From ae306df7e0e20866e39cc4f817edb99fe47ddc4d Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 1 Nov 2020 03:01:10 +0100 Subject: [PATCH 1/3] [viki] new way of obtaining subtitles. --- youtube_dlc/extractor/viki.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/youtube_dlc/extractor/viki.py b/youtube_dlc/extractor/viki.py index f8e360338..0f188f84d 100644 --- a/youtube_dlc/extractor/viki.py +++ b/youtube_dlc/extractor/viki.py @@ -308,19 +308,17 @@ class VikiIE(VikiBaseIE): 'url': thumbnail.get('url'), }) - stream_ids = [] - for f in formats: - s_id = f.get('stream_id') - if s_id is not None: - stream_ids.append(s_id) + 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 subtitle_lang, _ in video.get('subtitle_completions', {}).items(): - subtitles[subtitle_lang] = [{ - 'ext': subtitles_format, - 'url': self._prepare_call( - 'videos/%s/subtitles/%s.%s?stream_id=%s' % (video_id, subtitle_lang, subtitles_format, stream_ids[0])), - } for subtitles_format in ('srt', 'vtt')] + for sub in new_video.get('streamSubtitles').get('dash'): + subtitles[sub.get('srclang')] = [{ + 'ext': 'vtt', + 'url': sub.get('src'), + 'completion': sub.get('percentage'), + }] result = { 'id': video_id, From 31108ce946eccbe765b12f0b8a9a47622af68c27 Mon Sep 17 00:00:00 2001 From: Unknown Date: Sun, 1 Nov 2020 03:36:16 +0100 Subject: [PATCH 2/3] [core] sleep-subtitles fix --- youtube_dlc/downloader/common.py | 11 ++++++----- youtube_dlc/options.py | 2 +- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/youtube_dlc/downloader/common.py b/youtube_dlc/downloader/common.py index 460364a0b..c65500d61 100644 --- a/youtube_dlc/downloader/common.py +++ b/youtube_dlc/downloader/common.py @@ -364,11 +364,12 @@ class FileDownloader(object): else '%.2f' % sleep_interval)) time.sleep(sleep_interval) else: - sleep_interval_sub = self.params.get('sleep_interval_subtitles') - self.to_screen( - '[download] Sleeping %s seconds...' % ( - int(sleep_interval_sub))) - time.sleep(sleep_interval_sub) + if self.params.get('sleep_interval_subtitles') > 0: + sleep_interval_sub = self.params.get('sleep_interval_subtitles') + self.to_screen( + '[download] Sleeping %s seconds...' % ( + sleep_interval_sub)) + time.sleep(sleep_interval_sub) return self.real_download(filename, info_dict) def real_download(self, filename, info_dict): diff --git a/youtube_dlc/options.py b/youtube_dlc/options.py index 66b45220c..3c8a1305e 100644 --- a/youtube_dlc/options.py +++ b/youtube_dlc/options.py @@ -582,7 +582,7 @@ def parseOpts(overrideArguments=None): 'along with --min-sleep-interval.')) workarounds.add_option( '--sleep-subtitles', - dest='sleep_interval_subtitles', action='store_true', default=0, + dest='sleep_interval_subtitles', default=0, type=int, help='Enforce sleep interval on subtitles as well') verbosity = optparse.OptionGroup(parser, 'Verbosity / Simulation Options') From 764876a01f2f9c1eb59691678c5629fe283a39ce Mon Sep 17 00:00:00 2001 From: Tom-Oliver Heidel Date: Sun, 1 Nov 2020 03:38:44 +0100 Subject: [PATCH 3/3] [skip travis] select python 3.8 in workflow file --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f5d94dc49..2bf54cd58 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: - name: Set up Python uses: actions/setup-python@v2 with: - python-version: '3.x' + python-version: '3.8' - name: Install packages run: sudo apt-get -y install zip pandoc man - name: Bump version