add options for downloads

This commit is contained in:
2026-01-22 23:11:59 -05:00
parent f569f382f5
commit b5642456c2

View File

@@ -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,7 +27,19 @@ func downloadVideo(out_dir, url string) {
prog.Filename,
)
}).
Output("%(extractor)s - %(title)s.%(ext)s")
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 {