Finding the total number of comments for a Video Entry with the Python Client Library

The snippet below shows how to retrieve the total number of comments for a video entry by examining the comment feed object using the interactive shell:
>>> import gdata.youtube.service
>>> client = gdata.youtube.service.YouTubeService()
>>> feed = client.GetRecentlyFeaturedVideoFeed()
>>> # fetching the first entry from the recently featured video feed
>>> entry = feed.entry[0]
>>> entry.title.text
"Follow Obama's nomination week: youtube.com/2008conventions"
>>> # fetching the comment feed
>>> comments = client.GetYouTubeVideoCommentFeed(video_id='9N4GOpSt5OI')
>>> # printing the text contents of the total_results element
>>> # note that this element is part of every feed
>>> comments.total_results.text
'578'
Alternatively, if you want to eliminate the actual request to catch the comment feed itself, you can parse out the number of comments by examining the 'countHint' attribute of the comment feedLink:
>>> entry.comments.feed_link[0].count_hint
'50'

5 comments:

  1. De-tox is an approach to free your high schooler's body of all the hurtful synthetic compounds that drugs or liquor have deserted. Similarly as with most drugs, withdrawal indications can prompt extraordinary queasiness and even agony.
    quotes on addiction recovery
    quotes about drug recovery

    ReplyDelete
  2. fix hp printer in error state status displays that there may be a problem with printer itself. Make sure printer is turned on and connected to PC.

    ReplyDelete
  3. I really enjoyed this information.
    Thanks for sharing this wonderful piece of information.
    With the help of my websites and blogs you can get more easy guidelines to setup, configure and troubleshoot your printers.
    In case if you have any queries and to solve your troubles just check into my websites or blogs to resolve your canon.com/ijsetup problems.

    ReplyDelete