Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions contracts/api/v2/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -32773,6 +32773,7 @@
"type": "integer"
},
"playback_variants": {
"description": "Logical watch choices in server recommendation order: explicitly scoped file first, then the viewer's remembered edition, then standard before theatrical before other cuts, then first-part quality. playback_variants[0] is the recommended edition; clients apply only their local quality cap to each part's server-ordered versions",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
"items": {
"$ref": "#/components/schemas/PlaybackVariant"
},
Expand Down Expand Up @@ -32988,7 +32989,7 @@
"description": "The viewer's flags; absent without a profile"
},
"versions": {
"description": "Empty, never null",
"description": "Ordered in server preference order (highest resolution, then HDR, then file size, with first presentation parts before later parts); empty, never null",
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
"items": {
"$ref": "#/components/schemas/FileVersion"
},
Expand Down Expand Up @@ -53351,9 +53352,11 @@
"type": "boolean"
},
"audio_track_id": {
"description": "Explicit audio track identity picked by the viewer. Omit both audio_track_id and audio_track_index when the viewer did not pick a track (do not echo effective_audio_track_index) so the server resolves saved/profile preference and refines for unconverted playback.",
"type": "string"
},
"audio_track_index": {
"description": "Explicit zero-based audio track ordinal picked by the viewer. Omit when no track was picked so the server resolves preference and avoids unnecessary audio conversion.",
"format": "int64",
"type": "integer"
},
Expand Down Expand Up @@ -53462,9 +53465,11 @@
"type": "string"
},
"subtitle_track_id": {
"description": "Selected subtitle track identity. Omitting both subtitle_track_id and subtitle_track_index means subtitles off; clients rely on omission for off and for burn-in refusal retries.",
"type": "string"
},
"subtitle_track_index": {
"description": "Selected subtitle track index in the combined inventory. Omitting both subtitle_track_id and subtitle_track_index means subtitles off.",
"format": "int64",
"type": "integer"
}
Expand Down Expand Up @@ -53544,7 +53549,7 @@
"additionalProperties": false,
"properties": {
"default_file_id": {
"description": "Opaque identifier",
"description": "Recommended file_id for this variant (its first part's default_file_id)",
"examples": [
"1"
],
Expand All @@ -53562,7 +53567,7 @@
"type": "integer"
},
"parts": {
"description": "Empty, never null",
"description": "Ordered by part_index; empty, never null",
"items": {
"$ref": "#/components/schemas/PlaybackVariantPart"
},
Expand Down Expand Up @@ -53594,7 +53599,7 @@
"additionalProperties": false,
"properties": {
"default_file_id": {
"description": "Opaque identifier",
"description": "Recommended file_id for this part (the explicitly scoped file_id when present, else versions[0])",
"examples": [
"1"
],
Expand All @@ -53610,7 +53615,7 @@
"type": "integer"
},
"versions": {
"description": "Empty, never null",
"description": "Ordered in server preference order (highest resolution, then HDR, then file size); empty, never null",
"items": {
"$ref": "#/components/schemas/FileVersion"
},
Expand Down Expand Up @@ -63297,7 +63302,7 @@
"type": "string"
},
"playback_variants": {
"description": "Logical watch choices, each spanning one or more ordered parts",
"description": "Logical watch choices in server recommendation order: explicitly scoped file first, then the viewer's remembered edition, then standard before theatrical before other cuts, then first-part quality. playback_variants[0] is the recommended edition",
"items": {
"$ref": "#/components/schemas/WatchPlaybackVariant"
},
Expand Down Expand Up @@ -63353,7 +63358,7 @@
"description": "The acting profile's progress; absent without a profile or progress"
},
"versions": {
"description": "Every playable file of the item; empty, never null",
"description": "Every playable file of the item in server preference order (highest resolution, then HDR, then file size, with first presentation parts before later parts); empty, never null",
"items": {
"$ref": "#/components/schemas/WatchFileVersion"
},
Expand Down Expand Up @@ -63599,7 +63604,7 @@
"additionalProperties": false,
"properties": {
"default_file_id": {
"description": "Opaque identifier",
"description": "Recommended file_id for this variant (its first part's default_file_id)",
"examples": [
"1"
],
Expand All @@ -63617,7 +63622,7 @@
"type": "integer"
},
"parts": {
"description": "Ordered; empty, never null",
"description": "Ordered by part_index; empty, never null",
"items": {
"$ref": "#/components/schemas/WatchPlaybackVariantPart"
},
Expand Down Expand Up @@ -63648,7 +63653,7 @@
"additionalProperties": false,
"properties": {
"default_file_id": {
"description": "Opaque identifier",
"description": "Recommended file_id for this part (the explicitly scoped file_id when present, else versions[0])",
"examples": [
"1"
],
Expand All @@ -63664,7 +63669,7 @@
"type": "integer"
},
"versions": {
"description": "Empty, never null",
"description": "Ordered in server preference order (highest resolution, then HDR, then file size); empty, never null",
"items": {
"$ref": "#/components/schemas/WatchFileVersion"
},
Expand Down
181 changes: 181 additions & 0 deletions contracts/playback/subtitle-selection-conformance.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
{
"version": 1,
"description": "Canonical cross-client subtitle auto-selection rules shared by Web, Apple, Android, and Roku.",
"cases": [
{
"name": "off_without_forced_disables",
"mode": "off",
"preferred_language": "en",
"show_forced": false,
"audio_language": "en",
"tracks": [
{ "index": 0, "language": "en", "codec": "srt", "source": "embedded", "forced": true },
{ "index": 1, "language": "en", "codec": "srt", "source": "embedded" }
],
"expected_index": null
},
{
"name": "off_with_show_forced_selects_forced_matching_audio",
"mode": "off",
"preferred_language": "fr",
"show_forced": true,
"audio_language": "en",
"tracks": [
{ "index": 0, "language": "fr", "codec": "srt", "source": "embedded", "forced": true },
{ "index": 1, "language": "en", "codec": "srt", "source": "embedded" },
{ "index": 2, "language": "en", "codec": "srt", "source": "embedded", "forced": true }
],
"expected_index": 2
},
{
"name": "off_with_show_forced_and_unknown_audio_disables",
"mode": "off",
"preferred_language": "en",
"show_forced": true,
"audio_language": "und",
"tracks": [
{ "index": 0, "language": "en", "codec": "srt", "source": "embedded", "forced": true }
],
"expected_index": null
},
{
"name": "auto_same_language_without_forced_disables",
"mode": "auto",
"preferred_language": "en",
"show_forced": false,
"audio_language": "en",
"tracks": [
{ "index": 0, "language": "en", "codec": "srt", "source": "embedded" },
{ "index": 1, "language": "en", "codec": "srt", "source": "embedded", "forced": true }
],
"expected_index": null
},
{
"name": "auto_same_language_with_show_forced_selects_forced_not_full",
"mode": "auto",
"preferred_language": "en",
"show_forced": true,
"audio_language": "en",
"tracks": [
{ "index": 0, "language": "en", "codec": "srt", "source": "embedded" },
{ "index": 1, "language": "en", "codec": "srt", "source": "embedded", "forced": true }
],
"expected_index": 1
},
{
"name": "auto_foreign_audio_selects_full_over_forced_and_sdh",
"mode": "auto",
"preferred_language": "en",
"show_forced": true,
"audio_language": "ja",
"tracks": [
{ "index": 0, "language": "en", "codec": "srt", "source": "embedded", "forced": true },
{ "index": 1, "language": "en", "codec": "srt", "source": "embedded", "hearing_impaired": true },
{ "index": 2, "language": "en", "codec": "srt", "source": "external" },
{ "index": 3, "language": "en", "codec": "srt", "source": "embedded" }
],
"expected_index": 3
},
{
"name": "auto_prefers_non_burn_in_over_burn_in",
"mode": "auto",
"preferred_language": "en",
"show_forced": false,
"audio_language": "ja",
"tracks": [
{ "index": 0, "language": "en", "codec": "dvd_subtitle", "source": "embedded", "burn_in": true },
{ "index": 1, "language": "en", "codec": "srt", "source": "external", "burn_in": false }
],
"expected_index": 1
},
{
"name": "auto_empty_preferred_language_disables",
"mode": "auto",
"preferred_language": "",
"show_forced": true,
"audio_language": "ja",
"tracks": [
{ "index": 0, "language": "en", "codec": "srt", "source": "embedded", "forced": true },
{ "index": 1, "language": "en", "codec": "srt", "source": "embedded" }
],
"expected_index": null
},
{
"name": "always_with_show_forced_still_selects_full_dialogue",
"mode": "always",
"preferred_language": "en",
"show_forced": true,
"audio_language": "en",
"tracks": [
{ "index": 0, "language": "en", "codec": "srt", "source": "embedded", "forced": true },
{ "index": 1, "language": "en", "codec": "srt", "source": "embedded" }
],
"expected_index": 1
},
{
"name": "always_exact_track_signature_wins_even_for_forced_or_sdh",
"mode": "always",
"preferred_language": "en",
"show_forced": false,
"audio_language": "en",
"track_signature": {
"source": "embedded",
"language": "en",
"codec": "srt",
"label": "English (SDH)",
"forced": false,
"hearing_impaired": true
},
"tracks": [
{ "index": 0, "language": "en", "codec": "srt", "source": "embedded", "title": "English" },
{ "index": 1, "language": "en", "codec": "srt", "source": "embedded", "title": "English (SDH)", "hearing_impaired": true }
],
"expected_index": 1
},
{
"name": "auto_exact_track_signature_wins_over_same_language_suppression",
"mode": "auto",
"preferred_language": "en",
"show_forced": false,
"audio_language": "en",
"track_signature": {
"source": "embedded",
"language": "en",
"codec": "srt",
"label": "English (SDH)",
"forced": false,
"hearing_impaired": true
},
"tracks": [
{ "index": 0, "language": "en", "codec": "srt", "source": "embedded", "title": "English" },
{ "index": 1, "language": "en", "codec": "srt", "source": "embedded", "title": "English (SDH)", "hearing_impaired": true }
],
"expected_index": 1
},
{
"name": "source_priority_embedded_beats_external_beats_downloaded",
"mode": "always",
"preferred_language": "en",
"show_forced": false,
"audio_language": "ja",
"tracks": [
{ "index": 0, "language": "en", "codec": "srt", "source": "downloaded" },
{ "index": 1, "language": "en", "codec": "srt", "source": "external" },
{ "index": 2, "language": "en", "codec": "srt", "source": "embedded" }
],
"expected_index": 2
},
{
"name": "unplayable_tracks_are_never_selected",
"mode": "always",
"preferred_language": "en",
"show_forced": false,
"audio_language": "ja",
"tracks": [
{ "index": 0, "language": "en", "codec": "arib_caption", "source": "embedded", "unplayable": true },
{ "index": 1, "language": "en", "codec": "srt", "source": "external" }
],
"expected_index": 1
}
]
}
20 changes: 12 additions & 8 deletions docs/catalog-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,12 @@ unknown), then HDR before SDR, then the larger file. Files that start playback (
file, or a multipart presentation's first part) all come before any later part, which
follows in the same order, so `versions[0]` is a later part only when the list holds
no starting file (for example, when the viewer may access only a later part). `playback_variants`
keeps its own order: a variant comes before another when its lowest file ID is lower.
Audiobook and ebook versions keep their part and file order.
is ordered by the server for the acting viewer so `playback_variants[0]` is the recommended
default edition: an explicit remembered edition (`effective_version_edition_key`) comes first,
then `user_data.last_edition_key`, then the edition holding `user_data.last_file_id`, and
finally standard/unnamed editions before theatrical editions before other named cuts, with
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
ties preserving the variant's lowest file ID order. Watch Together room defaults reuse this
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
same ordering. Audiobook and ebook versions keep their part and file order.

For standalone movies and individual episodes, the server can group recognized
spellings of a named edition. Every present file the profile may access in the
Expand All @@ -611,12 +615,12 @@ key, and each file still reports its original `edition_raw`. Resume hints are
projected to the same edition key. Untagged files and other cuts keep their
own editions.

Clients choose the edition a detail page opens on in the same way. A picked edition
wins, then `user_data.last_edition_key`, then the edition holding
`user_data.last_file_id`. With no history, the edition is chosen by name before
quality: an unnamed or standard edition first, then a theatrical one, then any other.
Only editions in the first of those groups present are compared on quality (a file
within the quality cap, then higher resolution, then HDR), and ties keep server order.
Clients open a detail page or direct play on the server's order without re-ranking
editions or versions on the client. An explicit user pick wins; otherwise the client
opens on `playback_variants[0]` (or its remembered edition key) and chooses the first
version in that variant's active part that fits the client's local quality cap, falling
back to the variant's first version when none fits. Clients always send a concrete
`file_id` to `POST /api/v2/playback/start`.

## Device-scoped playback answers

Expand Down
1 change: 1 addition & 0 deletions internal/api/handlers/catalog_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func (h *CatalogResourceHandler) enrichItemDetail(ctx context.Context, v ItemVie
}
applyEffectiveEditionPreference(detail.SeasonUserData, &detail.EffectiveVersionEditionKey)
projectEditionPreference(detail.EditionAliases, detail.SeasonUserData, &detail.EffectiveVersionEditionKey)
catalog.OrderPlaybackVariants(detail.PlaybackVariants, v.Access.SelectedFileID, detail.EffectiveVersionEditionKey, detail.SeasonUserData)
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

detail.ViewerCurates = curates
Expand Down
7 changes: 4 additions & 3 deletions internal/api/handlers/watch_state_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ func (h *ItemsHandler) WatchDetail(ctx context.Context, userID int, profileID, c
if !h.CanViewFilePaths(ctx) {
detail.HideFileIdentity()
}
if detail.Type == itemTypeMovie || detail.Type == itemTypeEpisode {
h.populateWatchMarkers(ctx, detail, filter.SelectedFileID)
}
if detail.Type == itemTypeMovie || detail.Type == itemTypeEpisode || detail.Type == itemTypeEbook || detail.Type == itemTypeAudiobook {
detail.UserData = h.leafUserData(ctx, userID, profileID, detail.ContentID, detail.Type)
applyEffectiveEditionPreference(detail.UserData, &detail.EffectiveVersionEditionKey)
projectEditionPreference(detail.EditionAliases, detail.UserData, &detail.EffectiveVersionEditionKey)
catalog.OrderPlaybackVariants(detail.PlaybackVariants, filter.SelectedFileID, detail.EffectiveVersionEditionKey, detail.UserData)
}
if detail.Type == itemTypeMovie || detail.Type == itemTypeEpisode {
h.populateWatchMarkers(ctx, detail, filter.SelectedFileID)
}
return detail, nil
}
Expand Down
Loading
Loading