Show that a external dl is being used if we are stuck in preparing stage as yt-dlp doesn't trigger progress_hook

This commit is contained in:
arabcoders 2025-04-10 01:32:32 +03:00
parent 4a21592e12
commit 17dd007ff0
2 changed files with 25 additions and 3 deletions

View file

@ -184,8 +184,8 @@ class DownloadQueue(metaclass=Singleton):
"""
if item.has_extras():
for key in item.extras.copy():
if not str(key).startswith("playlist"):
item.extras.pop(key, None)
if not self.keep_extra_key(key):
item.extras.pop(key)
if not entry:
return {"status": "error", "msg": "Invalid/empty data was given."}
@ -395,6 +395,10 @@ class DownloadQueue(metaclass=Singleton):
.get_all(),
}
if yt_conf.get("external_downloader"):
LOG.warning(f"Using external downloader '{yt_conf.get('external_downloader')}' for '{item.url}'.")
item.extras.update({"external_downloader": True})
downloaded, id_dict = self._is_downloaded(file=yt_conf.get("download_archive", None), url=item.url)
if downloaded is True and id_dict:
message = f"This url with ID '{id_dict.get('id')}' has been downloaded already and recorded in archive."
@ -715,3 +719,17 @@ class DownloadQueue(metaclass=Singleton):
return False, None
return is_downloaded(file, url)
def keep_extra_key(self, key: str) -> bool:
"""
Check if the extra key should be kept.
Args:
key (str): The extra key to check.
Returns:
bool: True if the extra key should be kept, False otherwise.
"""
keys = ("playlist", "external_downloader")
return any(key == k or key.startswith(k) for k in keys)

View file

@ -301,6 +301,10 @@ const setStatus = item => {
return 'Live Streaming';
}
if ('preparing' === item.status) {
return ag(item, 'extras.external_downloader') ? 'External DL' : 'Preparing..';
}
if (!item.status) {
return 'Unknown..';
}
@ -372,7 +376,7 @@ const updateProgress = (item) => {
}
if ('preparing' === item.status) {
return 'Preparing';
return ag(item, 'extras.external_downloader') ? 'External downloader.' : 'Preparing';
}
if (null != item.status) {