Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save neiesc/7f51a3747b0085d1fc0d640d902374c8 to your computer and use it in GitHub Desktop.
Save neiesc/7f51a3747b0085d1fc0d640d902374c8 to your computer and use it in GitHub Desktop.
Download Audio from YouTube with youtube-dl

Download Audio from YouTube

-i - ignore errors

-c - continue

--extract-audio - extract audio track

--audio-format mp3 - convert to mp3

--audio-quality 0 - the best audio quality

--yes-playlist - affirm that url points to a playlist

YT_URL - video url from youtube

Download single entry

yt-dlp -i --extract-audio --audio-format mp3 --audio-quality 0 YT_URL

Download playlist

yt-dlp -ict --yes-playlist --extract-audio --audio-format mp3 --audio-quality 0 https://www.youtube.com/playlist?list=UUCvVpbYRgYjMN7mG7qQN0Pg

Download playlist, --download-archive downloaded.txt add successfully downloaded files into downloaded.txt

yt-dlp --download-archive downloaded.txt --no-overwrites -ict --yes-playlist --extract-audio --audio-format mp3 --audio-quality 0 --socket-timeout 5 https://www.youtube.com/playlist?list=UUCvVpbYRgYjMN7mG7qQN0Pg

Retry until success, no -i option

while ! yt-dlp --download-archive downloaded.txt --no-overwrites -ct --yes-playlist --extract-audio --audio-format mp3 --audio-quality 0 --socket-timeout 5 <YT_PlayList_URL>; do echo DISCONNECTED; sleep 5; done

while ! yt-dlp --download-archive downloaded.txt --no-overwrites -ct --yes-playlist --extract-audio --audio-format mp3 --audio-quality 0 --socket-timeout 5 --embed-thumbnail --add-metadata <YT_PlayList_URL>; do echo DISCONNECTED; sleep 5; done

Added

--embed-thumbnail --add-metadata for infos

References

https://askubuntu.com/questions/634584/how-to-download-youtube-videos-as-a-best-quality-audio-mp3-using-youtube-dl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment