Skip to content

Commit 3690018

Browse files
committed
Allow custom youtube-dl path
1 parent 43c44fc commit 3690018

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

pkg/ytdl/ytdl.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ type Config struct {
3535
SelfUpdate bool `toml:"self_update"`
3636
// Timeout in minutes for youtube-dl process to finish download
3737
Timeout int `toml:"timeout"`
38+
// CustomBinary is a custom path to youtube-dl, this allows using various youtube-dl forks.
39+
CustomBinary string `toml:"custom_binary"`
3840
}
3941

4042
type YoutubeDl struct {
@@ -44,12 +46,25 @@ type YoutubeDl struct {
4446
}
4547

4648
func New(ctx context.Context, cfg Config) (*YoutubeDl, error) {
47-
path, err := exec.LookPath("youtube-dl")
48-
if err != nil {
49-
return nil, errors.Wrap(err, "youtube-dl binary not found")
50-
}
49+
var (
50+
path string
51+
err error
52+
)
53+
54+
if cfg.CustomBinary != "" {
55+
path = cfg.CustomBinary
56+
57+
// Don't update custom youtube-dl binaries.
58+
log.Warnf("using custom youtube-dl binary, turning self updates off")
59+
cfg.SelfUpdate = false
60+
} else {
61+
path, err = exec.LookPath("youtube-dl")
62+
if err != nil {
63+
return nil, errors.Wrap(err, "youtube-dl binary not found")
64+
}
5165

52-
log.Debugf("found youtube-dl binary at %q", path)
66+
log.Debugf("found youtube-dl binary at %q", path)
67+
}
5368

5469
timeout := DefaultDownloadTimeout
5570
if cfg.Timeout > 0 {

0 commit comments

Comments
 (0)