showing results for - "get all youtube playlist videos as json without api python"
Hilary
17 Mar 2019
1import urllib, json
2author = 'Youtube_Username'
3
4foundAll = False
5ind = 1
6videos = []
7while not foundAll:
8    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 ) )
9    try:
10        resp = json.load(inp)
11        inp.close()
12        returnedVideos = resp['feed']['entry']
13        for video in returnedVideos:
14            videos.append( video ) 
15
16        ind += 50
17        print len( videos )
18        if ( len( returnedVideos ) < 50 ):
19            foundAll = True
20    except:
21        #catch the case where the number of videos in the channel is a multiple of 50
22        print "error"
23        foundAll = True
24
25for video in videos:
26    print video['title'] # video title
27    print video['link'][0]['href'] #url
28