Home

Awesome

youtube-download

A userscript for MPV that allows you to download the current youtube video/audio with one key press.

Start a video download with ctrl+d (configurable) or start an audio download with ctrl+a (configurable).

Installation

Copy youtube-download.lua into your scripts directory, e.g.:

cp youtube-download.lua ~/.config/mpv/scripts/

optional, copy the config file:

cp youtube-download.conf ~/.config/mpv/script-opts/

Make sure you have either ffmpeg or avconv installed.

Windows:

The location of the scripts directory on Windows is %APPDATA%\mpv\scripts e.g. C:\Users\cvzi\AppData\Roaming\mpv\scripts The location of the .conf files on Windows is %APPDATA%\mpv\script-opts

On windows, you need to add the directory of the ffmpeg.exe to your machine's %PATH or put the ffmpeg.exe in the same directory as the youtube-dl.exe/yt-dlp.

uosc menu integration

If you want to add the download menu to uosc, you need to add one of the following lines to your input.conf. If you use the line starting with # it just creates an entry in the uosc menu. If you use the second line, it also creates a keyboard shortcut to open the menu. Replace d with the key of your choice:

#           script-message-to youtube_download menu     #! Download
OR
d           script-message-to youtube_download menu     #! Download

If you want it to appear in a submenu, replace Download with e.g. Utils > Download

Note: If you're using the default menu of uosc and you don't have the uosc menu defined in input.conf, you first need to create a menu configuration. You can find an example at https://github.com/tomasklaen/uosc#examples

screenshot of uosc

If you want uosc menu entries in your language, you can change the locale_content-option in youtube-download.conf. For example for Chinese (Simplified) localization:

locale_content=[{"Download": "下载","Audio": "音频","Subtitles": "字幕","Select range": "选择范围","Video (Current quality)": "视频(当前质量)","Video (Default quality)": "视频(默认质量)","Video with subtitles": "视频和字幕","Current file is not a youtube video": "当前文件不受支持","Video (Config file)": "视频(使用配置文件)","Audio (Config file)": "音频(使用配置文件)","Subtitle (Config file)": "字幕(使用配置文件)","Video with subtitles (Config file)": "视频和字幕(使用配置文件)","Download whole mpv playlist": "下载整个播放列表"}]

mpv.net:

The script folder for mpv.net is: %APPDATA%\mpv.net\scripts

The .conf files belong into: %APPDATA%\mpv.net\script-opts

The keyboard shortcuts in the script and the .conf-file don't work with mpv.net. You need to set the keyboard shortcuts yourself in your input.conf. Default location is %APPDATA%\mpv.net\input.conf. Add the following lines to the end of your input.conf (change the keys if they are already used, leave out lines that you don't need):


 Ctrl+d     script-message-to   youtube_download   download-video
 Ctrl+a     script-message-to   youtube_download   download-audio
 Ctrl+s     script-message-to   youtube_download   download-subtitle
 Ctrl+i     script-message-to   youtube_download   download-embed-subtitle

Debugging errors:

To get more information in case of an error you can make mpv print more data about the script:

mpv --msg-level=youtube_download=trace "https://www.youtube.com/watch?v=AbC_DeFgHIj"

or on Windows:

mpv.com --msg-level=youtube_download=trace "https://www.youtube.com/watch?v=AbC_DeFgHIj"

Features and default keyboard shortcuts:

Credit

youtube-quality's Credit