Skip to content

Instantly share code, notes, and snippets.

@josenaves
Last active February 6, 2020 06:47
Show Gist options
  • Save josenaves/6440058 to your computer and use it in GitHub Desktop.
Save josenaves/6440058 to your computer and use it in GitHub Desktop.
import urllib, json
author = 'Youtube_Username'
foundAll = False
ind = 1
videos = []
while not foundAll:
inp = urllib.urlopen(r'http://gdata.youtube.com/feeds/api/videos?start-index={0}&max-results=50&alt=json&orderby=published&author={1}'.format( ind, author ) )
try:
resp = json.load(inp)
inp.close()
returnedVideos = resp['feed']['entry']
for video in returnedVideos:
videos.append( video )
ind += 50
print len( videos )
if ( len( returnedVideos ) < 50 ):
foundAll = True
except:
#catch the case where the number of videos in the channel is a multiple of 50
print "error"
foundAll = True
for video in videos:
print video['title'] # video title
print video['link'][0]['href'] #url
@Ghanshyamsavaliya
Copy link

@josenaves, I have tried your code but it is giving me some error.

Error:
HTTPError: HTTP Error 404: Not Found

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