Getting details from Youtube URL

We can easily get many details from a youtube url using some of Python libraries. Here am going to show you how we can get
1)Video id
2)Video title
3)Author of video
4)Video thumbnails

We use Python’s urlparse, urllib and simplejson libraries to do this.

import urlparse
import urllib
import simplejson
url_data = urlparse.urlparse("")
video_id = urlparse.parse_qs(url_data.query)["v"][0]  # this is the video id
# from this url you will get all data you needed about video, by just replacing the video id
url = '' % video_id 
json = simplejson.load(urllib.urlopen(url))

# this is the title of the video
title = json['entry']['title']['$t']  

# author of video               
author = json['entry']['author'][0]['name']['$t']
print "id:%s\nauthor:%s\ntitle:%s" % (id, author, title)

You will get thumbnails from this url:
image_id can be 0,1,2 or 3.


One thought on “Getting details from Youtube URL

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s