mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-09-08 21:45:05 +00:00
Added separate _call_api function.
This commit is contained in:
parent
3bdfc242d3
commit
9b8ed4477c
|
@ -1,6 +1,7 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
# from venv import create
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..compat import compat_parse_qs
|
from ..compat import compat_parse_qs
|
||||||
|
@ -14,7 +15,6 @@ from ..utils import (
|
||||||
update_url_query,
|
update_url_query,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class GoogleDriveIE(InfoExtractor):
|
class GoogleDriveIE(InfoExtractor):
|
||||||
_VALID_URL = r'''(?x)
|
_VALID_URL = r'''(?x)
|
||||||
https?://
|
https?://
|
||||||
|
@ -162,6 +162,14 @@ class GoogleDriveIE(InfoExtractor):
|
||||||
return self._get_captions_by_type(
|
return self._get_captions_by_type(
|
||||||
video_id, subtitles_id, 'automatic_captions', origin_lang_code)
|
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
|
# USING URL: https://drive.google.com/file/d/1lVFQrzYKnJDd045Gc9xv1W4YA9zKPX7r/view?usp=sharing
|
||||||
# API KEY: AIzaSyCGrlNJSIw19pjonNQOqMIyS2Xai9g0YT0
|
# API KEY: AIzaSyCGrlNJSIw19pjonNQOqMIyS2Xai9g0YT0
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
@ -171,12 +179,11 @@ class GoogleDriveIE(InfoExtractor):
|
||||||
'https://drive.google.com/get_video_info',
|
'https://drive.google.com/get_video_info',
|
||||||
video_id, query={'docid': video_id}))
|
video_id, query={'docid': video_id}))
|
||||||
# print("_real_extract video_info: ", video_info)
|
# print("_real_extract video_info: ", video_info)
|
||||||
|
json_data = self._call_api(video_id)
|
||||||
# Call Google Drive API
|
createdTime = json_data['createdTime']
|
||||||
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)
|
modifiedTime = json_data['modifiedTime']
|
||||||
print("_real_extract json_data: ", json_data)
|
print("createdTime: ", createdTime)
|
||||||
|
|
||||||
|
|
||||||
def get_value(key):
|
def get_value(key):
|
||||||
return try_get(video_info, lambda x: x[key][0])
|
return try_get(video_info, lambda x: x[key][0])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue