This commit is contained in:
arabcoders 2025-04-26 17:22:59 +03:00
parent 68a0d6b571
commit 0f69ec047c

View file

@ -24,7 +24,7 @@ from .ItemDTO import Item, ItemDTO
from .Presets import Presets from .Presets import Presets
from .Scheduler import Scheduler from .Scheduler import Scheduler
from .Singleton import Singleton from .Singleton import Singleton
from .Utils import ag, arg_converter, calc_download_path, dt_delta, extract_info, is_downloaded, load_cookies from .Utils import arg_converter, calc_download_path, dt_delta, extract_info, is_downloaded, load_cookies
from .YTDLPOpts import YTDLPOpts from .YTDLPOpts import YTDLPOpts
LOG = logging.getLogger("DownloadQueue") LOG = logging.getLogger("DownloadQueue")
@ -786,8 +786,8 @@ class DownloadQueue(metaclass=Singleton):
LOG.debug(f"Checking for stale workers. {len(workers)} workers found.") LOG.debug(f"Checking for stale workers. {len(workers)} workers found.")
for worker_id in workers: for worker_id in workers:
worker = ag(workers, worker_id, {}) worker = workers.get(worker_id, {})
started = ag(worker, "started", None) started = worker.get("started", None)
if not started: if not started:
LOG.debug(f"Worker '{worker_id}' not working yet.") LOG.debug(f"Worker '{worker_id}' not working yet.")
continue continue
@ -798,18 +798,20 @@ class DownloadQueue(metaclass=Singleton):
LOG.debug(f"Worker '{worker_id}' is not consider stale yet.") LOG.debug(f"Worker '{worker_id}' is not consider stale yet.")
continue continue
status = ag(worker, "data.status", None) data = worker.get("data", {})
status = data.get("status", None)
if "preparing" != status: if "preparing" != status:
LOG.debug(f"Worker '{worker_id}' not stuck. Status '{status}'.") LOG.debug(f"Worker '{worker_id}' not stuck. Status '{status}'.")
continue continue
_id = ag(worker, "data._id", None) _id = data.get("data._id", None)
if not _id: if not _id:
LOG.debug(f"Worker '{worker_id}' has no id.") LOG.debug(f"Worker '{worker_id}' has no id.")
continue continue
id = ag(worker, "data.id", None) id = data.get("id", None)
title = ag(worker, "data.title", None) title = data.get("title", None)
item_ref = f"{_id=} {id=} {title=}" item_ref = f"{_id=} {id=} {title=}"