1
0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-12-22 07:56:49 +00:00
This commit is contained in:
crystal-hwang 2024-08-21 22:32:49 -04:00 committed by GitHub
commit 37218111de
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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(