How do I fetch youtube title and description from python code from the given url. Is it necessory to use youtube API for it? I am writing a program which need to find generate title and description from given url
Python Script to Get Information from YouTubeFirst, we import the required libraries. To move further, we create the HTTP session. Now, we create a function that will return all the data in a dictionary. In the above method, we download the HTML code of the web page.
It is not necessary, but it is probably significantly quicker and easier than writing your own.
For more information, see https://developers.google.com/youtube/1.0/developers_guide_python
After installing the gdata
module, try
import gdata.youtube
import gdata.youtube.service
yt_service = gdata.youtube.service.YouTubeService()
# authorize - you need to sign up for your own access key, or be rate-limited
# yt_service.developer_key = 'ABCxyz123...'
# yt_service.client_id = 'My-Client_id'
def PrintEntryDetails(entry):
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
for entry in yt_service.GetTopRatedVideoFeed().entry:
PrintEntryDetails(entry)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With