diff --git a/app/Config.py b/app/Config.py index 0847dc70..7d905d06 100644 --- a/app/Config.py +++ b/app/Config.py @@ -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( diff --git a/app/Download.py b/app/Download.py index cd10785a..1da4a8fd 100644 --- a/app/Download.py +++ b/app/Download.py @@ -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) diff --git a/app/DownloadQueue.py b/app/DownloadQueue.py index 46e6619e..4d89ae29 100644 --- a/app/DownloadQueue.py +++ b/app/DownloadQueue.py @@ -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(