added timeout limit to extract_info
This commit is contained in:
parent
abe5971f8c
commit
9ff44f3234
2 changed files with 10 additions and 2 deletions
|
|
@ -45,6 +45,8 @@ class Config:
|
||||||
|
|
||||||
new_version_available: bool = False
|
new_version_available: bool = False
|
||||||
|
|
||||||
|
extract_info_timeout: int = 70
|
||||||
|
|
||||||
_int_vars: tuple = ('port', 'max_workers',)
|
_int_vars: tuple = ('port', 'max_workers',)
|
||||||
_immutable: tuple = ('version', '__instance', 'ytdl_options', 'new_version_available')
|
_immutable: tuple = ('version', '__instance', 'ytdl_options', 'new_version_available')
|
||||||
_boolean_vars: tuple = ('keep_archive', 'ytdl_debug', 'debug', 'temp_keep', 'allow_manifestless',)
|
_boolean_vars: tuple = ('keep_archive', 'ytdl_debug', 'debug', 'temp_keep', 'allow_manifestless',)
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ class DownloadQueue:
|
||||||
already.add(url)
|
already.add(url)
|
||||||
try:
|
try:
|
||||||
LOG.debug(f'extracting info from {url=}')
|
LOG.debug(f'extracting info from {url=}')
|
||||||
entry = await asyncio.get_running_loop().run_in_executor(
|
data = asyncio.get_running_loop().run_in_executor(
|
||||||
None,
|
None,
|
||||||
ExtractInfo,
|
ExtractInfo,
|
||||||
mergeConfig(self.config.ytdl_options, ytdlp_config),
|
mergeConfig(self.config.ytdl_options, ytdlp_config),
|
||||||
|
|
@ -226,6 +226,8 @@ class DownloadQueue:
|
||||||
bool(self.config.ytdl_debug)
|
bool(self.config.ytdl_debug)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
entry = await asyncio.wait_for(data, timeout=self.config.extract_info_timeout)
|
||||||
|
|
||||||
if not entry:
|
if not entry:
|
||||||
if not self.config.keep_archive:
|
if not self.config.keep_archive:
|
||||||
return {
|
return {
|
||||||
|
|
@ -234,7 +236,7 @@ class DownloadQueue:
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug(f'No metadata, Rechecking with archive disabled. {url=}')
|
LOG.debug(f'No metadata, Rechecking with archive disabled. {url=}')
|
||||||
entry = await asyncio.get_running_loop().run_in_executor(
|
data = await asyncio.get_running_loop().run_in_executor(
|
||||||
None,
|
None,
|
||||||
ExtractInfo,
|
ExtractInfo,
|
||||||
mergeConfig(self.config.ytdl_options, ytdlp_config),
|
mergeConfig(self.config.ytdl_options, ytdlp_config),
|
||||||
|
|
@ -243,6 +245,8 @@ class DownloadQueue:
|
||||||
True
|
True
|
||||||
)
|
)
|
||||||
|
|
||||||
|
entry = await asyncio.wait_for(data, timeout=self.config.extract_info_timeout)
|
||||||
|
|
||||||
if not entry:
|
if not entry:
|
||||||
return {'status': 'error', 'msg': 'Unable to extract info check logs.'}
|
return {'status': 'error', 'msg': 'Unable to extract info check logs.'}
|
||||||
|
|
||||||
|
|
@ -261,6 +265,8 @@ class DownloadQueue:
|
||||||
return {'status': 'error', 'msg': 'Video has been downloaded already and recorded in archive.log file.'}
|
return {'status': 'error', 'msg': 'Video has been downloaded already and recorded in archive.log file.'}
|
||||||
except yt_dlp.utils.YoutubeDLError as exc:
|
except yt_dlp.utils.YoutubeDLError as exc:
|
||||||
return {'status': 'error', 'msg': str(exc)}
|
return {'status': 'error', 'msg': str(exc)}
|
||||||
|
except asyncio.exceptions.TimeoutError as exc:
|
||||||
|
return {'status': 'error', 'msg': 'TimeoutError: Unable to extract info.'}
|
||||||
|
|
||||||
return await self.__add_entry(
|
return await self.__add_entry(
|
||||||
entry=entry,
|
entry=entry,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue