summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2021-11-29 17:40:56 -0500
committersiddharth <s@ricketyspace.net>2021-11-29 17:40:56 -0500
commitc5c2fe7cf412e6203dc30f0268fa5566669ea287 (patch)
treea6f19798878ce01625fe1a65ae5cb5a2697b8a06
parentb2af9479be7642aa9877c147b2bf7e1cf920e16b (diff)
feed: update ydlv0.1.0
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.
-rw-r--r--feed/feed.go15
1 files changed, 3 insertions, 12 deletions
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 {