Added socket_timeout.
This commit is contained in:
parent
68ff625a47
commit
708e058b01
3 changed files with 13 additions and 2 deletions
|
|
@ -8,6 +8,7 @@ from version import APP_VERSION
|
|||
from dotenv import load_dotenv
|
||||
from yt_dlp.version import __version__ as YTDLP_VERSION
|
||||
|
||||
|
||||
class Config:
|
||||
__instance = None
|
||||
config_path: str = '.'
|
||||
|
|
@ -47,9 +48,11 @@ class Config:
|
|||
|
||||
extract_info_timeout: int = 70
|
||||
|
||||
socket_timeout: int = 30
|
||||
|
||||
ytdlp_version: str = YTDLP_VERSION
|
||||
|
||||
_int_vars: tuple = ('port', 'max_workers',)
|
||||
_int_vars: tuple = ('port', 'max_workers', 'socket_timeout', 'extract_info_timeout',)
|
||||
_immutable: tuple = ('version', '__instance', 'ytdl_options', 'new_version_available', 'ytdlp_version',)
|
||||
_boolean_vars: tuple = ('keep_archive', 'ytdl_debug', 'debug', 'temp_keep', 'allow_manifestless',)
|
||||
|
||||
|
|
@ -153,6 +156,8 @@ class Config:
|
|||
else:
|
||||
LOG.info(f'No custom yt-dlp options found in "{self.config_path}"')
|
||||
|
||||
self.ytdl_options['socket_timeout'] = self.socket_timeout
|
||||
|
||||
if self.keep_archive:
|
||||
LOG.info(f'keep archive: {self.keep_archive}')
|
||||
self.ytdl_options['download_archive'] = os.path.join(
|
||||
|
|
|
|||
|
|
@ -261,6 +261,9 @@ class Download:
|
|||
if 'filename' in status:
|
||||
self.info.filename = os.path.relpath(status.get('filename'), self.download_dir)
|
||||
|
||||
if os.path.exists(status.get('filename')):
|
||||
self.info.file_size = os.path.getsize(status.get('filename'))
|
||||
|
||||
# Set correct file extension for thumbnails
|
||||
if self.info.format == 'thumbnail':
|
||||
self.info.filename = re.sub(r'\.webm$', '.jpg', self.info.filename)
|
||||
|
|
|
|||
|
|
@ -242,11 +242,14 @@ class DownloadQueue:
|
|||
return {'status': 'error', 'msg': 'Unable to extract info check logs.'}
|
||||
|
||||
LOG.debug(f'extract_info: for [{url=}] is done in {time.perf_counter() - started}. Length: {len(entry)}')
|
||||
except yt_dlp.utils.ExistingVideoReached:
|
||||
except yt_dlp.utils.ExistingVideoReached as exc:
|
||||
LOG.error(f'Video has been downloaded already and recorded in archive.log file. {str(exc)}')
|
||||
return {'status': 'error', 'msg': 'Video has been downloaded already and recorded in archive.log file.'}
|
||||
except yt_dlp.utils.YoutubeDLError as exc:
|
||||
LOG.error(f'YoutubeDLError: Unable to extract info. {str(exc)}')
|
||||
return {'status': 'error', 'msg': str(exc)}
|
||||
except asyncio.exceptions.TimeoutError as exc:
|
||||
LOG.error(f'TimeoutError: Unable to extract info. {str(exc)}')
|
||||
return {'status': 'error', 'msg': 'TimeoutError: Unable to extract info.'}
|
||||
|
||||
return await self.__add_entry(
|
||||
|
|
|
|||
Loading…
Reference in a new issue