Skip to content

Instantly share code, notes, and snippets.

@ag7
Last active August 29, 2015 14:25
Show Gist options
  • Save ag7/bd84d16e8fe457d98132 to your computer and use it in GitHub Desktop.
Save ag7/bd84d16e8fe457d98132 to your computer and use it in GitHub Desktop.
Download youtube mp3 playlist into specific folder.
#!/usr/bin/env python
import sys, os, subprocess
# requirements: youtube-dl and ffmpeg
if __name__ == "__main__":
if len(sys.argv) != 4:
print "usage: youtube_playlist_downloader.py -o <dir> <playlist-link>"
sys.exit(1)
if not os.path.isdir(sys.argv[2]):
try:
os.makedirs(sys.argv[2])
except:
print "cannot create dir " + sys.argv[2]
sys.exit(1)
os.chdir(sys.argv[2])
sys.exit(subprocess.call([
"youtube-dl",
"-citx",
"--auto-number",
"--autonumber-size", "2",
"--audio-format", "mp3",
"--audio-quality", "0",
sys.argv[3]]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment