mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-26 19:05:13 +00:00
feat(dl): add --skip-missing to skip titles that miss a required language or track
A season run skips such a title and continues; one title, or a run that skips every title, still exits 1 (now also for -ado/-fso). REST jobs report skipped_titles.
This commit is contained in:
@@ -137,6 +137,8 @@ class DownloadJob:
|
||||
# Subtitles skipped under skip_subtitle_errors (non-fatal). Each entry is a dl.SkippedSubtitle
|
||||
# dict (id / language / title) so a client can report which weren't available.
|
||||
skipped_subtitles: List[Dict[str, Any]] = field(default_factory=list)
|
||||
# Titles skipped because a requested track or language is missing; each a dl.SkippedTitle (title / reason).
|
||||
skipped_titles: List[Dict[str, Any]] = field(default_factory=list)
|
||||
|
||||
cancel_event: threading.Event = field(default_factory=threading.Event)
|
||||
|
||||
@@ -168,6 +170,7 @@ class DownloadJob:
|
||||
"segments_total": self.segments_total,
|
||||
"speed": self.speed,
|
||||
"skipped_subtitles": self.skipped_subtitles,
|
||||
"skipped_titles": self.skipped_titles,
|
||||
"input_prompt": self.input_prompt,
|
||||
"notice": self.notice,
|
||||
}
|
||||
@@ -232,6 +235,7 @@ def record_job_history(job: DownloadJob) -> None:
|
||||
"created_time": job.created_time.isoformat(),
|
||||
"completed_time": job.completed_time.isoformat() if job.completed_time else None,
|
||||
"output_files": job.output_files,
|
||||
"skipped_titles": job.skipped_titles,
|
||||
"parameters": redact_parameters(job.parameters),
|
||||
"error_message": _redact_text(job.error_message, job.parameters),
|
||||
}
|
||||
@@ -523,6 +527,8 @@ def perform_download(
|
||||
log.error(f"Download exited with code {exc.code}")
|
||||
log.debug("Stdout: %s", stdout_capture.getvalue())
|
||||
log.debug("Stderr: %s", stderr_capture.getvalue())
|
||||
if reason := getattr(dl_instance, "stop_reason", None):
|
||||
raise APIError(APIErrorCode.DOWNLOAD_ERROR, f"Download failed: {reason}")
|
||||
raise APIError(APIErrorCode.DOWNLOAD_ERROR, f"Download failed with exit code {exc.code}")
|
||||
|
||||
except Exception as exc: # noqa: BLE001 - propagate to caller
|
||||
@@ -961,11 +967,8 @@ class DownloadQueueManager:
|
||||
try:
|
||||
while True:
|
||||
done, _ = await asyncio.wait({communicate_task}, timeout=0.5)
|
||||
if communicate_task in done:
|
||||
stdout_bytes, stderr_bytes = communicate_task.result()
|
||||
break
|
||||
|
||||
# Check for progress updates (skip re-parse when the file hasn't changed since last tick)
|
||||
# Read progress before the exit check so the worker's last write lands (skip an unchanged file)
|
||||
try:
|
||||
stat = os.stat(progress_path)
|
||||
stat_key = (stat.st_mtime_ns, stat.st_size)
|
||||
@@ -1003,6 +1006,8 @@ class DownloadQueueManager:
|
||||
job.notice = progress_data["notice"]
|
||||
if progress_data.get("skipped_subtitles"):
|
||||
job.skipped_subtitles = progress_data["skipped_subtitles"]
|
||||
if progress_data.get("skipped_titles"):
|
||||
job.skipped_titles = progress_data["skipped_titles"]
|
||||
if "progress" in progress_data:
|
||||
new_progress = float(progress_data["progress"])
|
||||
if new_progress != job.progress:
|
||||
@@ -1017,6 +1022,10 @@ class DownloadQueueManager:
|
||||
except (OSError, json.JSONDecodeError, ValueError) as e:
|
||||
log.debug(f"Could not read progress for job {job.job_id}: {e}")
|
||||
|
||||
if communicate_task in done:
|
||||
stdout_bytes, stderr_bytes = communicate_task.result()
|
||||
break
|
||||
|
||||
if job.cancel_event.is_set() or job.status == JobStatus.CANCELLED:
|
||||
log.info(f"Cancellation detected for job {job.job_id}, terminating worker process")
|
||||
process.terminate()
|
||||
|
||||
Reference in New Issue
Block a user