downloading a youtube playlist and converting to mp3 (linux)

** A lot of music on youtube (that I listen to) is unsigned, if the music is released, support the artists and buy the tracks at beatport/itunes etc **

Made a 5 min script that does all the steps needed to download a youtube playlist and convert it to mp3. It is not perfectly efficient and could be significantly improved by checking if the song exists in that dir already.

This script is simply joining together:

Requirements: youtube-dl, ffmpeg, Python version 2.6, 2.7, or 3.3+ , libmp3lame0

Steps to get these on Ubuntu:

apt-get install ubuntu-restricted-extras

apt-get install libmp3lame0

apt-get install youtube-dl

apt-get install ffmpeg


Usage: sh [youtube playlist URL] [output_directory]


sh ./ /home/user1/Music/youtube/

To get the youtube playlist URL view the playlist by clicking on its name, no videos will be playing, then click on share and the url will be highlighted:

click on share and the URL will appear

note: any other .flv/.mp4 files in that directory will be converted to mp3 and deleted.

The script:

# Simple script to dl and convert youtube playlists - MarkC, 2013
# Usage: sh [youtube playlist addess] [output directory]
# To get the youtube playlist address, view the playlist then click on share, copy that URL
# example: sh /home/lp1/Music/youtube
# ytdl - abritrary extension name
youtube-dl -o "$2%(playlist)s/%(title)s.ytdl" --max-quality url $1
find $2 -type f -name "*.ytdl" -exec avconv -i '{}' '{}'.mp3 ;
find $2 -name *.ytdl -exec rm {} +


One thought on “downloading a youtube playlist and converting to mp3 (linux)”

  1. I’ll be back for the answer if there is one.
    Im using mint and it’s not working it can’t find the

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>