From 6e3d7820814cc6121725da83a7746b8f495f5f09 Mon Sep 17 00:00:00 2001 From: Kyle Yasuda Date: Mon, 7 Aug 2023 17:46:25 -0700 Subject: [PATCH] add ytdlp_file_format config variable (#6) - allow choosing preferred file format for downloads - update readme --- README.md | 7 ++++--- mpv-youtube-queue.conf | 1 + mpv-youtube-queue.lua | 5 ++++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 39b2180..577b657 100644 --- a/README.md +++ b/README.md @@ -77,13 +77,14 @@ This script requires the following software to be installed on the system - `downloader - curl`: The name of the program to use to download the video - `font_name - JetBrains Mono`: The name of the font to use - `font_size - 12`: Size of the font -- `marked_icon - ⇅`: The icon to use to mark a video as ready to be moved - in the queue +- `marked_icon - ⇅`: The icon to use to mark a video as ready to be moved in + the queue - `show_errors - yes`: Show error messages on the OSD +- `ytdlp_file_format - mp4`: The preferred file format for downloaded videos - `ytdlp_output_template - %(uploader)s/%(title)s.%(ext)s`: The [yt-dlp output template string](https://github.com/yt-dlp/yt-dlp#output-template) - Full path with the default `download_directory` - is: `~/videos/YouTube//.<ext>` + is: `~/videos/YouTube/<uploader>/<title>.<ext>` ## License diff --git a/mpv-youtube-queue.conf b/mpv-youtube-queue.conf index a38f6e5..bc36c5a 100644 --- a/mpv-youtube-queue.conf +++ b/mpv-youtube-queue.conf @@ -23,4 +23,5 @@ font_name=JetBrains Mono font_size=12 marked_icon=⇅ show_errors=yes +ytdlp_file_format=mp4 ytdlp_output_template=%(uploader)s/%(title)s.%(ext)s diff --git a/mpv-youtube-queue.lua b/mpv-youtube-queue.lua index 8dc2232..110ed32 100644 --- a/mpv-youtube-queue.lua +++ b/mpv-youtube-queue.lua @@ -44,6 +44,7 @@ local options = { font_size = 12, marked_icon = "⇅", show_errors = true, + ytdlp_file_format = "mp4", ytdlp_output_template = "%(uploader)s/%(title)s.%(ext)s" } @@ -462,7 +463,9 @@ function YouTubeQueue.download_video_at(idx) local v = video_queue[idx] local q = o.download_quality:sub(1, -2) local dl_dir = expanduser(o.download_directory) - local command = 'yt-dlp -f \'bestvideo[height<=' .. q .. + local command = 'yt-dlp -f \'bestvideo[height<=' .. q .. '][ext=' .. + options.ytdlp_file_format .. ']+bestaudio/best[height<=' .. + q .. ']/bestvideo[height<=' .. q .. ']+bestaudio/best[height<=' .. q .. ']\' -o "' .. dl_dir .. "/" .. options.ytdlp_output_template .. '" --downloader ' .. o.downloader .. ' ' .. v.video_url