[PeerTube] Only download subtitles if requested
This commit is contained in:
parent
3e6e70932a
commit
2c2c219911
@ -485,6 +485,18 @@ class PeerTubeIE(InfoExtractor):
|
|||||||
entries = [peertube_url]
|
entries = [peertube_url]
|
||||||
return entries
|
return entries
|
||||||
|
|
||||||
|
def _get_subtitles(self, host, video_id):
|
||||||
|
video_captions = self._download_json(
|
||||||
|
'https://%s/api/v1/videos/%s/captions' % (host, video_id), video_id)
|
||||||
|
|
||||||
|
subtitles = {}
|
||||||
|
for entry in video_captions['data']:
|
||||||
|
caption_url = 'https://%s%s' % (host, entry['captionPath'])
|
||||||
|
subtitles[entry['language']['id']] = [{
|
||||||
|
'url': caption_url
|
||||||
|
}]
|
||||||
|
return subtitles
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
mobj = re.match(self._VALID_URL, url)
|
mobj = re.match(self._VALID_URL, url)
|
||||||
host = mobj.group('host') or mobj.group('host_2')
|
host = mobj.group('host') or mobj.group('host_2')
|
||||||
@ -496,9 +508,6 @@ class PeerTubeIE(InfoExtractor):
|
|||||||
video_description = self._download_json(
|
video_description = self._download_json(
|
||||||
'https://%s/api/v1/videos/%s/description' % (host, video_id), video_id, fatal=False)
|
'https://%s/api/v1/videos/%s/description' % (host, video_id), video_id, fatal=False)
|
||||||
|
|
||||||
video_captions = self._download_json(
|
|
||||||
'https://%s/api/v1/videos/%s/captions' % (host, video_id), video_id)
|
|
||||||
|
|
||||||
title = video['name']
|
title = video['name']
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
@ -520,12 +529,7 @@ class PeerTubeIE(InfoExtractor):
|
|||||||
formats.append(f)
|
formats.append(f)
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
subtitles = {}
|
subtitles = self.extract_subtitles(host, video_id)
|
||||||
for entry in video_captions['data']:
|
|
||||||
caption_url = 'https://%s%s' % (host, entry['captionPath'])
|
|
||||||
subtitles[entry['language']['id']] = [{
|
|
||||||
'url': caption_url
|
|
||||||
}]
|
|
||||||
|
|
||||||
def account_data(field):
|
def account_data(field):
|
||||||
return try_get(video, lambda x: x['account'][field], compat_str)
|
return try_get(video, lambda x: x['account'][field], compat_str)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user