add ytdlp_file_format config variable (#6)

- allow choosing preferred file format for downloads
- update readme
This commit is contained in:
Kyle Yasuda 2023-08-07 17:46:25 -07:00 committed by GitHub
parent cc8c677e0b
commit 6e3d782081
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 4 deletions

View File

@ -77,9 +77,10 @@ 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 - `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_name - JetBrains Mono`: The name of the font to use
- `font_size - 12`: Size of the font - `font_size - 12`: Size of the font
- `marked_icon - ⇅`: The icon to use to mark a video as ready to be moved - `marked_icon - ⇅`: The icon to use to mark a video as ready to be moved in
in the queue the queue
- `show_errors - yes`: Show error messages on the OSD - `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 - `ytdlp_output_template - %(uploader)s/%(title)s.%(ext)s`: The [yt-dlp output
template string](https://github.com/yt-dlp/yt-dlp#output-template) template string](https://github.com/yt-dlp/yt-dlp#output-template)
- Full path with the default `download_directory` - Full path with the default `download_directory`

View File

@ -23,4 +23,5 @@ font_name=JetBrains Mono
font_size=12 font_size=12
marked_icon=⇅ marked_icon=⇅
show_errors=yes show_errors=yes
ytdlp_file_format=mp4
ytdlp_output_template=%(uploader)s/%(title)s.%(ext)s ytdlp_output_template=%(uploader)s/%(title)s.%(ext)s

View File

@ -44,6 +44,7 @@ local options = {
font_size = 12, font_size = 12,
marked_icon = "", marked_icon = "",
show_errors = true, show_errors = true,
ytdlp_file_format = "mp4",
ytdlp_output_template = "%(uploader)s/%(title)s.%(ext)s" 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 v = video_queue[idx]
local q = o.download_quality:sub(1, -2) local q = o.download_quality:sub(1, -2)
local dl_dir = expanduser(o.download_directory) 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 .. ']+bestaudio/best[height<=' .. q .. ']\' -o "' .. dl_dir ..
"/" .. options.ytdlp_output_template .. "/" .. options.ytdlp_output_template ..
'" --downloader ' .. o.downloader .. ' ' .. v.video_url '" --downloader ' .. o.downloader .. ' ' .. v.video_url