Filter videos to unlisted videos from 2017 and before
This commit is contained in:
parent
1f5eaa231a
commit
5d58428cd9
@ -29,7 +29,10 @@ class YouTubeAPI(object):
|
|||||||
channel = snippet['channelTitle']
|
channel = snippet['channelTitle']
|
||||||
channelId = snippet['channelId']
|
channelId = snippet['channelId']
|
||||||
description = snippet['description']
|
description = snippet['description']
|
||||||
|
try:
|
||||||
tags = snippet['tags']
|
tags = snippet['tags']
|
||||||
|
except:
|
||||||
|
tags = ''
|
||||||
privacy = status['privacyStatus']
|
privacy = status['privacyStatus']
|
||||||
return title, date, channel, channelId, description, tags, privacy
|
return title, date, channel, channelId, description, tags, privacy
|
||||||
|
|
||||||
|
@ -2,11 +2,21 @@
|
|||||||
|
|
||||||
from youtube_api import YouTubeAPI
|
from youtube_api import YouTubeAPI
|
||||||
import sys
|
import sys
|
||||||
|
import youtube_dl
|
||||||
|
|
||||||
# Read YouTube API Key.
|
# Read YouTube API Key.
|
||||||
def getYouTubeAPIKey():
|
def getYouTubeAPIKey():
|
||||||
return open('youtube.key', 'r').read()
|
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.
|
# Print out information about a video.
|
||||||
def printVideoInfo(info):
|
def printVideoInfo(info):
|
||||||
title, date, channel, channelId, description, tags, privacy = info
|
title, date, channel, channelId, description, tags, privacy = info
|
||||||
@ -18,4 +28,10 @@ def printVideoInfo(info):
|
|||||||
print('Privacy: ' + privacy)
|
print('Privacy: ' + privacy)
|
||||||
|
|
||||||
api = YouTubeAPI(getYouTubeAPIKey())
|
api = YouTubeAPI(getYouTubeAPIKey())
|
||||||
print(len(api.getPlaylistVideos(sys.argv[1])))
|
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))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user