[viki] new way of obtaining subtitles.

This commit is contained in:
Unknown 2020-11-01 03:01:10 +01:00
parent 7fb5f2f29d
commit ae306df7e0
1 changed files with 9 additions and 11 deletions

View File

@ -308,19 +308,17 @@ class VikiIE(VikiBaseIE):
'url': thumbnail.get('url'), 'url': thumbnail.get('url'),
}) })
stream_ids = [] new_video = self._download_json(
for f in formats: 'https://www.viki.com/api/videos/%s' % video_id, video_id,
s_id = f.get('stream_id') 'Downloading new video JSON to get subtitles', headers={'x-viki-app-ver': '2.2.5.1428709186'}, expected_status=[200, 400, 404])
if s_id is not None:
stream_ids.append(s_id)
subtitles = {} subtitles = {}
for subtitle_lang, _ in video.get('subtitle_completions', {}).items(): for sub in new_video.get('streamSubtitles').get('dash'):
subtitles[subtitle_lang] = [{ subtitles[sub.get('srclang')] = [{
'ext': subtitles_format, 'ext': 'vtt',
'url': self._prepare_call( 'url': sub.get('src'),
'videos/%s/subtitles/%s.%s?stream_id=%s' % (video_id, subtitle_lang, subtitles_format, stream_ids[0])), 'completion': sub.get('percentage'),
} for subtitles_format in ('srt', 'vtt')] }]
result = { result = {
'id': video_id, 'id': video_id,