Merge pull request #65 from arabcoders/dev
Added a notification for failing to add link due to it being in the archive log
This commit is contained in:
commit
c6dd99c5e1
2 changed files with 38 additions and 5 deletions
|
|
@ -238,7 +238,29 @@ class DownloadQueue:
|
||||||
url,
|
url,
|
||||||
bool(self.config.ytdl_debug)
|
bool(self.config.ytdl_debug)
|
||||||
)
|
)
|
||||||
|
|
||||||
if not entry:
|
if not entry:
|
||||||
|
if self.config.keep_archive:
|
||||||
|
entry = await asyncio.get_running_loop().run_in_executor(
|
||||||
|
None,
|
||||||
|
ExtractInfo,
|
||||||
|
mergeConfig(self.config.ytdl_options, ytdlp_config),
|
||||||
|
url,
|
||||||
|
bool(self.config.ytdl_debug),
|
||||||
|
True
|
||||||
|
)
|
||||||
|
|
||||||
|
if not entry:
|
||||||
|
return {'status': 'error', 'msg': 'Unable to extract info check logs.'}
|
||||||
|
|
||||||
|
if self.isDownloaded(entry):
|
||||||
|
log.info(
|
||||||
|
f'[{entry.get("id")}: {entry.get("title")}]: has been downloaded already.')
|
||||||
|
return {
|
||||||
|
'status': 'error',
|
||||||
|
'msg': f'[{entry.get("id")}: {entry.get("title")}]: has been downloaded already.'
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'status': 'error',
|
'status': 'error',
|
||||||
'msg': 'No metadata, most likely video has been downloaded before.' if self.config.keep_archive else 'Unable to extract info check logs.'
|
'msg': 'No metadata, most likely video has been downloaded before.' if self.config.keep_archive else 'Unable to extract info check logs.'
|
||||||
|
|
|
||||||
21
app/Utils.py
21
app/Utils.py
|
|
@ -164,7 +164,7 @@ def calcDownloadPath(basePath: str, folder: str = None, createPath: bool = True)
|
||||||
return download_path
|
return download_path
|
||||||
|
|
||||||
|
|
||||||
def ExtractInfo(config: dict, url: str, debug: bool = False) -> dict:
|
def ExtractInfo(config: dict, url: str, debug: bool = False, forceLookup: bool = False) -> dict:
|
||||||
params: dict = {
|
params: dict = {
|
||||||
'color': 'no_color',
|
'color': 'no_color',
|
||||||
'extract_flat': True,
|
'extract_flat': True,
|
||||||
|
|
@ -177,7 +177,7 @@ def ExtractInfo(config: dict, url: str, debug: bool = False) -> dict:
|
||||||
# Remove keys that are not needed for info extraction as those keys generate files when used with extract_info.
|
# Remove keys that are not needed for info extraction as those keys generate files when used with extract_info.
|
||||||
for key in ('writeinfojson', 'writethumbnail', 'writedescription', 'writeautomaticsub',):
|
for key in ('writeinfojson', 'writethumbnail', 'writedescription', 'writeautomaticsub',):
|
||||||
if key in params:
|
if key in params:
|
||||||
del params[key]
|
params.pop(key)
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
params['verbose'] = True
|
params['verbose'] = True
|
||||||
|
|
@ -185,6 +185,9 @@ def ExtractInfo(config: dict, url: str, debug: bool = False) -> dict:
|
||||||
else:
|
else:
|
||||||
params['quiet'] = True
|
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)
|
return yt_dlp.YoutubeDL(params=params).extract_info(url, download=False)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -230,12 +233,20 @@ def isDownloaded(archive_file: str, info: dict) -> bool:
|
||||||
if not info or not archive_file or not os.path.exists(archive_file):
|
if not info or not archive_file or not os.path.exists(archive_file):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
id = yt_dlp.YoutubeDL()._make_archive_id(info)
|
try:
|
||||||
if not id:
|
id = yt_dlp.YoutubeDL()._make_archive_id(info)
|
||||||
|
if not id:
|
||||||
|
return False
|
||||||
|
except Exception as e:
|
||||||
|
log.error(f'Error generating archive id: {e}')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
with open(archive_file, 'r') as f:
|
with open(archive_file, 'r') as f:
|
||||||
return id in f.read()
|
for line in f.readlines():
|
||||||
|
if id in line:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def jsonCookie(cookies: dict[dict[str, any]]) -> str | None:
|
def jsonCookie(cookies: dict[dict[str, any]]) -> str | None:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue