Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use youtube-dl output template with extension parameter #50 #59

Merged
merged 1 commit into from
Nov 26, 2019

Conversation

huseyz
Copy link
Contributor

@huseyz huseyz commented Nov 25, 2019

This solves #50.
When youtube-dl downloads the original file from youtube it's using the given output template to name the file.

Currently when podsync asks it to download a file and convert it to audio with an output template like /path/episodeip.mp3; this causes the original file to be downloaded as /path/episodeip.mp3. Which leads to ffmpeg using it as both input and output; this causes ffmpeg to exit immediately saying output file already exists.

As a result, all the files stay as webm video files named as [episodeid].mp3s. These can't be served by itunes etc.

To reproduce:

[server]
port = 80
hostname = "http://localhost"
data_dir = "./data/"

[tokens]
youtube = "[YOUTUBE_TOKEN]"

[feeds]
  [feeds.arsimet]
  url = "https://www.youtube.com/watch?v=gPKLRwSuXwQ&list=PLWXQ0iArMOp-a7rWy84upd7J3tgMv9eZo"
  page_size = 10
  update_period = "6h"
  quality = "high"
  format = "audio"

Example ffprobe GD5xkdt2vwY.mp3 -hide_banner output:

Input #0, matroska,webm, from 'GD5xkdt2vwY.mp3':
  Metadata:
    encoder         : google/video-file
  Duration: 00:17:19.82, start: -0.007000, bitrate: 119 kb/s
    Stream #0:0(eng): Audio: opus, 48000 Hz, stereo, fltp (default)

One can see the output saying "output file exists" by adding a line to ytdl.go:106

log.Infof("youtube-dl output: %s", output)

This PR changes causes podsync to use an output template [episode_id].%(ext)s which translates to [episode_id.mp3] or [episode_id.mp4] depending on the configuration. please note that youtube-dl will use mp3 or mp4 based on --format which is passed in function Download in ytdl.go:41

Copy link
Owner

@mxpv mxpv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for doing this! I have a few comments.

cmd/podsync/updater.go Outdated Show resolved Hide resolved
cmd/podsync/updater.go Outdated Show resolved Hide resolved
Copy link
Contributor Author

@huseyz huseyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the changes you've asked for; calculation of the exact episode file path is still separated in multiple places. However unifying them in a proper way is beyond my go skills.

@mxpv
Copy link
Owner

mxpv commented Nov 26, 2019

Thank you!

@mxpv mxpv merged commit 3ba98e8 into mxpv:master Nov 26, 2019
@tuxpeople tuxpeople mentioned this pull request Nov 28, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants