refactor(api): move the server CDM licence cap into one module that measures tracks by the -q rule

This commit is contained in:
imSp4rky
2026-11-29 09:16:18 -07:00
parent 6fc2d84bd7
commit 8e67081e11
13 changed files with 318 additions and 168 deletions
+1 -1
View File
@@ -72,7 +72,7 @@ unshackle dl [OPTIONS] SERVICE [SERVICE ARGS...]
| Flag | Default | Description |
|---|---|---|
| `-p`, `--profile` | - | Profile for credentials and cookies. |
| `-q`, `--quality` | best | Resolution(s), comma-separated, e.g. `1080,720`. `-q 1080` also matches anamorphic tracks by 16:9 canvas. |
| `-q`, `--quality` | best | Resolution(s), comma-separated, e.g. `1080,720`. `-q 1080` also matches anamorphic tracks by 16:9 canvas, and padded encodes by standard resolution. |
| `-v`, `--vcodec` | any | Video codec(s). Accepts names or values: `AVC`/`H.264`/`H264`, `HEVC`/`H.265`/`H265`, `VVC`/`H.266`/`H266`, `VC1`/`VC-1`, `VP8`, `VP9`, `AV1`. |
| `-a`, `--acodec` | any | Audio codec(s), comma-separated. Accepts `AAC`, `AC3`/`DD`, `EC3`/`DD+`/`eac3`/`ddp`, `AC4`/`AC-4`, `OPUS`, `OGG`/`VORB`/`vorbis`, `DTS`, `DTSX`/`DTS-X`, `ALAC`, `FLAC`, `MP3`. |
| `-vb`, `--vbitrate` | highest | Exact video bitrate in kbps. |
+3 -1
View File
@@ -87,7 +87,9 @@ unshackle dl -q 2160,1080,720 EXAMPLE 81234567
!!! note "16:9 canvas matching"
Resolution matching is by track **height** first. If no track height matches exactly,
unshackle falls back to a 16:9-canvas match, so `-q 1080` also selects an
anamorphic `1920×804` track (computed as `int(width × 9 / 16)`). unshackle applies the
anamorphic `1920×804` track (computed as `int(width × 9 / 16)`). A padded or cropped encode
also matches its standard resolution, the nearest standard height within 10%, so `-q 1080`
selects a `2048×1088` track. unshackle applies the
fallback to each range and codec on its own. A service that crops only its HDR10 tracks
therefore keeps its `3840×1920` HDR10 track, even when another range has an exact
`2160` height match.
+4 -2
View File
@@ -215,8 +215,10 @@ server-identity flag, keeps the server CDM.
Set it to a height in pixels for every service, or to a map of service tag to height with an
optional `default` entry. A service the map does not name or sets to `null` gets the `default`, and
with no `default` it has no limit. The server compares the limit with the lowest `-q` that selects
the track: the track height, or the 16:9 height from the width when that is lower. The server reads
the remote client's `-q` when the remote session starts:
the track, by the rule of `dl -q`: the track height, the 16:9 height from the width, or the standard
resolution of a padded or cropped encode (the nearest standard height within 10%). Thus the server
never refuses a track that `-q` at the limit selects: a padded `2048x1088` track passes a `1080`
limit. The server reads the remote client's `-q` when the remote session starts:
- With no `-q`, or a `-q` at or below the limit, the server CDM licenses the remote session. The server
refuses a live licence for a video track taller than the limit, and the client licenses that