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

Fix yt-dlp output filename template #111

Merged
merged 1 commit into from
Feb 19, 2023

Conversation

rantanevich
Copy link
Contributor

@rantanevich rantanevich commented Feb 19, 2023

After upgrading yt-dlp, the target file name is generated as -o {{.Filename}}.tmp + .mp3

$ pip3 freeze | grep yt-dlp
yt-dlp==2023.2.17

$ yt-dlp --extract-audio --audio-format=mp3 --audio-quality=0 -f m4a/bestaudio "https://www.youtube.com/watch?v=hhvNl2a04aM" --no-progress -o 4f92358fcd37f1e117962be5ab69f02cda651d4c.tmp
[youtube] Extracting URL: https://www.youtube.com/watch?v=hhvNl2a04aM
[youtube] hhvNl2a04aM: Downloading webpage
[youtube] hhvNl2a04aM: Downloading android player API JSON
[info] hhvNl2a04aM: Downloading 1 format(s): 140
[download] Destination: 4f92358fcd37f1e117962be5ab69f02cda651d4c.tmp
[download] Download completed
[FixupM4a] Correcting container of "4f92358fcd37f1e117962be5ab69f02cda651d4c.tmp"
[ExtractAudio] Destination: 4f92358fcd37f1e117962be5ab69f02cda651d4c.tmp.mp3
Deleting original file 4f92358fcd37f1e117962be5ab69f02cda651d4c.tmp (pass -k to keep)

But we expect to get {{.Filename}}.mp3 that leads to skipping new entries

file = filepath.Join(d.destination, fname+".mp3")
if _, err := os.Stat(file); os.IsNotExist(err) {
return file, ErrSkip
}

@rantanevich rantanevich requested a review from umputun as a code owner February 19, 2023 14:04
Copy link
Owner

@umputun umputun left a comment

Choose a reason for hiding this comment

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

The problem was discussed, and the issue is real. However, the fix you are proposing is not fixing it. It changes a test and a comment but won't change the behavior. Still, it is good to have for consistency; however, to fix it, the user needs to adjust yml configuration and get rid of .tmp suffix.

I have updated provided yml files in the example and the documentation; see c96f4f1

@umputun umputun merged commit 9be6959 into umputun:master Feb 19, 2023
@rantanevich
Copy link
Contributor Author

My fault I didn't update default value in ./app/config/config.go. So it would allow not to specify c.YouTube.DlTemplate in the config

if c.YouTube.DlTemplate == "" {
c.YouTube.DlTemplate = `yt-dlp --extract-audio --audio-format=mp3 --audio-quality=0 -f m4a/bestaudio "https://www.youtube.com/watch?v={{.ID}}" --no-progress -o {{.FileName}}.tmp`
}

Should I preparer a new PR or you will fix it yourself?

@rantanevich rantanevich deleted the fix-youtube.dltemplate branch February 20, 2023 08:42
umputun added a commit that referenced this pull request Feb 20, 2023
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