mirror of
https://github.com/yt-dlp/yt-dlp
synced 2024-12-28 22:24:34 +01:00
fall-back to the old way to fetch subtitles, if needed
This commit is contained in:
parent
651bae3d23
commit
142f2c8e99
1 changed files with 19 additions and 10 deletions
|
@ -308,17 +308,26 @@ class VikiIE(VikiBaseIE):
|
||||||
'url': thumbnail.get('url'),
|
'url': thumbnail.get('url'),
|
||||||
})
|
})
|
||||||
|
|
||||||
new_video = self._download_json(
|
|
||||||
'https://www.viki.com/api/videos/%s' % video_id, video_id,
|
|
||||||
'Downloading new video JSON to get subtitles', headers={'x-viki-app-ver': '2.2.5.1428709186'}, expected_status=[200, 400, 404])
|
|
||||||
|
|
||||||
subtitles = {}
|
subtitles = {}
|
||||||
for sub in new_video.get('streamSubtitles').get('dash'):
|
try:
|
||||||
subtitles[sub.get('srclang')] = [{
|
# New way to fetch subtitles
|
||||||
'ext': 'vtt',
|
new_video = self._download_json(
|
||||||
'url': sub.get('src'),
|
'https://www.viki.com/api/videos/%s' % video_id, video_id,
|
||||||
'completion': sub.get('percentage'),
|
'Downloading new video JSON to get subtitles', headers={'x-viki-app-ver': '2.2.5.1428709186'}, expected_status=[200, 400, 404])
|
||||||
}]
|
for sub in new_video.get('streamSubtitles').get('dash'):
|
||||||
|
subtitles[sub.get('srclang')] = [{
|
||||||
|
'ext': 'vtt',
|
||||||
|
'url': sub.get('src'),
|
||||||
|
'completion': sub.get('percentage'),
|
||||||
|
}]
|
||||||
|
except AttributeError:
|
||||||
|
# fall-back to the old way if there isn't a streamSubtitles attribute
|
||||||
|
for subtitle_lang, _ in video.get('subtitle_completions', {}).items():
|
||||||
|
subtitles[subtitle_lang] = [{
|
||||||
|
'ext': subtitles_format,
|
||||||
|
'url': self._prepare_call(
|
||||||
|
'videos/%s/subtitles/%s.%s' % (video_id, subtitle_lang, subtitles_format)),
|
||||||
|
} for subtitles_format in ('srt', 'vtt')]
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
|
|
Loading…
Reference in a new issue