Cleanup code.
This commit is contained in:
parent
8042f5ac45
commit
d24a241579
2 changed files with 14 additions and 15 deletions
|
|
@ -11,7 +11,8 @@ from ItemDTO import ItemDTO
|
|||
from DataStore import DataStore
|
||||
from Utils import Notifier, ObjectSerializer, calcDownloadPath, ExtractInfo, isDownloaded, mergeConfig
|
||||
from AsyncPool import AsyncPool
|
||||
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
|
||||
LOG = logging.getLogger('DownloadQueue')
|
||||
TYPE_DONE: str = 'done'
|
||||
TYPE_QUEUE: str = 'queue'
|
||||
|
|
@ -228,15 +229,16 @@ class DownloadQueue:
|
|||
started = time.perf_counter()
|
||||
LOG.debug(f'extract_info: checking {url=}')
|
||||
|
||||
entry = await asyncio.wait_for(
|
||||
fut=asyncio.get_running_loop().run_in_executor(
|
||||
None,
|
||||
ExtractInfo,
|
||||
mergeConfig(self.config.ytdl_options, ytdlp_config),
|
||||
url,
|
||||
bool(self.config.ytdl_debug)
|
||||
),
|
||||
timeout=self.config.extract_info_timeout)
|
||||
with ThreadPoolExecutor as executor:
|
||||
entry = await asyncio.wait_for(
|
||||
fut=asyncio.get_running_loop().run_in_executor(
|
||||
executor,
|
||||
ExtractInfo,
|
||||
mergeConfig(self.config.ytdl_options, ytdlp_config),
|
||||
url,
|
||||
bool(self.config.ytdl_debug)
|
||||
),
|
||||
timeout=self.config.extract_info_timeout)
|
||||
|
||||
if not entry:
|
||||
return {'status': 'error', 'msg': 'Unable to extract info check logs.'}
|
||||
|
|
@ -250,7 +252,7 @@ class DownloadQueue:
|
|||
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 {'status': 'error', 'msg': f'TimeoutError: {self.config.extract_info_timeout}s reached Unable to extract info.'}
|
||||
|
||||
return await self.__add_entry(
|
||||
entry=entry,
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ def calcDownloadPath(basePath: str, folder: str = None, createPath: bool = True)
|
|||
return download_path
|
||||
|
||||
|
||||
def ExtractInfo(config: dict, url: str, debug: bool = False, forceLookup: bool = False) -> dict:
|
||||
def ExtractInfo(config: dict, url: str, debug: bool = False) -> dict:
|
||||
params: dict = {
|
||||
'color': 'no_color',
|
||||
'extract_flat': True,
|
||||
|
|
@ -158,9 +158,6 @@ def ExtractInfo(config: dict, url: str, debug: bool = False, forceLookup: bool =
|
|||
else:
|
||||
params['quiet'] = True
|
||||
|
||||
if forceLookup and 'download_archive' in params:
|
||||
params.pop('download_archive')
|
||||
|
||||
return yt_dlp.YoutubeDL(params=params).extract_info(url, download=False)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue