From c5c2fe7cf412e6203dc30f0268fa5566669ea287 Mon Sep 17 00:00:00 2001 From: siddharth Date: Mon, 29 Nov 2021 17:40:56 -0500 Subject: feed: update ydl Instead of 'cd'ing into the dumpdir, use the '-o' flag in youtube-dl to specify the directory under which the enttry needs to be downloaded to. --- feed/feed.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) (limited to 'feed') diff --git a/feed/feed.go b/feed/feed.go index c4fa5e0..dc28f65 100644 --- a/feed/feed.go +++ b/feed/feed.go @@ -192,19 +192,10 @@ func (feed *Feed) ydl(url string) error { return fmt.Errorf("URL invalid") } - // Change working directory to feed's dumpdir. - wd, err := os.Getwd() - if err != nil { - return err - } - defer os.Chdir(wd) - err = os.Chdir(feed.DumpDir) - if err != nil { - return err - } - // Download url via youtube-dl - cmd := exec.Command(feed.YDLPath, "--no-progress", url) + outputTemplate := fmt.Sprintf("-o%s", + path.Join(feed.DumpDir, "%(title)s-%(id)s.%(ext)s")) + cmd := exec.Command(feed.YDLPath, "--no-progress", outputTemplate, url) out, err := cmd.CombinedOutput() fmt.Printf("[%s]: %s", feed.Id, out) if err != nil { -- cgit v1.2.3