annotate tools/get_vids.py @ 79:548b9e61bd64

Updated bands.json to include "asset_prefix" tags for all the bands. Incorporated all the small images from Ferenc into the bands slideshow. Went through and crushed all the large images to fit within 800x600. Make sure to "manage.py loaddata bands.json" after picking this up.
author Chris Ridgway <ckridgway@gmail.com>
date Fri, 25 Nov 2011 16:54:59 -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)