Compare commits
No commits in common. "5d58428cd9c1ef82a0e376ac48cef91fc8be234c" and "f0dbb580b2fc0ea8cd1a50745bf27e8726d6248c" have entirely different histories.
5d58428cd9
...
f0dbb580b2
@ -29,23 +29,8 @@ class YouTubeAPI(object):
|
||||
channel = snippet['channelTitle']
|
||||
channelId = snippet['channelId']
|
||||
description = snippet['description']
|
||||
try:
|
||||
tags = snippet['tags']
|
||||
except:
|
||||
tags = ''
|
||||
tags = snippet['tags']
|
||||
privacy = status['privacyStatus']
|
||||
return title, date, channel, channelId, description, tags, privacy
|
||||
|
||||
def getPlaylist(self, id, pageToken=''):
|
||||
if(pageToken):
|
||||
pageToken = '&pageToken={}'.format(pageToken)
|
||||
return self.getRequest('playlistItems?part=snippet&maxResults=50&playlistId={}{}'.format(id,
|
||||
pageToken))
|
||||
|
||||
def getPlaylistVideos(self, id):
|
||||
playlist = self.getPlaylist(id)
|
||||
items = playlist['items']
|
||||
while 'nextPageToken' in playlist:
|
||||
playlist = self.getPlaylist(id, playlist['nextPageToken'])
|
||||
items.extend(playlist['items'])
|
||||
return items
|
||||
|
||||
|
@ -2,36 +2,16 @@
|
||||
|
||||
from youtube_api import YouTubeAPI
|
||||
import sys
|
||||
import youtube_dl
|
||||
|
||||
# Read YouTube API Key.
|
||||
# Read YouTube API Key
|
||||
def getYouTubeAPIKey():
|
||||
return open('youtube.key', 'r').read()
|
||||
|
||||
def getUploadTime(info):
|
||||
return info[1]
|
||||
|
||||
def getYear(info):
|
||||
return int(getUploadTime(info)[:4])
|
||||
|
||||
def getPrivacy(info):
|
||||
return info[6]
|
||||
|
||||
# Print out information about a video.
|
||||
def printVideoInfo(info):
|
||||
title, date, channel, channelId, description, tags, privacy = info
|
||||
print('Title: ' + title)
|
||||
print('Date: ' + date)
|
||||
print('Channel: {} ({})'.format(channel, channelId) )
|
||||
print('Description: ' + description)
|
||||
print('Tags: ', tags)
|
||||
print('Privacy: ' + privacy)
|
||||
|
||||
api = YouTubeAPI(getYouTubeAPIKey())
|
||||
videos = api.getPlaylistVideos(sys.argv[1])
|
||||
|
||||
videoInfo = [api.getVideoInfo(video['snippet']['resourceId']['videoId']) for video in videos]
|
||||
filteredVideos = [video for video in videoInfo if getPrivacy(video) == 'unlisted' and getYear(video) <= 2017]
|
||||
|
||||
for v in filteredVideos:
|
||||
print(getYear(v))
|
||||
title, date, channel, channelId, description, tags, privacy = api.getVideoInfo(sys.argv[1])
|
||||
print('Title: ' + title)
|
||||
print('Date: ' + date)
|
||||
print('Channel: {} ({})'.format(channel, channelId) )
|
||||
print('Description: ' + description)
|
||||
print('Tags: ', tags)
|
||||
print('Privacy: ' + privacy)
|
||||
|
Loading…
x
Reference in New Issue
Block a user