From 49b8dd4dd40e9e817c7a011f9e60f41b70f8203b Mon Sep 17 00:00:00 2001 From: Viktor Varland Date: Tue, 9 Sep 2025 09:05:47 +0200 Subject: [PATCH] refactor: rename and rely on yt-dlp defauls more --- Containerfile | 5 ++-- README.md | 3 ++- internal/config/config.go | 5 ++-- internal/dl/dl.go | 20 ++++++++------- internal/format/rss.go | 51 +++++++++++++++++++-------------------- 5 files changed, 44 insertions(+), 40 deletions(-) diff --git a/Containerfile b/Containerfile index 9b8e1c9..06bdf60 100644 --- a/Containerfile +++ b/Containerfile @@ -54,7 +54,8 @@ COPY <<-EOT /data/config.json "youtube": { "verbose": false, "cmd": "/home/subsyt/.local/bin/yt-dlp", - "quality": "res:1080", + "format": "", + "format_sort": "", "output_path_template": "s%(upload_date>%Y)s/%(channel)s.s%(upload_date>%Y)Se%(upload_date>%m%d)S.%(title)s.%(id)s.%(ext)s", "url": "https://www.youtube.com", "throttle": 5, @@ -62,7 +63,7 @@ COPY <<-EOT /data/config.json "opml_file": "/data/opml.xml", "po_token": "", "bgutil_server": "http://bgutil:4416", - "player_client": "mweb" + "player_client": "" } } } diff --git a/README.md b/README.md index cc1a0d3..f5b9039 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,8 @@ Full `config.json`: "youtube": { "verbose": false, "cmd": "./yt-dlp", - "quality": "res:1080", + "format": "best", + "format_sort": "res:1080", "output_path_template": "s%(upload_date>%Y)s/%(channel)s.s%(upload_date>%Y)Se%(upload_date>%m%d)S.%(title)s.%(id)s.%(ext)s", "url": "https://www.youtube.com", "throttle": 5, diff --git a/internal/config/config.go b/internal/config/config.go index 65c5831..53945df 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -12,12 +12,13 @@ type Provider struct { Cmd string Cookies_file string Opml_file string - Quality string + Format string + Format_sort string Output_path_template string Po_token string Verbose bool Bgutil_server string - Player_client string + Player_client string } type Config struct { diff --git a/internal/dl/dl.go b/internal/dl/dl.go index 7f1656f..cd4e46f 100644 --- a/internal/dl/dl.go +++ b/internal/dl/dl.go @@ -18,10 +18,10 @@ import ( ) type Download struct { - Url string - OutDir string - Name string - DryRun bool + Url string + OutDir string + Name string + DryRun bool Metadata bool } @@ -58,7 +58,7 @@ func Youtube(d Download, p config.Provider) { if d.Metadata == true { log.Println("Downloading metadata") mArgs := []string{ - "--skip-download", + "--skip-download", "--no-overwrites", "--playlist-items", "0:0:1", } @@ -85,10 +85,12 @@ func Youtube(d Download, p config.Provider) { } args = append(args, dArgs...) - if p.Quality != "" { - args = append(args, "--format-sort", p.Quality) - } else { - args = append(args, "--format-sort", "res:1080") + if p.Format != "" { + args = append(args, "--format", p.Format) + } + + if p.Format_sort != "" { + args = append(args, "--format-sort", p.Format_sort) } } diff --git a/internal/format/rss.go b/internal/format/rss.go index ea697fb..f21fa87 100644 --- a/internal/format/rss.go +++ b/internal/format/rss.go @@ -5,25 +5,25 @@ import ( ) type Feed struct { - XMLName xml.Name `xml:"feed"` - Id string `xml:"id"` - ChannelId string `xml:"yt:channelId"` - Title string `xml:"title"` - Published string `xml:"published"` - Links []Link `xml:"link"` - Author Author `xml:"author"` - Entries []Entry `xml:"entry"` + XMLName xml.Name `xml:"feed"` + Id string `xml:"id"` + ChannelId string `xml:"yt:channelId"` + Title string `xml:"title"` + Published string `xml:"published"` + Links []Link `xml:"link"` + Author Author `xml:"author"` + Entries []Entry `xml:"entry"` } type Link struct { - Rel string `xml:"rel,attr"` + Rel string `xml:"rel,attr"` Href string `xml:"href,attr"` } type Author struct { XMLName xml.Name `xml:"author"` - Name string `xml:"name"` - Uri string `xml:"uri"` + Name string `xml:"name"` + Uri string `xml:"uri"` } type MediaContent struct { @@ -56,27 +56,26 @@ type MediaCommunity struct { } type MediaGroup struct { - Title string `xml:"title"` - Content MediaContent `xml:"content"` - Thumbnail MediaThumbnail `xml:"thumbnail"` - Description string `xml:"description"` - Community MediaCommunity `xml:"community"` + Title string `xml:"title"` + Content MediaContent `xml:"content"` + Thumbnail MediaThumbnail `xml:"thumbnail"` + Description string `xml:"description"` + Community MediaCommunity `xml:"community"` } type Entry struct { - XMLName xml.Name `xml:"entry"` - Title string `xml:"title"` - Id string `xml:"id"` - VideoId string `xml:"videoId"` - ChannelId string `xml:"channelId"` - Link Link `xml:"link"` - Author Author `xml:"author"` - Published string `xml:"published"` - Updated string `xml:"updated"` + XMLName xml.Name `xml:"entry"` + Title string `xml:"title"` + Id string `xml:"id"` + VideoId string `xml:"videoId"` + ChannelId string `xml:"channelId"` + Link Link `xml:"link"` + Author Author `xml:"author"` + Published string `xml:"published"` + Updated string `xml:"updated"` MediaGroup MediaGroup `xml:"group"` } - func RssLoad(data []byte) (Feed, error) { feed := Feed{}