From b5642456c2c51f2fbc2ae741b9fc281242a9b2c1 Mon Sep 17 00:00:00 2001 From: William P Date: Thu, 22 Jan 2026 23:11:59 -0500 Subject: [PATCH] add options for downloads --- app/ytdlp.go | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/app/ytdlp.go b/app/ytdlp.go index 1a26bb2..6b641c8 100644 --- a/app/ytdlp.go +++ b/app/ytdlp.go @@ -1,12 +1,19 @@ package main import ( - "time" - "fmt" "context" + "fmt" + "time" + "github.com/lrstanley/go-ytdlp" ) -func downloadVideo(out_dir, url string) { + +type DownloadOptions struct { + EmbedThumbnail bool + IncludeSubtitles bool +} + +func downloadVideo(out_dir, url string, opts DownloadOptions) { dl := ytdlp.New(). SetWorkDir(out_dir). FormatSort("res,ext:mp4:m4a"). @@ -20,10 +27,22 @@ func downloadVideo(out_dir, url string) { prog.Filename, ) }). - Output("%(extractor)s - %(title)s.%(ext)s") - - _, err := dl.Run(context.TODO(), url) - if err != nil { - panic(err) - } + Output("%(title)s.%(ext)s") + + if opts.EmbedThumbnail { + dl = dl.EmbedThumbnail() + } + + if opts.IncludeSubtitles { + dl = dl.CompatOptions("no-keep-subs") + dl = dl.EmbedSubs() + dl = dl.SubLangs("en,en*") + dl = dl.WriteAutoSubs() + dl = dl.WriteSubs() + } + + _, err := dl.Run(context.TODO(), url) + if err != nil { + panic(err) + } }