Advertisement
Guest User

Untitled

a guest
Aug 30th, 2013
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.96 KB | None | 0 0
  1. import time
  2. import gdata.youtube
  3. import gdata.youtube.service
  4.  
  5. # my Youtube login data
  6. youtube_login = 'fb@frank-buss.de'
  7. youtube_password = 'this-is-not-my-password'
  8.  
  9. # project id, register at https://developers.google.com/youtube/registering_an_application
  10. youtube_project_id = 'foobar1234567'
  11.  
  12. # developer key, get it from https://code.google.com/apis/youtube/dashboard
  13. google_developer_key = 'HJI93........'
  14.  
  15. # connect to Youtube API
  16. print 'login...'
  17. yt_service = gdata.youtube.service.YouTubeService()
  18. yt_service.email = youtube_login
  19. yt_service.password = youtube_password
  20. yt_service.source = youtube_project_id
  21. yt_service.developer_key = google_developer_key
  22. yt_service.client_id = youtube_project_id
  23. yt_service.ProgrammaticLogin()
  24.  
  25. # EEVblog video count
  26. eevblog_count = 0
  27.  
  28. # print video details, if title contains "eevblog" and author is not EEVblog or Altzone
  29. def printEntryDetails(entry):
  30.     # get title
  31.     title = entry.media.title.text
  32.     if title.lower().find('eevblog') >= 0:
  33.         # get author
  34.         author = entry.author[0].name.text
  35.         if author != 'EEVblog' and author != 'Altzone':
  36.             # extract ID from URL
  37.             id = entry.id.text
  38.             id = id.split('/')
  39.             id = id[-1]
  40.             # show
  41.             print 'id: %s, author: %s, title: %s' % (id, author, title)
  42.  
  43. # process all videos of a feed and return the number of processed videos
  44. def printVideoFeed(feed):
  45.     count = len(feed.entry)
  46.     for entry in feed.entry:
  47.         printEntryDetails(entry)
  48.     return count
  49.  
  50. # search for videos with "eevblog" in title or other fields
  51. def getAndPrintUserUploads():
  52.     index = 1
  53.     while True:
  54.         # build URI, starting at "index"
  55.         uri = 'http://gdata.youtube.com/feeds/api/videos?vq=eevblog&start-index=%i&max-results=25' % index
  56.         # get feed
  57.         feed = yt_service.GetYouTubeVideoFeed(uri)
  58.         # process and return, if no more videos
  59.         count = printVideoFeed(feed)
  60.         if count == 0: return
  61.         index = index + count
  62.  
  63. print 'get EEVBlog videos not from EEVBlog or Altzone'
  64. getAndPrintUserUploads()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement