From efa753bbf0fecc4efaadbb348e8669ea6b7f3350 Mon Sep 17 00:00:00 2001 From: Jonne Kaunisto Date: Mon, 7 Oct 2019 14:54:12 +0200 Subject: [PATCH] added scopes and constatns --- simple_youtube_api/YouTubeVideo.py | 3 +- simple_youtube_api/youtube_api.py | 50 +-------------------- simple_youtube_api/youtube_constants.py | 59 +++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 50 deletions(-) create mode 100644 simple_youtube_api/youtube_constants.py diff --git a/simple_youtube_api/YouTubeVideo.py b/simple_youtube_api/YouTubeVideo.py index d1ce859..60e4696 100644 --- a/simple_youtube_api/YouTubeVideo.py +++ b/simple_youtube_api/YouTubeVideo.py @@ -181,7 +181,8 @@ def fetch_comment_threads(self, snippet=True, replies=True)\ return comment_threads - def download(self, output_path=None, filename=None, filename_prefix=None): + # TODO: debug issue with default filename + def download(self, output_path=None, filename="default_name", filename_prefix=None): '''Downloads video ''' video_url = 'https://youtube.com/watch?v=' + self.id diff --git a/simple_youtube_api/youtube_api.py b/simple_youtube_api/youtube_api.py index 90da431..d844127 100644 --- a/simple_youtube_api/youtube_api.py +++ b/simple_youtube_api/youtube_api.py @@ -7,6 +7,7 @@ import os from simple_youtube_api.Comment import Comment +from simple_youtube_api.youtube_constants import * from googleapiclient.discovery import build from googleapiclient.errors import HttpError @@ -16,55 +17,6 @@ from oauth2client.tools import run_flow from oauth2client.file import Storage -DATA_PATH = os.path.dirname(os.path.abspath(__file__))+os.sep + 'data' + os.sep -MAX_YOUTUBE_TITLE_LENGTH = 100 -MAX_YOUTUBE_DESCRIPTION_LENGTH = 5000 -MAX_YOUTUBE_TAGS_LENGTH = 500 -YOUTUBE_CATEGORIES = {'film': 1, 'animation': 1, - 'autos': 2, 'vehicles': 2, - 'music': 10, - 'pets': 15, 'animals': 15, - 'sports': 17, - 'short movies': 18, - 'travel': 19, 'events': 19, - 'gaming': 20, - 'videoblogging': 21, - 'people': 22, 'blogs': 22, - 'comedy': 23, - 'entertainment': 24, - 'news': 25, 'politics': 25, - 'howto': 26, 'style': 26, - 'education': 27, - 'science': 28, 'technology': 28, - 'nonprofits': 29, 'activism': 29, - 'movies': 30, - 'anime': 31, 'animation': 31, - 'action': 32, 'adventure': 32, - 'classics': 33, - 'comedy': 34, - 'documentary': 35, - 'drama': 36, - 'family': 37, - 'foreign': 38, - 'horror': 39, - 'sci-fi': 40, 'fantasy': 40, - 'thriller': 41, - 'shorts': 42, - 'shows': 43, - 'trailers': 44} - -YOUTUBE_LICENCES = ['creativeCommon', 'youtube'] - -SCOPES = ['https://www.googleapis.com/auth/youtube', - 'https://www.googleapis.com/auth/youtube.force-ssl', - 'https://www.googleapis.com/auth/youtube.readonly', - 'https://www.googleapis.com/auth/youtube.upload', - 'https://www.googleapis.com/auth/youtubepartner', - 'https://www.googleapis.com/auth/youtubepartner-channel-audit'] -API_SERVICE_NAME = 'youtube' -API_VERSION = 'v3' -VALID_PRIVACY_STATUS = ('public', 'private', 'unlisted') - # autogenerate code, do not edit def parse_youtube_video(video, data): diff --git a/simple_youtube_api/youtube_constants.py b/simple_youtube_api/youtube_constants.py new file mode 100644 index 0000000..b6520e8 --- /dev/null +++ b/simple_youtube_api/youtube_constants.py @@ -0,0 +1,59 @@ +import os + +DATA_PATH = os.path.dirname(os.path.abspath(__file__))+os.sep + 'data' + os.sep +MAX_YOUTUBE_TITLE_LENGTH = 100 +MAX_YOUTUBE_DESCRIPTION_LENGTH = 5000 +MAX_YOUTUBE_TAGS_LENGTH = 500 +YOUTUBE_CATEGORIES = {'film': 1, 'animation': 1, + 'autos': 2, 'vehicles': 2, + 'music': 10, + 'pets': 15, 'animals': 15, + 'sports': 17, + 'short movies': 18, + 'travel': 19, 'events': 19, + 'gaming': 20, + 'videoblogging': 21, + 'people': 22, 'blogs': 22, + 'comedy': 23, + 'entertainment': 24, + 'news': 25, 'politics': 25, + 'howto': 26, 'style': 26, + 'education': 27, + 'science': 28, 'technology': 28, + 'nonprofits': 29, 'activism': 29, + 'movies': 30, + 'anime': 31, 'animation': 31, + 'action': 32, 'adventure': 32, + 'classics': 33, + 'comedy': 34, + 'documentary': 35, + 'drama': 36, + 'family': 37, + 'foreign': 38, + 'horror': 39, + 'sci-fi': 40, 'fantasy': 40, + 'thriller': 41, + 'shorts': 42, + 'shows': 43, + 'trailers': 44} + +YOUTUBE_LICENCES = ['creativeCommon', 'youtube'] + +SCOPE_YOUTUBE = 'youtube' +SCOPES = ['https://www.googleapis.com/auth/youtube', + 'https://www.googleapis.com/auth/youtube.force-ssl', + 'https://www.googleapis.com/auth/youtube.readonly', + 'https://www.googleapis.com/auth/youtube.upload', + 'https://www.googleapis.com/auth/youtubepartner', + 'https://www.googleapis.com/auth/youtubepartner-channel-audit'] +API_SERVICE_NAME = 'youtube' +API_VERSION = 'v3' +VALID_PRIVACY_STATUS = ('public', 'private', 'unlisted') + + +SCOPES = ['https://www.googleapis.com/auth/youtube', + 'https://www.googleapis.com/auth/youtube.force-ssl', + 'https://www.googleapis.com/auth/youtube.readonly', + 'https://www.googleapis.com/auth/youtube.upload', + 'https://www.googleapis.com/auth/youtubepartner', + 'https://www.googleapis.com/auth/youtubepartner-channel-audit']