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........'
- # complaint details
- # the username is the string in the Youtube channel, e.g.
- # http://www.youtube.com/channel/UCC1Jo9UvXfS1CmrfbBX759g/videos
- complaint_username = 'UCC1Jo9UvXfS1CmrfbBX759g'
- complaint_term = 'RIGHTS'
- complaint_text = (
- 'This is original content from the EEVblog channel, which was uploaded without the permission '
- 'from Dave Jones, please remove it. '
- 'See http://www.eevblog.com/forum/news/226-of-my-videos-copied/ for details.'
- )
- # start with this EEVblog video copy, in case previous calls to this script exited
- eevblog_start_index = 4
- # 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 and file a complaint
- def printEntryDetailsAndComplain(entry):
- # get title
- title = entry.media.title.text
- if title.startswith('EEVblog '):
- global eevblog_count
- eevblog_count = eevblog_count + 1
- if eevblog_count < eevblog_start_index: return
- # extract ID from URL
- id = entry.id.text
- id = id.split('/')
- id = id[-1]
- # show
- print 'index: %i, id: %s, title: %s' % (eevblog_count, id, title)
- # file a complaint for this video
- yt_service.AddComplaint(complaint_text, complaint_term, id)
- # wait a minute to avoid "too_many_recent_calls" error message
- time.sleep(60)
- # 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:
- printEntryDetailsAndComplain(entry)
- return count
- # process all videos of a user
- def getAndPrintUserUploads(username):
- index = 1
- while True:
- # build URI, starting at "index"
- uri = 'http://gdata.youtube.com/feeds/api/users/%s/uploads?start-index=%i&max-results=25' % (username, 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 and file complaints'
- getAndPrintUserUploads(complaint_username)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement