Skip to content

Commit 303d741

Browse files
authored
Merge pull request #163 from ticky/additional-youtubedl-arguments
Allow additional youtube-dl arguments
2 parents 00c7bce + a878c05 commit 303d741

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ vimeo = [ # Multiple keys will be rotated.
8080
# filters = { title = "regex for title here", not_title = "regex for negative title match", description = "...", not_description = "..." } # Optional Golang regexp format. If set, then only download matching episodes.
8181
# opml = true|false # Optional inclusion of the feed in the OPML file (default value: false)
8282
# clean = { keep_last = 10 } # Keep last 10 episodes (order desc by PubDate)
83+
# youtube_dl_args = [ "--write-sub", "--embed-subs", "--sub-lang", "en,en-US,en-GB" ] # Optional extra arguments passed to youtube-dl when downloading videos from this feed. This example would embed available English closed captions in the videos. Note that setting '--audio-format' for audio format feeds, or '--format' or '--output' for any format may cause unexpected behaviour. You should only use this if you know what you are doing, and have read up on youtube-dl's options!
8384

8485
[database]
8586
badger = { truncate = true, file_io = true } # See https://github.com/dgraph-io/badger#memory-usage

pkg/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ type Feed struct {
4040
Clean Cleanup `toml:"clean"`
4141
// Custom is a list of feed customizations
4242
Custom Custom `toml:"custom"`
43+
// List of additional youtube-dl arguments passed at download time
44+
YouTubeDLArgs []string `toml:"youtube_dl_args"`
4345
// Included in OPML file
4446
OPML bool `toml:"opml"`
4547
}

pkg/ytdl/ytdl.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ func buildArgs(feedConfig *config.Feed, episode *model.Episode, outputFilePath s
214214
args = append(args, "--extract-audio", "--audio-format", "mp3", "--format", format)
215215
}
216216

217+
// Insert additional per-feed youtube-dl arguments
218+
args = append(args, feedConfig.YouTubeDLArgs...)
219+
217220
args = append(args, "--output", outputFilePath, episode.VideoURL)
218221
return args
219222
}

pkg/ytdl/ytdl_test.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ func TestBuildArgs(t *testing.T) {
1717
maxHeight int
1818
output string
1919
videoURL string
20+
ytdlArgs []string
2021
expect []string
2122
}{
2223
{
@@ -91,14 +92,24 @@ func TestBuildArgs(t *testing.T) {
9192
videoURL: "http://url1",
9293
expect: []string{"--format", "bestvideo[height<=1024][ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", "--output", "/tmp/2", "http://url1"},
9394
},
95+
{
96+
name: "Video high quality with custom youtube-dl arguments",
97+
format: model.FormatVideo,
98+
quality: model.QualityHigh,
99+
output: "/tmp/2",
100+
videoURL: "http://url1",
101+
ytdlArgs: []string{"--write-sub", "--embed-subs", "--sub-lang", "en,en-US,en-GB"},
102+
expect: []string{"--format", "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best", "--write-sub", "--embed-subs", "--sub-lang", "en,en-US,en-GB", "--output", "/tmp/2", "http://url1"},
103+
},
94104
}
95105

96106
for _, tst := range tests {
97107
t.Run(tst.name, func(t *testing.T) {
98108
result := buildArgs(&config.Feed{
99-
Format: tst.format,
100-
Quality: tst.quality,
101-
MaxHeight: tst.maxHeight,
109+
Format: tst.format,
110+
Quality: tst.quality,
111+
MaxHeight: tst.maxHeight,
112+
YouTubeDLArgs: tst.ytdlArgs,
102113
}, &model.Episode{
103114
VideoURL: tst.videoURL,
104115
}, tst.output)

0 commit comments

Comments
 (0)