From cc1551a32862ea976f56faf59dbf8bf35f8ba809 Mon Sep 17 00:00:00 2001 From: siddharth ravikumar Date: Sat, 26 Nov 2022 09:23:32 -0500 Subject: feed: update `Feed.ydl` Add custom handling to set the output file name for media from buzzsprout.com. --- feed/feed.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/feed/feed.go b/feed/feed.go index 5e997ea..abd4dc5 100644 --- a/feed/feed.go +++ b/feed/feed.go @@ -11,6 +11,7 @@ import ( "os" "os/exec" "path" + "strings" "time" "ricketyspace.net/fern/schema" @@ -220,9 +221,15 @@ func (feed *Feed) ydl(url string) error { return fmt.Errorf("URL invalid") } + // Media file name. + mediaName := "%(title)s-%(id)s.%(ext)s" + if strings.Contains(url, "buzzsprout.com") { + mediaName = path.Base(url) + } + // Download url via youtube-dl outputTemplate := fmt.Sprintf("-o%s", - path.Join(feed.DumpDir, "%(title)s-%(id)s.%(ext)s")) + path.Join(feed.DumpDir, mediaName)) cmd := exec.Command(feed.YDLPath, "--no-progress", outputTemplate, url) _, err := cmd.CombinedOutput() if err != nil { -- cgit v1.2.3