diff options
author | Jesús <heckyel@hyperbola.info> | 2021-12-29 19:12:28 -0500 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2021-12-29 19:12:28 -0500 |
commit | 5aac4e0267e32d98eb68692afedafda3b41ea629 (patch) | |
tree | c3b0f52d6a8cf4ad74e7f17f1ccd7653e1071471 /yt_dlp/downloader/common.py | |
parent | 4f0875462ee497cc13c02d0b852f52f4887b5cea (diff) | |
parent | 96f13f01a609add83555ca86fbf35d11441361d8 (diff) | |
download | hypervideo-pre-5aac4e0267e32d98eb68692afedafda3b41ea629.tar.lz hypervideo-pre-5aac4e0267e32d98eb68692afedafda3b41ea629.tar.xz hypervideo-pre-5aac4e0267e32d98eb68692afedafda3b41ea629.zip |
updated from upstream | 29/12/2021 at 19:12
Diffstat (limited to 'yt_dlp/downloader/common.py')
-rw-r--r-- | yt_dlp/downloader/common.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/yt_dlp/downloader/common.py b/yt_dlp/downloader/common.py index d0c9c223f..37321e34b 100644 --- a/yt_dlp/downloader/common.py +++ b/yt_dlp/downloader/common.py @@ -4,12 +4,14 @@ import os import re import time import random +import errno from ..utils import ( decodeArgument, encodeFilename, error_to_compat_str, format_bytes, + sanitize_open, shell_quote, timeconvert, timetuple_from_msec, @@ -39,6 +41,7 @@ class FileDownloader(object): ratelimit: Download speed limit, in bytes/sec. throttledratelimit: Assume the download is being throttled below this speed (bytes/sec) retries: Number of times to retry for HTTP error 5xx + file_access_retries: Number of times to retry on file access error buffersize: Size of download buffer in bytes. noresizebuffer: Do not automatically resize the download buffer. continuedl: Try to continue downloads if possible. @@ -207,6 +210,21 @@ class FileDownloader(object): def ytdl_filename(self, filename): return filename + '.ytdl' + def sanitize_open(self, filename, open_mode): + file_access_retries = self.params.get('file_access_retries', 10) + retry = 0 + while True: + try: + return sanitize_open(filename, open_mode) + except (IOError, OSError) as err: + retry = retry + 1 + if retry > file_access_retries or err.errno not in (errno.EACCES,): + raise + self.to_screen( + '[download] Got file access error. Retrying (attempt %d of %s) ...' + % (retry, self.format_retries(file_access_retries))) + time.sleep(0.01) + def try_rename(self, old_filename, new_filename): if old_filename == new_filename: return @@ -397,6 +415,7 @@ class FileDownloader(object): 'status': 'finished', 'total_bytes': os.path.getsize(encodeFilename(filename)), }, info_dict) + self._finish_multiline_status() return True, False if subtitle is False: |