Created
March 2, 2014 19:19
-
-
Save m4rk3r/9312131 to your computer and use it in GitHub Desktop.
batch dl youtube playlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
from math import ceil | |
import os | |
import time | |
_PLAYLIST_ = 'PLA280ADDF60B3B17E' | |
_URL_ = 'https://gdata.youtube.com/feeds/api/playlists/{0}?v=2&alt=json' | |
_BY_ = 25 | |
first=True | |
videos = [] | |
data = json.loads(requests.get(_URL_.format(_PLAYLIST_)).text) | |
total = data['feed']['openSearch$totalResults']['$t'] | |
for idx in xrange(1,total,_BY_): | |
if not first: data = json.loads(requests.get(_URL_.format(_PLAYLIST_)+'&start-index='+str(idx)).text) | |
else: first = False | |
for entry in data['feed']['entry']: | |
videos.append( entry['link'][0]['href'] ) | |
print videos | |
for video in videos: | |
os.system('youtube-dl {0}'.format(video)) | |
time.sleep(15) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment