Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import gdata.youtube
- import gdata.youtube.service
- # my Youtube login data
- youtube_login = 'fb@frank-buss.de'
- youtube_password = 'this-is-not-my-password'
- # project id, register at https://developers.google.com/youtube/registering_an_application
- youtube_project_id = 'foobar1234567'
- # developer key, get it from https://code.google.com/apis/youtube/dashboard
- google_developer_key = 'HJI93........'
- # connect to Youtube API
- print 'login...'
- yt_service = gdata.youtube.service.YouTubeService()
- yt_service.email = youtube_login
- yt_service.password = youtube_password
- yt_service.source = youtube_project_id
- yt_service.developer_key = google_developer_key
- yt_service.client_id = youtube_project_id
- yt_service.ProgrammaticLogin()
- # EEVblog video count
- eevblog_count = 0
- # print video details, if title contains "eevblog" and author is not EEVblog or Altzone
- def printEntryDetails(entry):
- # get title
- title = entry.media.title.text
- if title.lower().find('eevblog') >= 0:
- # get author
- author = entry.author[0].name.text
- if author != 'EEVblog' and author != 'Altzone':
- # extract ID from URL
- id = entry.id.text
- id = id.split('/')
- id = id[-1]
- # show
- print 'id: %s, author: %s, title: %s' % (id, author, title)
- # process all videos of a feed and return the number of processed videos
- def printVideoFeed(feed):
- count = len(feed.entry)
- for entry in feed.entry:
- printEntryDetails(entry)
- return count
- # search for videos with "eevblog" in title or other fields
- def getAndPrintUserUploads():
- index = 1
- while True:
- # build URI, starting at "index"
- uri = 'http://gdata.youtube.com/feeds/api/videos?vq=eevblog&start-index=%i&max-results=25' % index
- # get feed
- feed = yt_service.GetYouTubeVideoFeed(uri)
- # process and return, if no more videos
- count = printVideoFeed(feed)
- if count == 0: return
- index = index + count
- print 'get EEVBlog videos not from EEVBlog or Altzone'
- getAndPrintUserUploads()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement