Compare commits

...

11 Commits

Author SHA1 Message Date
crystal-hwang
e938d4ef43
Merge a4ae6b4520 into e1b3fa242c 2024-07-28 01:37:17 +09:00
cryhwang
a4ae6b4520 replaced owner for loop 2022-12-11 22:02:22 -05:00
cryhwang
2f76e1c0c5 removed comment 2022-12-11 20:20:07 -05:00
cryhwang
9583355a42 passed flake8 2022-12-11 20:12:10 -05:00
cryhwang
11242ed9ab remove freetv file 2022-12-11 20:03:52 -05:00
cryhwang
56cfd8f604 added return metadata 2022-12-11 14:17:39 -05:00
cryhwang
237e55ef91 modifiedtime and owner metadata 2022-12-11 13:24:00 -05:00
Eric Zhang
9b8ed4477c Added separate _call_api function. 2022-12-11 13:06:44 -05:00
Eric Zhang
3bdfc242d3 Added call to google drive api 2022-12-11 00:27:36 -05:00
zhangeric-15
bc2ebe77f1
Merge branch 'ytdl-org:master' into master 2022-11-15 12:57:13 -05:00
Eric Zhang
a54b9482ee added random.txt 2022-11-15 12:21:15 -05:00
3 changed files with 19 additions and 0 deletions

0
random.txt Normal file
View File

BIN
youtube-dl.sig Normal file

Binary file not shown.

View File

@ -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
@ -12,6 +13,7 @@ from ..utils import (
lowercase_escape,
try_get,
update_url_query,
unified_strdate,
)
@ -28,6 +30,7 @@ class GoogleDriveIE(InfoExtractor):
)
(?P<id>[a-zA-Z0-9_-]{28,})
'''
_API_KEY = "AIzaSyCGrlNJSIw19pjonNQOqMIyS2Xai9g0YT0"
_TESTS = [{
'url': 'https://drive.google.com/file/d/0ByeS4oOUV-49Zzh4R1J6R09zazQ/edit?pli=1',
'md5': '5c602afbbf2c1db91831f5d82f678554',
@ -161,12 +164,25 @@ 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)
return json_data
# 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)
video_info = compat_parse_qs(self._download_webpage(
'https://drive.google.com/get_video_info',
video_id, query={'docid': video_id}))
json_data = self._call_api(video_id)
createdTime = unified_strdate(json_data['createdTime'])
modifiedTime = unified_strdate(json_data['modifiedTime'])
owner_lst = [owner['displayName'] for owner in json_data['owners']]
def get_value(key):
return try_get(video_info, lambda x: x[key][0])
@ -271,6 +287,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(