diff options
author | Unknown <blackjack4494@web.de> | 2020-09-29 05:11:32 +0200 |
---|---|---|
committer | Unknown <blackjack4494@web.de> | 2020-09-29 05:11:32 +0200 |
commit | 0c9df79e170dc4e465271691d56ea155eff7cfb3 (patch) | |
tree | a9e8bffca8f404696eaf5fdfd32383dd4f2600f6 /youtube_dlc/YoutubeDL.py | |
parent | 88bdacf33cb68d14a96fe807e988cc2114310d0f (diff) | |
download | hypervideo-pre-0c9df79e170dc4e465271691d56ea155eff7cfb3.tar.lz hypervideo-pre-0c9df79e170dc4e465271691d56ea155eff7cfb3.tar.xz hypervideo-pre-0c9df79e170dc4e465271691d56ea155eff7cfb3.zip |
[core] no sleep affected subtitles only with enforced flag
Diffstat (limited to 'youtube_dlc/YoutubeDL.py')
-rw-r--r-- | youtube_dlc/YoutubeDL.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/youtube_dlc/YoutubeDL.py b/youtube_dlc/YoutubeDL.py index c7e3eb01e..0bb5ff1e9 100644 --- a/youtube_dlc/YoutubeDL.py +++ b/youtube_dlc/YoutubeDL.py @@ -1856,12 +1856,14 @@ class YoutubeDL(object): # subtitles download errors are already managed as troubles in relevant IE # that way it will silently go on when used with unsupporting IE subtitles = info_dict['requested_subtitles'] + ie = self.get_info_extractor(info_dict['extractor_key']) for sub_lang, sub_info in subtitles.items(): sub_format = sub_info['ext'] sub_filename = subtitles_filename(filename, sub_lang, sub_format, info_dict.get('ext')) if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(sub_filename)): self.to_screen('[info] Video subtitle %s.%s is already present' % (sub_lang, sub_format)) else: + self.to_screen('[info] Writing video subtitles to: ' + sub_filename) if sub_info.get('data') is not None: try: # Use newline='' to prevent conversion of newline characters @@ -1873,11 +1875,14 @@ class YoutubeDL(object): return else: try: - dl(sub_filename, sub_info) - except (ExtractorError, IOError, OSError, ValueError, - compat_urllib_error.URLError, - compat_http_client.HTTPException, - socket.error) as err: + if self.params.get('sleep_interval_subtitles', False): + dl(sub_filename, sub_info) + else: + sub_data = ie._request_webpage( + sub_info['url'], info_dict['id'], note=False).read() + with io.open(encodeFilename(sub_filename), 'wb') as subfile: + subfile.write(sub_data) + except (ExtractorError, IOError, OSError, ValueError, compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err: self.report_warning('Unable to download subtitle for "%s": %s' % (sub_lang, error_to_compat_str(err))) continue |