Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
2ac0a29
feat(collections): sync MDBList episode lists through the API
Rhainland Dec 6, 2026
109d2a8
fix(collections): read MDBList episodes from the list's items page
Rhainland Dec 6, 2026
b88cb7e
feat(collections): let library collections hold episodes and seasons
Rhainland Dec 6, 2026
4e9820b
feat(collections): sync MDBList seasons and store episode members
Rhainland Dec 6, 2026
6806e26
feat(collections): show episode and season members on collection pages
Rhainland Dec 6, 2026
d3a85c8
feat(collections): count episode and season members
Rhainland Dec 6, 2026
a020556
feat(collections): build collages from episode and season members
Rhainland Dec 6, 2026
fdaca08
feat(jellycompat): list episode and season members of a BoxSet
Rhainland Dec 6, 2026
eb764b7
feat(collections): page episode and season members in the catalog and…
Rhainland Dec 6, 2026
a9ab37d
docs(collections): record how collections hold episodes and seasons
Rhainland Dec 6, 2026
db66c02
refactor(collections): share the member-relation switch and skip titl…
Rhainland Dec 6, 2026
813d3b2
fix(collections): name an untitled specials season member Specials
Rhainland Dec 6, 2026
7c35344
fix(collections): match MDBList episodes and seasons by their TMDB IDs
Rhainland Dec 6, 2026
524ea40
fix(collections): keep an MDBList collection when the feed is empty a…
Rhainland Dec 6, 2026
cd33051
fix(jellycompat): keep a BoxSet's episodes under a sort and page Play…
Rhainland Dec 6, 2026
ac68f5a
fix(backup): restore a collection's episode and season members
Rhainland Dec 6, 2026
9c2d8a1
perf(collections): stop a collage's title read at its window
Rhainland Dec 6, 2026
56774e3
refactor(catalog): derive the season title fallback from one rule
Rhainland Dec 6, 2026
8d1a81a
docs(collections): record member matching, the no-key failure and Box…
Rhainland Dec 6, 2026
467cc44
test(jellycompat): read BoxSet children through a shared helper
Rhainland Dec 6, 2026
f055670
fix(collections): never match an MDBList entry by number to another T…
Rhainland Dec 6, 2026
1e6a723
fix(collections): end a keyless MDBList episode-list sync in a warning
Rhainland Dec 6, 2026
2d30c52
fix(collections): hide episode members whose files are in libraries t…
Rhainland Dec 6, 2026
28d94a7
fix(jellycompat): give BoxSet season members their poster tag
Rhainland Dec 6, 2026
f29482d
fix(collections): keep episode and season members in a library's Seri…
Rhainland Dec 6, 2026
4ea3c07
fix(jellycompat): advertise only a BoxSet season's own poster
Rhainland Dec 6, 2026
c0fd9ad
fix(collections): judge watch state per member under a Series category
Rhainland Dec 6, 2026
152c016
docs(collections): say what admins see of a keyless MDBList sync
Rhainland Dec 6, 2026
ca79e0b
feat(collections): say when an MDBList list needs the server's API key
Rhainland Dec 6, 2026
65a55ab
feat(web): warn when an MDBList list needs the server's API key
Rhainland Dec 6, 2026
dc1a67b
fix(collections): describe the keyless sync reason as the server answ…
Rhainland Dec 6, 2026
1e05918
fix(web): recheck an MDBList link after the editor reopens
Rhainland Dec 6, 2026
51583fd
fix(collections): keep previous-release title writes working during a…
Rhainland Dec 6, 2026
1ecab66
fix(collections): skip a title conflict on either unique index
Rhainland Dec 6, 2026
4cdc756
test(catalog): show the continuation index path whatever the table st…
Rhainland Dec 6, 2026
34a4825
docs(collections): say what happens after a merge loses the duplicate…
Rhainland Dec 6, 2026
b24ea93
chore(api): list the MDBList link check in the route manifest and for…
Rhainland Dec 6, 2026
0aa403f
refactor(catalog): move MDBList key and episode matching into their o…
Rhainland Dec 6, 2026
b023c74
fix(collections): stop previous-release syncs from deleting episode a…
Rhainland Dec 6, 2026
aa88f02
fix(metadata): let an episode merge drop a duplicate collection member
Rhainland Dec 6, 2026
e3bb707
docs(collections): name the statements that opt in to member deletes
Rhainland Dec 6, 2026
c4b5132
fix(mdblist): page past list items a sync skips
Rhainland Dec 6, 2026
ca4faf6
fix(jellycompat): list a BoxSet season only with an episode the viewe…
Rhainland Dec 6, 2026
7b2e542
docs(collections): say an API-read MDBList list keeps rank order
Rhainland Dec 6, 2026
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
4 changes: 2 additions & 2 deletions .silo-translations
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
platform=web
version=2026.12.05-95a7440
sha256=23d4c6836d55d337939d391d9e07fd667e7a7294117f95d2cfd7fce2df11ad9d
version=local-456ecc51d446
sha256=-
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"revision": "f546a01d7936a53eaf9f8e9cfcee85544726b7ce593dbc711ad6a44fa5084e70",
"revision": "ee4fef4069fb7fa39a6b1f5c2be57a01e9a778b40f457ceeef6cb5cf3433be27",
"state": "available",
"allowed": true,
"groups": true,
Expand All @@ -13,6 +13,7 @@
"item_reorder": true,
"template_summaries": true,
"mdblist_search": true,
"mdblist_link_check": false,
"mdblist_account_lists": false,
"schedule_time_zone": {
"utc_offset": "-05:00",
Expand Down
2 changes: 1 addition & 1 deletion contracts/api/v2/fixtures/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -6698,7 +6698,7 @@
"response_headers": {
"Cache-Control": "private, no-cache",
"Content-Type": "application/json",
"ETag": "\"1a53e61b4c2f6dac9f73962dd3d6a0cd1692be25ca0656446cbc0c6312cd6d0f\""
"ETag": "\"9c3a0bf850b85f3c5e3ebc6e8ffa334d0ac607c447add0f71d04baddf1725cd0\""
},
"response_media_type": "application/json",
"schema": "#/components/schemas/AdminCollectionCapabilityOutputBody",
Expand Down
196 changes: 196 additions & 0 deletions contracts/api/v2/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -6926,6 +6926,13 @@
"last_sync_message": {
"type": "string"
},
"last_sync_reason": {
"description": "Why the last sync read nothing, for clients to say in their own words; absent when it gives none. mdblist_api_key_required: the list syncs only with an MDBList API key the server lacks (a private list, or a list of episodes or seasons)",
"enum": [
"mdblist_api_key_required"
],
"type": "string"
},
"last_sync_status": {
"type": "string"
},
Expand Down Expand Up @@ -7123,6 +7130,13 @@
],
"type": "boolean"
},
"mdblist_link_check": {
"description": "checkAdminMDBListLink reports whether an MDBList link syncs only with an MDBList API key the server lacks",
"examples": [
true
],
"type": "boolean"
},
"mdblist_search": {
"description": "searchMDBListLists and listTopMDBListLists return lists; false when the server has no MDBList API key",
"examples": [
Expand Down Expand Up @@ -7170,6 +7184,7 @@
"item_reorder",
"template_summaries",
"mdblist_search",
"mdblist_link_check",
"mdblist_account_lists",
"schedule_time_zone",
"section_references",
Expand Down Expand Up @@ -7690,6 +7705,13 @@
"message": {
"type": "string"
},
"reason": {
"description": "Why the sync read nothing, as last_sync_reason on the collection; absent when it gives none",
"enum": [
"mdblist_api_key_required"
],
"type": "string"
},
"started_at": {
"description": "RFC 3339 instant in UTC with millisecond precision",
"format": "date-time",
Expand Down Expand Up @@ -18172,6 +18194,22 @@
],
"type": "object"
},
"AdminMDBListLinkOutputBody": {
"additionalProperties": false,
"properties": {
"needs_api_key": {
"description": "A server collection following the link syncs only with an MDBList API key the server lacks: MDBList's public feed refuses the list (a private list) or lists nothing (a list of episodes or seasons). False whenever the server has a key",
"examples": [
true
],
"type": "boolean"
}
},
"required": [
"needs_api_key"
],
"type": "object"
},
"AdminMarkerCapabilities": {
"additionalProperties": false,
"properties": {
Expand Down Expand Up @@ -86404,6 +86442,164 @@
"x-silo-service-backed": true
}
},
"/api/v2/admin/collections/mdblist/link": {
"get": {
"operationId": "checkAdminMDBListLink",
"parameters": [
{
"description": "Optional. When present, it must name the authenticated account's primary profile; an absent header is accepted.",
"in": "header",
"name": "X-Profile-Id",
"schema": {
"examples": [
"1"
],
"type": "string"
}
},
{
"description": "Verification proof for a PIN-locked profile, issued by POST /api/v2/profiles/{id}/verify-pin; required only when the declared profile is locked",
"in": "header",
"name": "X-Profile-Token",
"schema": {
"examples": [
"pvt_5f3a9c1e7b2d4e8fa0c6"
],
"type": "string"
}
},
{
"description": "The MDBList list link an administrator pasted",
"explode": false,
"in": "query",
"name": "url",
"required": true,
"schema": {
"description": "The MDBList list link an administrator pasted",
"examples": [
"https://mdblist.com/lists/alice/holiday-episodes"
],
"format": "uri",
"maxLength": 2048,
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/AdminMDBListLinkOutputBody"
}
}
},
"description": "OK"
},
"400": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/Problem"
}
}
},
"description": "Bad Request"
},
"401": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/Problem"
}
}
},
"description": "Unauthorized"
},
"403": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/Problem"
}
}
},
"description": "Forbidden"
},
"404": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/Problem"
}
}
},
"description": "Not Found"
},
"406": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/Problem"
}
}
},
"description": "Not Acceptable"
},
"422": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/Problem"
}
}
},
"description": "Unprocessable Entity"
},
"429": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/Problem"
}
}
},
"description": "Too Many Requests"
},
"500": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/Problem"
}
}
},
"description": "Internal Server Error"
},
"503": {
"content": {
"application/problem+json": {
"schema": {
"$ref": "#/components/schemas/Problem"
}
}
},
"description": "Service Unavailable"
}
},
"security": [
{
"bearerAuth": []
}
],
"summary": "Report whether a server collection following an MDBList link syncs only with an MDBList API key the server lacks. Reads the list's public feed once when the server has no key.",
"tags": [
"admin-collections"
],
"x-silo-class": "acting_admin",
"x-silo-service-backed": true
}
},
"/api/v2/admin/collections/mdblist/lists": {
"get": {
"operationId": "listAdminMDBListLists",
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture/api-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -1642,7 +1642,7 @@ answered empty (see catalog-home); `getLibrarySectionItems` answers the section
wrapper, and
`getLibraryCollections` has one shape whether or not collection groups are configured.

`getLibraryCollectionItems` pages manual membership by `(position, media_item_id)` and
`getLibraryCollectionItems` pages manual membership by `(position, member_id)` and
smart results by the executor's complete SQL sort tuple. Collection-specific durable revisions
reject continuation after definition, membership, or collection-access changes. Membership and
its revision are read in one database snapshot; authorization and catalog hydration are fenced
Expand Down
117 changes: 117 additions & 0 deletions docs/architecture/collection-members.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
# Episode and season members of library collections

A library collection holds titles (movies and series). A synced MDBList
collection can also hold episodes and seasons, because an MDBList list can
name them (a list of Christmas episodes, say). This note records how that
works; the client contract is in
[catalog-api.md](../catalog-api.md#episode-and-season-members).

## Storage

- `library_collection_items` has one column per member kind: `media_item_id`
for a title, `episode_id` for an episode, `season_id` for a season. Exactly
one is set, and the generated `member_id` is that one. The primary key and
the order and continuation indexes use `member_id`. A partial index on
`collection_id` where `media_item_id IS NULL` finds a collection's episode
and season members, so readers of a titles-only collection skip them cheaply.
- Each column has its own foreign key with `ON UPDATE CASCADE ON DELETE
CASCADE`, so a content-ID rekey or a delete of the episode, season, or title
moves or removes the member. The provider-ID merge conflicts on
`(collection_id, member_id)`; `reattribute` moves title and episode members
per column (`media_item_id`, `episode_id`).
- A unique index on `(collection_id, media_item_id)` stays beside the primary
key for servers of the previous release during a rolling upgrade: their
title writes use `ON CONFLICT (collection_id, media_item_id)`, which needs
it. Episode and season rows leave `media_item_id` NULL and never collide
there. Those servers still cannot read a collection that holds episodes or
seasons, but only an upgraded server's sync creates one.
`TestPreviousReleaseCollectionWritesStillWorkDB` runs their writes verbatim.
- Those servers also replace a collection's members by deleting every row
whose `media_item_id` their list leaves out, which would empty an episode
collection they sync. The trigger `library_collection_items_guard_member_delete`
refuses a direct delete of an episode or season member unless the
transaction set `silo.collection_member_writes`, so their sync fails and the
members stay until an upgraded server syncs it. Deletes cascading from an
episode, season or collection run nested in another trigger and go through.
Every statement in this release that can directly delete an episode or
season member (`ReplaceItems`, `RemoveManualItem`, and the episode-merge
dedupe in `reattribute`) calls `AllowCollectionMemberDeletes` first; a new
one that doesn't fails on those members. `TestPreviousReleaseReplaceKeepsEpisodeAndSeasonMembersDB` runs the
old replace against them. A later release can drop the trigger once
upgrades from the release before episode members are no longer supported.
With two unique indexes on a title, an `ON CONFLICT` that names one still
fails on the other when a concurrent transaction inserts the same title, so
the current release's skip-if-present inserts use `ON CONFLICT DO NOTHING`
with no target. The provider-ID merge is an upsert, needs a target, and takes
no collection lock, so it keeps that narrow race: a merge that moves a title
into a collection while a sync or add inserts the same title there can fail
once, on either side. A failed sync is redone by the next sync; a failed
merge returns its error to the metadata refresh or repair task that ran it,
and runs again only when one of those finds the duplicate again.
- In Go a member's kind is `""` (title), `CollectionMemberEpisode`, or
`CollectionMemberSeason`.
- The migration's Down removes every episode and season member, since the
table it restores holds titles only.

## Sync

- MDBList's public `/json` feed leaves episodes and seasons out, so a list of
them reads empty there. An empty feed answer is read again through the
MDBList API (`/lists/{id}/items`) with the server's key, which returns
`episodes` and `seasons`, each with its own TMDB ID (`id`), its show's TMDB
ID and TMDB's numbers. The API answer comes in MDBList's rank order and
is cut by rank to the read limit the collection's item limit sets. The
link's `sort` (such as `sort=usort`, Custom Order), which the feed
follows, doesn't reach it, so a public list of episodes or seasons comes
in rank order, as a private list does. Each sync of an empty list spends
API reads from
the key's daily quota: one per page of items, plus one to resolve an
owner-and-slug URL. Without a server key the sync ends in a warning and
keeps the members it had, since an empty feed says nothing about the list;
an import still creates the collection. The v2 admin API reports it as
`last_sync_reason` `mdblist_api_key_required`, and `checkAdminMDBListLink`
warns before the collection is created (see
[catalog-api.md](../catalog-api.md#mdblist-lists-that-need-a-key)).
- A list that also holds movies or shows has a non-empty feed, so it syncs
from the feed and its episodes and seasons are left out.
- A personal collection reads through the profile's watch-provider
connection, which returns no episodes either, so personal collections hold
titles only.
- Within the series matched by the show's TMDB ID, an episode matches by its
TMDB ID first, which holds however the library numbers the series, then by
its provider numbers (`provider_season_number`, `provider_episode_number`),
falling back to the shown numbers for a row without provider numbers, the
same probes as `GetBySeriesAndProviderNumber`. A season matches the same
way, though seasons rarely carry a TMDB ID, so in practice by number. A
number probe skips a row whose TMDB ID differs from the entry's, and
unlisted episodes never match. Episodes from a provider that writes no TMDB
IDs (the TVDB plugin) match by number only, so a series the library numbers
differently from TMDB can match the wrong episode.

## Reading members

- A viewer sees an episode or season member when they can see its series:
library access is checked on the series, and maturity and excluded types
apply to the series row. An episode also needs an `episode_libraries` row
in the collection's libraries and one in a library the viewer may open, so
a series spanning libraries never lists an episode they can't play; a
season needs an episode on disk, in such a library for a restricted viewer. The
relations live in `internal/catalog/collection_members.go`, and every
surface uses them: the card count, the collage, the collection page and
catalog cursor, home rows, shuffle, and the jellycompat BoxSet.
- A media scope on a collection page treats an episode or season member as
standing in for its series: a library's Series category, which Roku and
Android TV pass, keeps them, and its Movies category leaves them out.
- The catalog cursor only switches to the mixed member relation when a
collection holds an episode or season member, so a titles-only collection
keeps its plain title query.
- Cards name their series and numbers (`S30E10`, or the season number).
jellycompat lists an episode member as an `Episode` and a season member as
a `Season`; Play all plays an episode member as itself and a season member
as its visible episodes, each episode once. Catalog browse reads titles
only, so a BoxSet request with a sort keeps curated order for a collection
that holds episodes or seasons, and one with an item-type or member filter
lists its titles only.
- A selective restore finds a collection's members among titles, episodes and
seasons, and adds the missing ones in any of the three columns.
- The collection page's filter options come from title members only.
Loading
Loading