[PeerTube] Improve safety of dictionary access
This could probably be more elegant.
This commit is contained in:
parent
64186d344a
commit
66f07dcd41
@ -490,11 +490,16 @@ class PeerTubeIE(InfoExtractor):
|
|||||||
'https://%s/api/v1/videos/%s/captions' % (host, video_id), video_id)
|
'https://%s/api/v1/videos/%s/captions' % (host, video_id), video_id)
|
||||||
|
|
||||||
subtitles = {}
|
subtitles = {}
|
||||||
for entry in video_captions['data']:
|
for entry in video_captions.get('data'):
|
||||||
caption_url = 'https://%s%s' % (host, entry['captionPath'])
|
captions_language = entry.get('language')
|
||||||
subtitles[entry['language']['id']] = [{
|
if captions_language is not None:
|
||||||
'url': caption_url
|
language_id = captions_language.get('id')
|
||||||
}]
|
caption_path = entry.get('captionPath')
|
||||||
|
if language_id is not None and caption_path is not None:
|
||||||
|
caption_url = 'https://%s%s' % (host, caption_path)
|
||||||
|
subtitles[language_id] = [{
|
||||||
|
'url': caption_url
|
||||||
|
}]
|
||||||
return subtitles
|
return subtitles
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user