Skip to content

Instantly share code, notes, and snippets.

@fnielsen
Created September 17, 2013 20:01
Show Gist options
  • Save fnielsen/6599783 to your computer and use it in GitHub Desktop.
Save fnielsen/6599783 to your computer and use it in GitHub Desktop.
Example of iteration over YouTube comments with Python.
import gdata.youtube.service
yts = gdata.youtube.service.YouTubeService()
urlpattern = "http://gdata.youtube.com/feeds/api/videos/" + \
"9ar0TF7J5f0/comments?start-index=%d&max-results=25"
index = 1
url = urlpattern % index
comments = []
while True:
ytfeed = yts.GetYouTubeVideoCommentFeed(uri=url)
comments.extend([comment.content.text for comment in ytfeed.entry])
if not ytfeed.GetNextLink(): break
url = ytfeed.GetNextLink().href
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment