From a54b9482ee457c8c84104428dde353be5bebd662 Mon Sep 17 00:00:00 2001 From: Eric Zhang Date: Tue, 15 Nov 2022 12:21:15 -0500 Subject: [PATCH 1/9] added random.txt --- random.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 random.txt diff --git a/random.txt b/random.txt new file mode 100644 index 000000000..e69de29bb From 3bdfc242d353c6cdd4dc8bb2bbfaf0d04e6f29f6 Mon Sep 17 00:00:00 2001 From: Eric Zhang Date: Sun, 11 Dec 2022 00:27:36 -0500 Subject: [PATCH 2/9] Added call to google drive api --- youtube_dl/extractor/googledrive.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/youtube_dl/extractor/googledrive.py b/youtube_dl/extractor/googledrive.py index 3f2de00f1..e3c67929b 100644 --- a/youtube_dl/extractor/googledrive.py +++ b/youtube_dl/extractor/googledrive.py @@ -28,6 +28,7 @@ class GoogleDriveIE(InfoExtractor): ) (?P[a-zA-Z0-9_-]{28,}) ''' + _API_KEY = "AIzaSyCGrlNJSIw19pjonNQOqMIyS2Xai9g0YT0" _TESTS = [{ 'url': 'https://drive.google.com/file/d/0ByeS4oOUV-49Zzh4R1J6R09zazQ/edit?pli=1', 'md5': '5c602afbbf2c1db91831f5d82f678554', @@ -161,11 +162,20 @@ class GoogleDriveIE(InfoExtractor): return self._get_captions_by_type( video_id, subtitles_id, 'automatic_captions', origin_lang_code) + # USING URL: https://drive.google.com/file/d/1lVFQrzYKnJDd045Gc9xv1W4YA9zKPX7r/view?usp=sharing + # API KEY: AIzaSyCGrlNJSIw19pjonNQOqMIyS2Xai9g0YT0 def _real_extract(self, url): video_id = self._match_id(url) + print("_real_extract video_id: ", video_id) video_info = compat_parse_qs(self._download_webpage( 'https://drive.google.com/get_video_info', video_id, query={'docid': video_id})) + # print("_real_extract video_info: ", video_info) + + # Call Google Drive API + json_data = self._download_json('https://www.googleapis.com/drive/v3/files/%s?fields=createdTime,modifiedTime,owners&key=%s' % (video_id, self._API_KEY), video_id) + print("_real_extract json_data: ", json_data) + def get_value(key): return try_get(video_info, lambda x: x[key][0]) From 9b8ed4477c1aeb6dd89ddd12c4d5b5348f9589a1 Mon Sep 17 00:00:00 2001 From: Eric Zhang Date: Sun, 11 Dec 2022 13:06:44 -0500 Subject: [PATCH 3/9] Added separate _call_api function. --- youtube_dl/extractor/googledrive.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/youtube_dl/extractor/googledrive.py b/youtube_dl/extractor/googledrive.py index e3c67929b..d706fa968 100644 --- a/youtube_dl/extractor/googledrive.py +++ b/youtube_dl/extractor/googledrive.py @@ -1,6 +1,7 @@ from __future__ import unicode_literals import re +# from venv import create from .common import InfoExtractor from ..compat import compat_parse_qs @@ -14,7 +15,6 @@ from ..utils import ( update_url_query, ) - class GoogleDriveIE(InfoExtractor): _VALID_URL = r'''(?x) https?:// @@ -162,6 +162,14 @@ class GoogleDriveIE(InfoExtractor): return self._get_captions_by_type( video_id, subtitles_id, 'automatic_captions', origin_lang_code) + + def _call_api(self, video_id): + # Call Google Drive API + json_data = self._download_json('https://www.googleapis.com/drive/v3/files/%s?fields=createdTime,modifiedTime,owners&key=%s' % (video_id, self._API_KEY), video_id) + print("_real_extract json_data: ", json_data) + return json_data + + # USING URL: https://drive.google.com/file/d/1lVFQrzYKnJDd045Gc9xv1W4YA9zKPX7r/view?usp=sharing # API KEY: AIzaSyCGrlNJSIw19pjonNQOqMIyS2Xai9g0YT0 def _real_extract(self, url): @@ -171,12 +179,11 @@ class GoogleDriveIE(InfoExtractor): 'https://drive.google.com/get_video_info', video_id, query={'docid': video_id})) # print("_real_extract video_info: ", video_info) - - # Call Google Drive API - json_data = self._download_json('https://www.googleapis.com/drive/v3/files/%s?fields=createdTime,modifiedTime,owners&key=%s' % (video_id, self._API_KEY), video_id) - print("_real_extract json_data: ", json_data) - - + json_data = self._call_api(video_id) + createdTime = json_data['createdTime'] + modifiedTime = json_data['modifiedTime'] + print("createdTime: ", createdTime) + def get_value(key): return try_get(video_info, lambda x: x[key][0]) From 237e55ef91d19d377da81d6fb82cbc9528f539ad Mon Sep 17 00:00:00 2001 From: cryhwang Date: Sun, 11 Dec 2022 13:24:00 -0500 Subject: [PATCH 4/9] modifiedtime and owner metadata --- youtube-dl.sig | Bin 0 -> 566 bytes youtube_dl/extractor/freetv.py | 38 ++++++++++++++++++++++++++++ youtube_dl/extractor/googledrive.py | 11 +++++--- 3 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 youtube-dl.sig create mode 100644 youtube_dl/extractor/freetv.py diff --git a/youtube-dl.sig b/youtube-dl.sig new file mode 100644 index 0000000000000000000000000000000000000000..d866f04dd97fd7f30128186b221c6f08999f8645 GIT binary patch literal 566 zcmV-60?GY}0y6{v0SEvc79j-fe_QlxJHFT)hc=EZIX({WFBufx*dt6oKk8SR9?9PYAQBG73H+vyL+@T04 zLf53Sq-F+!@H9&Uq5EQ-(Dbm6-Uvqse^zs+sD=%S0u`4HAWX4%zAxJU!rp%XO#fcO zb>i1$-DIG&#X_a^k0ocvyJ;VGMU{EUgQ{KcM`-g02(?75O4;QUTkZD3(m95p3-4Dz zcI&;z{~r@<_7G#dgXNQFVYm*^DlN!h5kb`O0Ajp2d$fh#SF=f-@*8b@zgEnCg8qWT z(?~8~6^a736sir`IT`9-`S>QZeC?J!7S$yhImHIPWQ6KU=w0l;B`-STbhvB;QPY?)G&D^Wne|Jmr! z8nJxpe^d)n66Y)-fc7ZS>#t>awVnk_G7R-Ip$^3B)NHgaRqMZPi*I;NwK<{+8BpH4 z2Ih;jYT033>8!rzv7cdMtLuLtd%;97EWgjRNo(uGyO(m0-vfVnuO#b^uhVWNJF`Tb zrhaTgN&6rwS;4s6-h>4WVQMwp?^k|9XfdjKoldmxjROl^`b47ImVX$|$jczQsR%(> Ev~i>n3IG5A literal 0 HcmV?d00001 diff --git a/youtube_dl/extractor/freetv.py b/youtube_dl/extractor/freetv.py new file mode 100644 index 000000000..d305f2d09 --- /dev/null +++ b/youtube_dl/extractor/freetv.py @@ -0,0 +1,38 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class FreeTVIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?yourextractor\.com/watch/(?P[0-9]+)' + _TEST = { + 'url': 'https://yourextractor.com/watch/42', + 'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)', + 'info_dict': { + 'id': '42', + 'ext': 'mp4', + 'title': 'Video title goes here', + 'thumbnail': r're:^https?://.*\.jpg$', + # TODO more properties, either as: + # * A value + # * MD5 checksum; start the string with md5: + # * A regular expression; start the string with re: + # * Any Python type (for example int or float) + } + } + + def _real_extract(self, url): + display_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + # TODO more code goes here, for example ... + title = self._html_search_regex(r'

(.+?)

', webpage, 'title') + + return { + 'id': video_id, + 'title': title, + 'description': self._og_search_description(webpage), + 'uploader': self._search_regex(r']+id="uploader"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False), + # TODO more properties (see youtube_dl/extractor/common.py) + } \ No newline at end of file diff --git a/youtube_dl/extractor/googledrive.py b/youtube_dl/extractor/googledrive.py index d706fa968..48d9c8b4b 100644 --- a/youtube_dl/extractor/googledrive.py +++ b/youtube_dl/extractor/googledrive.py @@ -13,6 +13,7 @@ from ..utils import ( lowercase_escape, try_get, update_url_query, + unified_strdate, ) class GoogleDriveIE(InfoExtractor): @@ -164,7 +165,7 @@ class GoogleDriveIE(InfoExtractor): def _call_api(self, video_id): - # Call Google Drive API + # Call Google Drive API json_data = self._download_json('https://www.googleapis.com/drive/v3/files/%s?fields=createdTime,modifiedTime,owners&key=%s' % (video_id, self._API_KEY), video_id) print("_real_extract json_data: ", json_data) return json_data @@ -178,11 +179,15 @@ class GoogleDriveIE(InfoExtractor): video_info = compat_parse_qs(self._download_webpage( 'https://drive.google.com/get_video_info', video_id, query={'docid': video_id})) - # print("_real_extract video_info: ", video_info) + json_data = self._call_api(video_id) createdTime = json_data['createdTime'] modifiedTime = json_data['modifiedTime'] - print("createdTime: ", createdTime) + + owner_lst = [] + for owner in json_data['owners']: + owner_lst.append(owner['displayName']) + def get_value(key): return try_get(video_info, lambda x: x[key][0]) From 56cfd8f604d4c398d5e52b0bea007c821abac2df Mon Sep 17 00:00:00 2001 From: cryhwang Date: Sun, 11 Dec 2022 14:17:39 -0500 Subject: [PATCH 5/9] added return metadata --- youtube_dl/extractor/googledrive.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/youtube_dl/extractor/googledrive.py b/youtube_dl/extractor/googledrive.py index 48d9c8b4b..1bb91cadd 100644 --- a/youtube_dl/extractor/googledrive.py +++ b/youtube_dl/extractor/googledrive.py @@ -293,6 +293,9 @@ class GoogleDriveIE(InfoExtractor): 'title': title, 'thumbnail': 'https://drive.google.com/thumbnail?id=' + video_id, 'duration': int_or_none(get_value('length_seconds')), + 'created_date': createdTime, + 'modified_date': modifiedTime, + 'owners': owner_lst, 'formats': formats, 'subtitles': self.extract_subtitles(video_id, subtitles_id, hl), 'automatic_captions': self.extract_automatic_captions( From 11242ed9ab41507c3aae34ad2252a3e1d05f5e0b Mon Sep 17 00:00:00 2001 From: cryhwang Date: Sun, 11 Dec 2022 20:03:52 -0500 Subject: [PATCH 6/9] remove freetv file --- youtube_dl/extractor/freetv.py | 38 ----------------------------- youtube_dl/extractor/googledrive.py | 4 +-- 2 files changed, 2 insertions(+), 40 deletions(-) delete mode 100644 youtube_dl/extractor/freetv.py diff --git a/youtube_dl/extractor/freetv.py b/youtube_dl/extractor/freetv.py deleted file mode 100644 index d305f2d09..000000000 --- a/youtube_dl/extractor/freetv.py +++ /dev/null @@ -1,38 +0,0 @@ -# coding: utf-8 -from __future__ import unicode_literals - -from .common import InfoExtractor - - -class FreeTVIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?yourextractor\.com/watch/(?P[0-9]+)' - _TEST = { - 'url': 'https://yourextractor.com/watch/42', - 'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)', - 'info_dict': { - 'id': '42', - 'ext': 'mp4', - 'title': 'Video title goes here', - 'thumbnail': r're:^https?://.*\.jpg$', - # TODO more properties, either as: - # * A value - # * MD5 checksum; start the string with md5: - # * A regular expression; start the string with re: - # * Any Python type (for example int or float) - } - } - - def _real_extract(self, url): - display_id = self._match_id(url) - webpage = self._download_webpage(url, video_id) - - # TODO more code goes here, for example ... - title = self._html_search_regex(r'

(.+?)

', webpage, 'title') - - return { - 'id': video_id, - 'title': title, - 'description': self._og_search_description(webpage), - 'uploader': self._search_regex(r']+id="uploader"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False), - # TODO more properties (see youtube_dl/extractor/common.py) - } \ No newline at end of file diff --git a/youtube_dl/extractor/googledrive.py b/youtube_dl/extractor/googledrive.py index 1bb91cadd..8ec5ac45c 100644 --- a/youtube_dl/extractor/googledrive.py +++ b/youtube_dl/extractor/googledrive.py @@ -181,8 +181,8 @@ class GoogleDriveIE(InfoExtractor): video_id, query={'docid': video_id})) json_data = self._call_api(video_id) - createdTime = json_data['createdTime'] - modifiedTime = json_data['modifiedTime'] + createdTime = unified_strdate(json_data['createdTime']) + modifiedTime = unified_strdate(json_data['modifiedTime']) owner_lst = [] for owner in json_data['owners']: From 9583355a4212ac3ef60873de7c337cab98647aa1 Mon Sep 17 00:00:00 2001 From: cryhwang Date: Sun, 11 Dec 2022 20:12:10 -0500 Subject: [PATCH 7/9] passed flake8 --- youtube_dl/extractor/googledrive.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/youtube_dl/extractor/googledrive.py b/youtube_dl/extractor/googledrive.py index 8ec5ac45c..c92902bdc 100644 --- a/youtube_dl/extractor/googledrive.py +++ b/youtube_dl/extractor/googledrive.py @@ -16,6 +16,7 @@ from ..utils import ( unified_strdate, ) + class GoogleDriveIE(InfoExtractor): _VALID_URL = r'''(?x) https?:// @@ -163,14 +164,12 @@ class GoogleDriveIE(InfoExtractor): return self._get_captions_by_type( video_id, subtitles_id, 'automatic_captions', origin_lang_code) - def _call_api(self, video_id): # Call Google Drive API json_data = self._download_json('https://www.googleapis.com/drive/v3/files/%s?fields=createdTime,modifiedTime,owners&key=%s' % (video_id, self._API_KEY), video_id) print("_real_extract json_data: ", json_data) return json_data - # USING URL: https://drive.google.com/file/d/1lVFQrzYKnJDd045Gc9xv1W4YA9zKPX7r/view?usp=sharing # API KEY: AIzaSyCGrlNJSIw19pjonNQOqMIyS2Xai9g0YT0 def _real_extract(self, url): @@ -187,8 +186,7 @@ class GoogleDriveIE(InfoExtractor): owner_lst = [] for owner in json_data['owners']: owner_lst.append(owner['displayName']) - - + def get_value(key): return try_get(video_info, lambda x: x[key][0]) From 2f76e1c0c567e0401af808245f6aabf0a74c87fb Mon Sep 17 00:00:00 2001 From: cryhwang Date: Sun, 11 Dec 2022 20:20:07 -0500 Subject: [PATCH 8/9] removed comment --- youtube_dl/extractor/googledrive.py | 1 - 1 file changed, 1 deletion(-) diff --git a/youtube_dl/extractor/googledrive.py b/youtube_dl/extractor/googledrive.py index c92902bdc..71fc8f677 100644 --- a/youtube_dl/extractor/googledrive.py +++ b/youtube_dl/extractor/googledrive.py @@ -167,7 +167,6 @@ class GoogleDriveIE(InfoExtractor): def _call_api(self, video_id): # Call Google Drive API json_data = self._download_json('https://www.googleapis.com/drive/v3/files/%s?fields=createdTime,modifiedTime,owners&key=%s' % (video_id, self._API_KEY), video_id) - print("_real_extract json_data: ", json_data) return json_data # USING URL: https://drive.google.com/file/d/1lVFQrzYKnJDd045Gc9xv1W4YA9zKPX7r/view?usp=sharing From a4ae6b45202a92ff5e60e5bbd77d1712f251fa0f Mon Sep 17 00:00:00 2001 From: cryhwang Date: Sun, 11 Dec 2022 22:02:22 -0500 Subject: [PATCH 9/9] replaced owner for loop --- youtube_dl/extractor/googledrive.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/youtube_dl/extractor/googledrive.py b/youtube_dl/extractor/googledrive.py index 71fc8f677..028fb985c 100644 --- a/youtube_dl/extractor/googledrive.py +++ b/youtube_dl/extractor/googledrive.py @@ -173,7 +173,6 @@ class GoogleDriveIE(InfoExtractor): # API KEY: AIzaSyCGrlNJSIw19pjonNQOqMIyS2Xai9g0YT0 def _real_extract(self, url): video_id = self._match_id(url) - print("_real_extract video_id: ", video_id) video_info = compat_parse_qs(self._download_webpage( 'https://drive.google.com/get_video_info', video_id, query={'docid': video_id})) @@ -182,9 +181,7 @@ class GoogleDriveIE(InfoExtractor): createdTime = unified_strdate(json_data['createdTime']) modifiedTime = unified_strdate(json_data['modifiedTime']) - owner_lst = [] - for owner in json_data['owners']: - owner_lst.append(owner['displayName']) + owner_lst = [owner['displayName'] for owner in json_data['owners']] def get_value(key): return try_get(video_info, lambda x: x[key][0])