diff --git a/internal/dl/dl.go b/internal/dl/dl.go index 36ceb0e..c858563 100644 --- a/internal/dl/dl.go +++ b/internal/dl/dl.go @@ -151,7 +151,6 @@ func Youtube(d Download, p config.Provider) { } if d.DryRun == true { - log.Println("/!\\ DRY RUN ENABLED /!\\") args = append(args, "--simulate") } else { args = append(args, "--no-simulate") @@ -163,7 +162,6 @@ func Youtube(d Download, p config.Provider) { // of 1 ... this results in zero videos being downloaded. if d.Metadata == true { - log.Println("Downloading channel metadata") mArgs := []string{ "--skip-download", "--no-overwrites", @@ -171,7 +169,6 @@ func Youtube(d Download, p config.Provider) { } args = append(args, mArgs...) } else { - log.Println("Downloading video") archive := filepath.Join(d.OutDir, "archive.txt") throttle := strconv.Itoa(p.Throttle) @@ -244,16 +241,17 @@ func Youtube(d Download, p config.Provider) { log.Fatal(err) } - log.Printf("[%s] running yt-dlp with args: %v\n", d.OutDir, args) - var wg sync.WaitGroup wg.Add(2) + var outBuf, errBuf strings.Builder + go func() { defer wg.Done() scanner := bufio.NewScanner(stdout) for scanner.Scan() { - log.Printf("[%s] %s\n", d.OutDir, scanner.Text()) + outBuf.WriteString(scanner.Text()) + outBuf.WriteString("\n") } }() @@ -261,7 +259,8 @@ func Youtube(d Download, p config.Provider) { defer wg.Done() scanner := bufio.NewScanner(stderr) for scanner.Scan() { - log.Printf("[%s] %s\n", d.OutDir, scanner.Text()) + errBuf.WriteString(scanner.Text()) + errBuf.WriteString("\n") } }() @@ -273,8 +272,20 @@ func Youtube(d Download, p config.Provider) { wg.Wait() err = cmd.Wait() + combined := outBuf.String() + errBuf.String() + if err != nil { - log.Printf("Error: %s\n", err) + log.Printf("FAIL %s\n", d.Url) + log.Printf(" cmd: %s %s\n", p.Cmd, strings.Join(args, " ")) + for _, line := range strings.Split(strings.TrimSpace(combined), "\n") { + log.Printf(" | %s\n", line) + } + } else if d.Metadata { + // metadata downloads are silent on success + } else if strings.Contains(combined, "has already been recorded in the archive") { + log.Printf("SKIP %s (archived)\n", d.Url) + } else { + log.Printf(" OK %s\n", d.Url) } } diff --git a/main.go b/main.go index d28002c..59df306 100644 --- a/main.go +++ b/main.go @@ -42,8 +42,6 @@ func run(cfg config.Config) { } for _, outlines := range opml.Body.Outline { - log.Printf("Archiving videos from OPML: %s\n", outlines.Title) - for _, outline := range outlines.Outlines { rssData, err := dl.RssDownloader(outline.XmlUrl) if err != nil { @@ -57,7 +55,6 @@ func run(cfg config.Config) { continue } - // download the channel dl.Youtube(dl.Download{ Url: feed.Author.Uri, OutDir: paths.ChannelsDir, @@ -65,12 +62,11 @@ func run(cfg config.Config) { Metadata: true, }, provider) - log.Printf("Downloaded RSS feed for %s with %d entries", feed.Title, len(feed.Entries)) + log.Printf("[%s] %d entries", feed.Title, len(feed.Entries)) for _, entry := range feed.Entries { url := fmt.Sprintf("%s/watch?v=%s", provider.Url, entry.VideoId) - log.Printf("Entry: %#v", entry) dl.Youtube(dl.Download{ Url: url, OutDir: paths.EpisodesDir,