aboutsummaryrefslogtreecommitdiff
path: root/youtube_dlc/extractor/viki.py
diff options
context:
space:
mode:
authorDiego Fernando Rodríguez Varón <diegorodriguezv@gmail.com>2020-11-14 09:40:51 -0500
committerDiego Fernando Rodríguez Varón <diegorodriguezv@gmail.com>2020-11-14 09:40:51 -0500
commita2044d57ca89a463a731febd5e95033c36427ab6 (patch)
tree10a57e386d3bcc6382a813bcbe785eed08fed0eb /youtube_dlc/extractor/viki.py
parentfff50711120b1a1c0477550748768d1e5b1fb755 (diff)
parentd052b9a112fb7ae749a829dceba6e3289663a303 (diff)
Merge branch 'master' of https://github.com/blackjack4494/yt-dlc into fix-tmz
Diffstat (limited to 'youtube_dlc/extractor/viki.py')
-rw-r--r--youtube_dlc/extractor/viki.py29
1 files changed, 19 insertions, 10 deletions
diff --git a/youtube_dlc/extractor/viki.py b/youtube_dlc/extractor/viki.py
index 0f188f84d..6bddf8be9 100644
--- a/youtube_dlc/extractor/viki.py
+++ b/youtube_dlc/extractor/viki.py
@@ -308,17 +308,26 @@ class VikiIE(VikiBaseIE):
'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 = {}
- for sub in new_video.get('streamSubtitles').get('dash'):
- subtitles[sub.get('srclang')] = [{
- 'ext': 'vtt',
- 'url': sub.get('src'),
- 'completion': sub.get('percentage'),
- }]
+ try:
+ # New way to fetch subtitles
+ 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])
+ 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 = {
'id': video_id,