From 0d9050e68eca5dc62e2e31e801aa76b6a256fc05 Mon Sep 17 00:00:00 2001 From: imSp4rky Date: Sat, 5 Dec 2026 10:30:33 -0700 Subject: [PATCH] chore(release): bump version to 7.1.0 and refuse a remote session create that sends cdm_relay --- CHANGELOG.md | 223 ++++++++++++++++++ docs/dev/rest-api/remote-sessions.md | 6 +- pyproject.toml | 2 +- .../unit/snapshots/route_error_replies.json | 12 +- tests/remote/unit/test_session_lifetime.py | 3 + unshackle/core/__init__.py | 2 +- unshackle/core/api/handlers.py | 9 +- uv.lock | 2 +- 8 files changed, 244 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2746fa1d4..baf96c316 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,229 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm This changelog is automatically generated using [git-cliff](https://git-cliff.org). +## [7.1.0] - 2026-12-05 + +### Features + +- *remote*: Add a session channel for the messages the server starts +- *remote*: Warn when the client cache has more files than a server takes +- *remote*: License each track locally with --cdm-only over remote +- *service*: Pass a qr code with a login prompt or approval wait +- *drm*: Add the whole-file aes-ctr cipher and paged aac rewrite +- *tracks*: Resolve a track url on use, locally and over remote +- *console*: Read a QR code from a PNG with a pure decoder +- *log*: Record each HTTP attempt in the debug log with debug_requests +- *session*: Open a websocket on the rnet session +- *dl*: Name the free space of a nearly full temp volume on the failure line +- *dl*: Warn before the downloads when the temp volume cannot hold the selected tracks +- *config*: Add filename_replacements to replace text in output names +- *dl*: Warn when the temp volume cannot hold the HLS tracks of a title +- *tracks*: Resume segment decryption and rolling merge through the segment store +- *providers*: Let a service name the metadata provider its catalogue resolves through +- *providers*: Fill the western IDs of an AniList match from the anime-lists ID map +- *providers*: Fill the AniList ID of a TMDB or TVDB match from the anime-lists ID map +- *hls*: Use the DRM of the track when no key tag can be licensed +- *service*: Warn when a proxy exit is outside GEOFENCE +- *remote*: Name the missing KID in the server-device error +- *music*: List and select playlist songs by their position +- *remote*: End a remote session when its client is gone +- *hls*: License a FairPlay-only SAMPLE-AES playlist through a PlayReady or Widevine CDM +- *core*: Add HDR Vivid hybrids and a MonaLisa command builder +- *hls*: License every content key of a FairPlay bridge playlist that rotates its key +- *drm*: Warn when the licence returns the content key that the decode check flagged +- *dl*: Add opt-in per-caller completion archive +- *drm*: Bridge a FairPlay-only HLS track only for a service with get_fairplay_bridge_license +- *dl*: Leave FairPlay-only tracks out of the selection for a service without get_fairplay_bridge_license +- *hdr*: Find HDR Vivid and HDR10+ SEI in MPEG-TS and VVC tracks, read local HLS playlists and accept a 200 probe body +- *hls*: Carry a held media playlist over --remote and export, inflate gzip segments, add own_stream_only mux opt-in +- *drm*: License MonaLisa over --remote on the server and decrypt it in core, with or without bbtsdecrypt +- *tracks*: Add Audio bit_depth and sample_rate from manifests and carry them over remote +- *music*: Redraw the album header with the quality of the first song's chosen audio track +- *music*: Add shared LRC and SRT lyric helpers to core music +- *drm*: [**breaking**] Load DRM systems beyond the built-ins from plugins in directories.plugins +- *drm*: Decrypt plugin segments as they land on the fetch_segments decrypter seam +- *drm*: License a plugin DRM at the licence step and over --remote with the client's plugin device +- *dl*: Add --max-downloads to stop a run after N downloaded titles +- *remote*: Send the client's services..preferences to the server in every licensing mode +- *kv*: [**breaking**] Take KID:KEY pairs and key files as kv add arguments with optional --service and --vault +- *remote*: [**breaking**] Make remote serve WebSocket-only and refuse older clients with CLIENT_OUTDATED + +### Bug Fixes + +- *dash*: Trim audio that overlaps the next stitched period before decryption +- *remote*: Send a service option under its served name +- *remote*: Answer malformed input with one line and keep secrets out of logs +- *api*: Evict a session of the key that holds the most at max_sessions +- *drm*: End a licence with no usable key in one line for every DRM system +- *api*: Redact every form of a configured credential from job errors +- *remote*: Close a session channel whose loop already ended +- *api*: Take 256 cache files and an 8 MiB body on the login routes +- *cdm*: Read every device's DRM system through one CDM catalogue +- *remote*: License a server-CDM track through ServerKeySource +- *cdm*: Keep remote CDM state per session in one shared HttpCdm base +- *drm*: Give an L1 remote CDM the common privacy certificate when a service has none +- *dl*: Keep a second file with the same name by moving output placement and the mux step into their own modules +- *api*: Let a core failure name its own API error code +- *core*: Load every service config through one launch-context function +- *api*: Keep the error code a download failure names in the job error +- *api*: Leave Gluetun out of a server download job's proxy providers +- *remote*: Load the server's first-listed cdm for a server-device option +- *serve*: Close the developer dashboard when a config reload removes its key +- *vaults*: Quote table names, dedupe kids without case, and reuse one mysql connection +- *cacher*: Store a jwt with no exp claim without an expiration +- *api*: Cap the total size of a client cache upload and clean up after a refused session create +- *clearkey*: Warn when pkcs7 unpad fails and require a 16-byte key from the key uri +- *remote*: Skip a malformed server log record or channel message instead of ending the session channel +- *dash*: Require a matching 206 for the segmentbase init and fetch it from its sourceurl +- *vaults*: Log a one-line warning and skip an http vault that answers non-json +- *vaults*: Log each vault failure once in one line without the request url +- *dl*: Name no cdm system in the remote status line of a whole-file cipher title +- *vaults*: Raise when an http or api vault is down or rate limited +- *vaults*: Raise when an http vault is rate limited or refuses a push +- *session*: Make RnetResponse a context manager for cover downloads +- *events*: Emit TRACK_DOWNLOADED once per track after decryption +- *drm*: Keep the track file when shaka-packager skips a stream with no samples +- *dash*: License a track whose only key system is the W3C common PSSH as ClearKey +- *api*: Check serve and service dl defaults at job admission +- *providers*: Match non-Latin titles by letters of every script +- *subprocess*: Name the tool, exit and reason in external-tool errors +- *manifests*: Skip a DASH Representation or HLS variant with an unknown codec +- *dl*: Stop a failed mux with one line that names the free space +- *drm*: Keep the input when mp4decrypt fails or writes no output +- *serve*: Reject a config reload whose validation exits instead of stopping the server +- *providers*: Accept an IMDb or AniList match on any title the ranker used +- *drm*: Keep the input when a cbcs, ClearKey, stripe or segment decrypt fails +- *tracks*: Keep segment resume across an hls merge failure and a locked partial on windows +- *remote*: Map a cut-off answer to a recoverable error and stop trusting an empty optional answer +- *api*: Stop serve cleanly with jobs, streams and remote sessions open +- *api*: Redact error replies, lock segment url lookups, refuse unresolvable proxy hosts and recheck job proxies at start +- *tracks*: Treat a zero-denominator video frame rate as unknown +- *remote*: Run the session channel and tunnel loops without asyncio.run so exit starts no thread on Python 3.12.0-3.12.2 +- *providers*: Match a later season's year and TVDB translated names in metadata searches +- *drm*: Read the init segment tenc KID when FFprobe is not installed +- *drm*: Raise ValueError when a file ends inside a box largesize in read_top_boxes +- *hls*: Give a variant or media entry listed twice one track +- *hls*: Refuse key tags the DRM of the track cannot decrypt +- *subtitle*: Drop the XML declaration of TTML before pycaption reads it +- *music*: Show a collection's own facts in the listing and over --remote +- *remote*: End a remote session from before its create to after its DELETE +- *remote*: Measure the idle time of a remote session on a monotonic clock +- *remote*: End the remote session when a signal or a closed console stops the client +- *remote*: End remote session work when the server stops, and leave no session cache behind +- *remote*: End every remote wait of a run when the user cancels it +- *hls*: Apply each key tag to the wanted segments that it governs +- *remote*: End the remote logins and the pooled remote sessions of a relay when the server stops +- *hls*: Bridge a stitched one-key FairPlay playlist with an all-zero tenc KID +- *hls*: Bridge a FairPlay playlist whose clear part has a METHOD=NONE tag and its own init segment +- *hls*: Keep the EXT-X-KEY of another KEYFORMAT in force when a playlist renews one key tag +- *drm*: Stop a bridged FairPlay track whose server-CDM answer or licence key does not decrypt it +- *drm*: Send a bridged licence key to the server vault only after its decode check decodes it +- *import*: Keep the FairPlay bridged mark and every KID of a DRM through an export +- *dash*: Refuse an encrypted DASH track with no licensable DRM and gate FairPlay-only DASH tracks for a hook service +- *dl*: Exit 1 when a title's track download fails +- *dl*: Time elapsed lines, downloader and proxy waits with time.monotonic +- *tracks*: Sniff attachment MIME from file bytes and keep ffmpeg autobsf on repack +- *title-cache*: Key a cookie-only login by its cookie file path +- *tracks*: Mark AC-4 Atmos from the HLS ATMOS channels identifier and carry atmos without JOC through signature, export and remote +- *subprocess*: Log handled tool failures at debug and drop an empty ccextractor output +- *titles*: Name AC-4 Atmos in the {atmos} token from Audio.atmos of the tracks in the file +- *snapshot*: Keep every manifest tree of a shared URL and restore each track from its own tree +- *import*: Keep the values a service set on exported tracks and export a song as a song +- *naming*: Label AC-4 audio as AC4 in file names +- *remote*: Send the off form of a service --x/--no-x flag over --remote +- *api*: Time the rate-limit window on the monotonic clock and make three flaky tests deterministic +- *log*: Redact the debug_requests record and write each body to a file in a per-run folder +- *drm*: Decrypt a track with mp4decrypt when its sample offsets are not relative to the moof +- *session*: Pass verify to the rnet client and carry it into download child processes +- *downloader*: Reject a speed limit too large for a float in parse_speed_limit +- *remote*: Stop at the licence step when a licence fails, falling back only to the service's cdm entry +- *remote*: Stop with one line when a remote server rejects the API key instead of building the stub command +- *api*: Report a response body that ended early as a retryable NETWORK_ERROR +- *session*: Retry an rnet response whose body ends early +- *session*: Name the API error code and the short rnet cause of an exhausted request + +### Documentation + +- *services*: Show METADATA_PROVIDER in the EXAMPLE service template +- *drm*: Credit CodeName393 bbtsdecrypt (GPL-3.0) in the BBTS decrypter docstring +- *config*: Explain how to set defaults for a service's own options +- *rest-api*: Build the download request table from the OpenAPI yaml +- *service*: Make the Service docstring the one table of class variables and attributes +- *config*: Make the configuration reference the one owner of every option table +- *cli*: Make cli-reference the one description of each dl flag and downloading.md the task guide +- *rest-api*: Give the remote session protocol one page and move dl --remote setup to a user guide +- *nav*: Add a User Guide Server section and move the Python API under Developer +- Sweep docs to zero ste_lint findings and one remote session name +- Give each dl and serve flag and the error envelope one owner page and tighten the cli-reference test + +### Changes + +- *dl*: Move track selection into core/tracks/selection.py +- *manifests*: Share one segment pipeline across dash, hls, ism +- *core*: Move the title, track and DRM wire form into core/wire.py +- *dl*: Move content-key resolution into core/drm/key_resolution.py +- *api*: Keep the dl option facts in one table in core/dl_options.py +- *remote*: Keep the session protocol in core/remote_protocol.py +- *remote*: Send every client call through RemoteClient +- *drm*: Make the internal ContentKeyResolver methods private +- *api*: Answer a route's uncaught exception in one decorator +- *cdm*: Read a cdm entry for device and DRM system in one module +- *api*: Build a remote session whole, with one login state +- *core*: Write a service's launch keys through one module +- *core*: Move login state to core.login and load key vaults through one factory +- *dl*: Check dl options once in a run plan shared by the CLI and the REST download job +- *manifests*: Pick the licensable DRM and KID in one licence step +- *drm*: Read CENC systems and track KIDs in one cenc module +- *api*: Answer every API key question from one KeyPolicy +- *core*: One TitleSource base for Service, remote and import +- *api*: Admit download job create and retry through one job_admission step +- *core*: Lift title metadata enrichment out of dl into TitleMetadata +- *drm*: Move track drm discovery into core and merge the drifted pssh and hls playlist readers +- Delete unreferenced title cache, log, template, provider and http vault helpers +- *vaults*: Move content-key provenance and the bad-key verdict into vaults +- *vaults*: Give the server handlers vault operations +- *proxies*: Resolve every --proxy value through one shared entry +- *proxies*: Apply a service proxy_map before the proxy resolves +- *vaults*: Pick kv vault behaviour from class flags and keep the api batch size +- *api*: Resolve service options once with requested_service_options +- *api*: Give every served service its dl options from the run plan +- *tracks*: Fold segment resume into one segment store module +- *api*: Move the server CDM licence cap into one module that measures tracks by the -q rule +- *remote*: Hold who licenses a remote session as one licensing mode +- *api*: Move server key resolution into server_keys and name the tracks reply's DRM system from the licence order +- *drm*: Build PlayReady from base64 with PlayReady.from_pssh_b64 in server keys and the wire rebuild +- *drm*: Read PlayReady result codes from pyplayready DrmResult and drop the hand-copied table +- *commands*: Run the prd and wvd dump commands through the upstream pyplayready and pywidevine CLIs +- *drm*: Read PlayReady KIDs from pyplayready WRM headers and drop the hand XML scan +- *wire*: Put the tracks reply codec in wire and stamp service flags in serialize_title +- *tracks*: Make complete_track the one finish step for every track kind +- *api*: Build list, search and session services through one launch_served +- *api*: Put the job and worker process channels in job_channel +- *api*: End every remote session through SessionStore._retire and close the store at shutdown +- *temp*: Read the free space where the failed step deletes its temp files +- *export*: Move the --export writer out of dl into core ExportWriter +- *api*: Decide the proxy of an API request in one api_proxy module +- *drm*: Hand the server key batch to one installer as a KeyBatch value +- *manifests*: Merge downloaded DASH and ISM segments through segment_pipeline.merge_downloaded +- *manifests*: Build the HLS key plan once and read it in every HLS licence pass +- *remote*: Encode the session create body in run_plan.session_request beside served_plan +- *vaults*: Move the settle rules, vault writer, stored tally and server-vault push into the key ledger +- *cdm*: Leave key vault reads and writes to content-key resolution in an HTTP CDM run +- *downloader*: Put one transport adapter per HTTP session kind under download() +- *downloader*: Judge every 206, 416 and 200 ranged answer in one range_answer verdict +- *downloader*: Make dl.result the one writer of the speed limit and drop speed_limit_locked +- *downloader*: Keep download()'s retry counters and their resets in one RetryBudget +- *downloader*: Build every progress speed string with format_speed + +### Maintenance + +- *vaults*: Drop the stale sql injection todos + +### Builds + +- *deps*: Drop unused crccheck, jsonpath-ng, PyExecJS and chardet +- Cap floating dependencies, add a ci coverage report and fix the contributing checks + ## [7.0.0] - 2026-11-23 ### Features diff --git a/docs/dev/rest-api/remote-sessions.md b/docs/dev/rest-api/remote-sessions.md index 84035f665..210341791 100644 --- a/docs/dev/rest-api/remote-sessions.md +++ b/docs/dev/rest-api/remote-sessions.md @@ -61,7 +61,7 @@ DELETE /api/session/{id} → the end, with the changed cache files - **Body size.** The create request and `POST /api/search` take a body of up to 8 MiB, the `samples` route up to 16 MiB, and every other route up to 1 MiB. - **Older clients.** The server accepts only the current client flow. A create without - `session_id`, and a service route of a remote session whose client never opened the remote session + `session_id` or with `cdm_relay`, and a service route of a remote session whose client never opened the remote session channel, get `426 CLIENT_OUTDATED`. ### Slow responses @@ -197,7 +197,7 @@ the background, and answers at once with the login state `authenticating`. The b |---|---| | `service` | Required. The service tag, in any case, or an alias. | | `title_id` | Required. The title ID or URL, as for `dl`. | -| `session_id` | Required. The ID that the client gives the remote session: the canonical text of a version 4 UUID. Without it, the create gets `426 CLIENT_OUTDATED`. | +| `session_id` | Required. The ID that the client gives the remote session: the canonical text of a version 4 UUID. Without it, the create gets `426 CLIENT_OUTDATED`. A create that has `cdm_relay` gets the same error. | | `credentials` | `{username, password, extra?}` for the profile. | | `cookies` | The Netscape cookie file of the profile, zlib-compressed and base64-encoded. | | `cache` | The cache files of the service: a map of cache key to the zlib-compressed, base64-encoded file. See [Cache files](#cache-files). | @@ -286,7 +286,7 @@ keys from track data, and keeps the cache on the server. | `400` | `INVALID_SERVICE` | An unknown service, or one that the API key may not use. | | `403` | `FORBIDDEN` | Another API key or another IP address has the `session_id`. | | `404` | `SESSION_NOT_FOUND` | A `DELETE` or a newer create with the same `session_id` ended this create. | -| `426` | `CLIENT_OUTDATED` | No `session_id`: the client is older than the server accepts. | +| `426` | `CLIENT_OUTDATED` | No `session_id`, or a `cdm_relay` field: the client is older than the server accepts. | | `409` | `SERVER_DRAINING` | The server drains before a restart. | ### `GET /api/tunnel` diff --git a/pyproject.toml b/pyproject.toml index 9ee9a392f..b1594f8de 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "unshackle" -version = "7.0.0" +version = "7.1.0" description = "Modular Movie, TV, and Music Archival Software." authors = [{ name = "unshackle team" }] requires-python = ">=3.11,<3.15" diff --git a/tests/remote/unit/snapshots/route_error_replies.json b/tests/remote/unit/snapshots/route_error_replies.json index 9c3299cc6..7c3985e64 100644 --- a/tests/remote/unit/snapshots/route_error_replies.json +++ b/tests/remote/unit/snapshots/route_error_replies.json @@ -3353,7 +3353,7 @@ "session create no session id": { "body": { "error_code": "CLIENT_OUTDATED", - "message": "This client is older than the server accepts: update unshackle to the current dev build (ref REF)", + "message": "This client is older than the server accepts: update unshackle to the latest dev build (ref REF)", "ref": "REF", "status": "error", "timestamp": "TIMESTAMP" @@ -3361,12 +3361,12 @@ "content_type": "application/json", "leading_newlines": false, "log": [ - "Error ref REF: CLIENT_OUTDATED 426 POST /api/session/create service=EXAMPLE user=test\u2026: This client is older than the server accepts: update unshackle to the current dev build" + "Error ref REF: CLIENT_OUTDATED 426 POST /api/session/create service=EXAMPLE user=test\u2026: This client is older than the server accepts: update unshackle to the latest dev build" ], "stats": { "error": { "code": "CLIENT_OUTDATED", - "message": "This client is older than the server accepts: update unshackle to the current dev build", + "message": "This client is older than the server accepts: update unshackle to the latest dev build", "ref": "REF" }, "late_status": null @@ -3615,7 +3615,7 @@ "titles no channel": { "body": { "error_code": "CLIENT_OUTDATED", - "message": "This client is older than the server accepts: update unshackle to the current dev build (ref REF)", + "message": "This client is older than the server accepts: update unshackle to the latest dev build (ref REF)", "ref": "REF", "status": "error", "timestamp": "TIMESTAMP" @@ -3623,12 +3623,12 @@ "content_type": "application/json", "leading_newlines": false, "log": [ - "Error ref REF: CLIENT_OUTDATED 426 GET /api/session/pinned-session/titles service=EXAMPLE user=test\u2026: This client is older than the server accepts: update unshackle to the current dev build" + "Error ref REF: CLIENT_OUTDATED 426 GET /api/session/pinned-session/titles service=EXAMPLE user=test\u2026: This client is older than the server accepts: update unshackle to the latest dev build" ], "stats": { "error": { "code": "CLIENT_OUTDATED", - "message": "This client is older than the server accepts: update unshackle to the current dev build", + "message": "This client is older than the server accepts: update unshackle to the latest dev build", "ref": "REF" }, "late_status": null diff --git a/tests/remote/unit/test_session_lifetime.py b/tests/remote/unit/test_session_lifetime.py index cee6e8bba..41c1831a4 100644 --- a/tests/remote/unit/test_session_lifetime.py +++ b/tests/remote/unit/test_session_lifetime.py @@ -562,6 +562,9 @@ def test_the_server_takes_the_id_that_the_client_names() -> None: with pytest.raises(APIError) as e: handlers.new_session_id({}) assert e.value.error_code == APIErrorCode.CLIENT_OUTDATED + with pytest.raises(APIError) as e: + handlers.new_session_id({"session_id": named, "cdm_relay": True}) + assert e.value.error_code == APIErrorCode.CLIENT_OUTDATED def test_a_create_that_times_out_is_deleted(build: SimpleNamespace) -> None: diff --git a/unshackle/core/__init__.py b/unshackle/core/__init__.py index 6173baa82..9889f8fa4 100644 --- a/unshackle/core/__init__.py +++ b/unshackle/core/__init__.py @@ -11,7 +11,7 @@ _patch_click_help() # The patch also rebinds these, which makes Context.invoke refuse a command that another package built. click.core.Command, click.core.Group = _CLICK_CLASSES # type: ignore[misc] -__version__ = "7.0.0" +__version__ = "7.1.0" PKG = Path(__file__).parent.parent # Framework code only. Services are user-swappable, so they are not part of the identity. diff --git a/unshackle/core/api/handlers.py b/unshackle/core/api/handlers.py index a5e9641f9..a26e081fa 100644 --- a/unshackle/core/api/handlers.py +++ b/unshackle/core/api/handlers.py @@ -2922,12 +2922,15 @@ def client_device_cdm( ) -CLIENT_OUTDATED_MESSAGE = "This client is older than the server accepts: update unshackle to the current dev build" +CLIENT_OUTDATED_MESSAGE = "This client is older than the server accepts: update unshackle to the latest dev build" def new_session_id(data: dict[str, Any]) -> str: - """The id of the remote session to make, which its client names as a canonical UUID version 4.""" - if "session_id" not in data: + """The id of the remote session to make, which its client names as a canonical UUID version 4. + + A client that sends no id, or the ``cdm_relay`` flag of the polling flow, is older than the server accepts. + """ + if "session_id" not in data or "cdm_relay" in data: raise APIError(APIErrorCode.CLIENT_OUTDATED, CLIENT_OUTDATED_MESSAGE) named = data["session_id"] with suppress(ValueError): diff --git a/uv.lock b/uv.lock index 57399d985..a7db5cbc6 100644 --- a/uv.lock +++ b/uv.lock @@ -2240,7 +2240,7 @@ wheels = [ [[package]] name = "unshackle" -version = "7.0.0" +version = "7.1.0" source = { editable = "." } dependencies = [ { name = "aiohttp" },