Skip to content

Instantly share code, notes, and snippets.

@rantav
Last active December 16, 2015 14:49
Show Gist options
  • Save rantav/5451336 to your computer and use it in GitHub Desktop.
Save rantav/5451336 to your computer and use it in GitHub Desktop.
import gdata.youtube
import gdata.youtube.service
import re
yt_service = gdata.youtube.service.YouTubeService()
def PrintEntryDetails(entry):
print 'Video ID: %s' % extract_id_from_video_url(entry.media.player.url)
print 'Video title: %s' % entry.media.title.text
print 'Video published on: %s ' % entry.published.text
#print 'Video description: %s' % entry.media.description.text
#print 'Video category: %s' % entry.media.category[0].text
#print 'Video tags: %s' % entry.media.keywords.text
print 'Video watch page: %s' % entry.media.player.url
#print 'Video flash player URL: %s' % entry.GetSwfUrl()
print 'Video duration: %s' % entry.media.duration.seconds
def PrintVideoFeed(feed):
for entry in feed.entry:
PrintEntryDetails(entry)
def GetAndPrintUserUploads(username):
yt_service = gdata.youtube.service.YouTubeService()
uri = 'http://gdata.youtube.com/feeds/api/users/%s/uploads?max-results=1' % username
PrintVideoFeed(yt_service.GetYouTubeVideoFeed(uri))
def extract_id_from_video_url(video_url):
match = re.search(r'\?\w*v=(\w{11})', video_url)
return match.group(1)
GetAndPrintUserUploads('ran')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment