Glam Prestige Journal

Bright entertainment trends with youth appeal.

I was wondering if it was possible to download a youtube playlist as mp3 using youtube-dl, skipping already existing files. I am using this command:

youtube-dl --continue --ignore-errors --no-overwrites --extract-audio --audio-format mp3 --output "%(title)s.%(ext)s" [path here]

and, even though I set it to not overwrite, it does redownload everything from scratch. Is this possible?

2

2 Answers

With the option --download-archive FILE youtube-dl both reads and adds to a list of files not to download again. Every time a file is successfully downloaded, that video id is added to FILE.

You can use it as follows:

youtube-dl --download-archive downloaded.txt --no-post-overwrites -ciwx --audio-format mp3 -o "%(title)s.%(ext)s" [path here]

It will redownload any videos from before that you didn't keep for one last time as it creates the list. You can now delete them.

If your MP3 files had been named with the default format of %(title)s-%(id)s.%(ext)s, you could have avoided the redownload by creating downloaded.txt from the youtube %(id)s in a bash terminal as follows:

for n in *.mp3
do if [[ "$n" =~ -[-_0-9a-zA-Z]{11}.mp3$ ]] then echo "youtube ${n: -15: 11}" >> downloaded.txt fi
done
4

This is really helpful. If it's of any use to anybody, I modified the code to create the existing downloads list to include all files in the folder. Useful if downloading audio with the --extract-audio and --audio-quality "best" flags

for n in *.*
do if [[ "$n" =~ -[-_0-9a-zA-Z]{11}.*$ ]] then echo "youtube ${n: -15: 11}" >> downloaded.txt fi
done

I'm sure most people could have worked that out for themselves, but not everyone is clued-up with bash scripting.

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy