feat(dl): add opt-in per-caller completion archive

This commit is contained in:
Fiszu
2026-12-01 21:58:17 -06:00
committed by GitHub
parent 7a5bac7878
commit e36236d5cc
14 changed files with 853 additions and 3 deletions
+10
View File
@@ -456,6 +456,8 @@ Make a download job. It requires `service` and `title_id`. Every other field is
| `require_video` | string[] | `[]` | Video languages that must exist. The job fails if one is missing, even with `best_available`, or skips the title with `skip_missing`. |
| `require_subs` | string[] | `[]` | Subtitle languages that must exist. The job fails if one is missing, or skips the title with `skip_missing`. `s_lang` still decides what to keep. |
| `skip_missing` | boolean | `false` | Skip a title that misses a required language or track, and continue with the next title. The job's `skipped_titles` lists each skip. The job fails when it has one title or skips every title. |
| `skip_existing` | boolean | `false` | Skip variants recorded as completed for this API key, matched after selection by service, title ID, quality, range and codec. Does not verify files on disk or compare audio/subtitle choices. |
| `force` | boolean | `false` | Bypass the completion archive check for this job. Does not change overwrite behaviour. |
| `forced_subs` | boolean | `false` | Include forced subtitles. |
| `forced_subs_only` | boolean | `false` | Download forced subtitles and no other subtitle; implies `forced_subs`. Not valid with `no_subs`, `video_only`, `audio_only` or `chapters_only`. |
| `forced_s_lang` | string[] | `[]` | Forced subtitle language(s); implies `forced_subs`. |
@@ -593,6 +595,7 @@ Show download jobs, with optional filtering and sorting.
"speed": "5.2 MB/s",
"skipped_subtitles": [],
"skipped_titles": [],
"already_present": [],
"input_prompt": null,
"notice": null,
"qr": null
@@ -865,6 +868,7 @@ Read the persisted history of jobs that reached a terminal state, newest first.
"completed_time": "2026-07-03T12:08:00+00:00",
"output_files": ["/downloads/Example.S01E01.mkv"],
"skipped_titles": [],
"already_present": [],
"error_message": null,
"parameters": { "...": "redacted" }
}
@@ -878,6 +882,12 @@ Read the persisted history of jobs that reached a terminal state, newest first.
| `200` | - | History returned. |
| `400` | `INVALID_PARAMETERS` | Invalid `limit`. |
`already_present` lists completion-archive skips separately from newly produced `output_files`
and missing-track `skipped_titles`. Each entry contains `service`, `title_id`, `title`,
`reason: "already_present"`, and `variants` (objects with `quality`, `range`, `codec`). The same
field is present in job progress/details. A job with only archive matches completes successfully.
The archive is independent of history retention, isolated per API key, and has no inventory endpoint.
### `DELETE /api/history/{job_id}`
Remove a single persisted history entry. Returns **`204 No Content`** (empty body) on success.
+2
View File
@@ -103,6 +103,8 @@ unshackle dl [OPTIONS] SERVICE [SERVICE ARGS...]
| `--require-video` | - | Video langs that must exist. The title fails even with `--best-available`. Does not select tracks. |
| `--require-subs` | - | Subtitle langs that must exist. Fails the title if one is missing. `--s-lang` still decides what to keep. |
| `--skip-missing` | off | Skip a title that misses a required language or track, and continue with the next title. A run with one title, or a run that skips every title, still fails. |
| `--skip-existing` | off | Skip a resolved video variant recorded in the completion archive. Does not verify that files still exist. |
| `--force` | off | Bypass the completion archive check for this run; does not change overwrite behaviour. |
| `-fs`, `--forced-subs` | off | Include forced subtitle tracks. |
| `-fso`, `--forced-subs-only` | off | Keep only forced subtitle tracks; drop the other subtitles. Implies `-fs`. |
| `-fsl`, `--forced-s-lang` | none | Language(s) wanted for forced subtitles; implies `-fs`. A `-` prefix excludes. |
+33
View File
@@ -109,6 +109,39 @@ dl:
request body, `workers: 0` for example, makes each job that uses it fail at submit with
`400 INVALID_PARAMETERS`.
### Completion archive
`dl.skip_existing: true` opts CLI downloads into an append-only completion archive under
`directories.cache/download-archive/cli.jsonl`. `--skip-existing` enables it for one run;
`--force` bypasses its check and still records successful full outputs when the archive is enabled.
A receipt holds the canonical service tag, title ID (string or integer), and the resolved video
quality, range and codec. Selection runs normally before checking the archive: a best-available
720p result can match 720p again, but a later 1080p selection downloads. A different quality,
range or codec does not match. All selected variants must have receipts to skip the title.
A higher resolution does not satisfy an explicitly lower request.
Receipts are written only after a full movie/episode has been muxed and its output files have
been published. Samples, `--skip-dl`, `--no-mux`, track-only and omitted-track modes do not check
or update the archive. Unknown video metadata, non-string/non-integer IDs, music, stereoscopic
and generated/hybrid video outputs also fall back to normal downloading. So does
`--skip-subtitle-errors`, which can publish incomplete output. `--include-sample` still records
the complete output, not the sample.
This is a completion log, not a media inventory: deleting or moving an output does not remove
its receipt. It does not compare audio or subtitle choices or inspect existing files. Use
`--force` when an archived variant needs to be downloaded again. It does not import job history,
and history trimming or deletion does not affect it. Clearing the cache removes these receipts.
Concurrent writers lock only local archive I/O; simultaneous downloads may both proceed.
API jobs use separate files named `api-<SHA-256 of caller key>.jsonl` in the same directory.
They never consult the CLI archive or another caller's archive. Enable this with the request's
`skip_existing: true`, a `serve.skip_existing` default, or a `services.<TAG>.dl.skip_existing`
default. API callers cannot choose a scope or archive path. An ownerless internal job does not
use the archive. Remote service selection uses the local job's completion archive, not a remote
server's library. Skipped receipts are reported as `already_present` and complete successfully;
this does not change the separate missing-track `skipped_titles` behaviour.
## `continue_downloads`
- **Type:** `bool` &nbsp;·&nbsp; **Default:** `false`