annotate tools/get_vids.py @ 87:fbeda0f5f3be

Fix for odd Webkit CSS issue when using jPlayer Blue Monday skin and our CSS. All instances of the Future Bugler font on the Listen page were jaggie and smaller than expected.
author Chris Ridgway <ckridgway@gmail.com>
date Sun, 27 Nov 2011 15:06:26 -0600
parents a0d3bc630ebd
children
rev   line source
bgneal@60 1 """
bgneal@60 2 Quick & dirty Python script to retrieve the video IDs of all the videos in a
bgneal@60 3 playlist on YouTube.
bgneal@60 4
bgneal@60 5 """
bgneal@60 6 import urlparse
bgneal@60 7
bgneal@60 8 from gdata.youtube.service import YouTubeService
bgneal@60 9
bgneal@60 10
bgneal@60 11 PLAYLIST_ID = '26E22C14D94D323F'
bgneal@60 12
bgneal@60 13 yt = YouTubeService()
bgneal@60 14 feed = yt.GetYouTubePlaylistVideoFeed(playlist_id=PLAYLIST_ID)
bgneal@60 15
bgneal@60 16 print "Feed contains %s videos" % feed.total_results.text
bgneal@60 17
bgneal@60 18 vids = []
bgneal@60 19 while True:
bgneal@60 20 vids.extend(feed.entry)
bgneal@60 21 next_link = feed.GetNextLink()
bgneal@60 22 if not next_link:
bgneal@60 23 break
bgneal@60 24 feed = yt.Query(next_link.href)
bgneal@60 25
bgneal@60 26 print "Got %d videos" % len(vids)
bgneal@60 27
bgneal@60 28 vid_ids = []
bgneal@60 29 problems = []
bgneal@60 30 for vid in vids:
bgneal@60 31 for link in vid.link:
bgneal@60 32 url_data = urlparse.urlparse(link.href)
bgneal@60 33 query = urlparse.parse_qs(url_data.query)
bgneal@60 34 if 'v' in query:
bgneal@60 35 vid_ids.append(query['v'][0])
bgneal@60 36 break
bgneal@60 37 else:
bgneal@60 38 print "Video id not found for %s" % vid.title.text
bgneal@60 39
bgneal@60 40 video_id = vid_ids[0]
bgneal@60 41 playlist = vid_ids[1:]
bgneal@60 42
bgneal@60 43 print "videoId: '%s'," % video_id
bgneal@60 44 print "playerVars: { playlist: [ %s ] }," % ','.join("'%s'" % v for v in
bgneal@60 45 playlist)