From bf32ea9b218cd93044e59956b9b451c5f160a7b3 Mon Sep 17 00:00:00 2001 From: blurbery <271863866+blurbery@users.noreply.github.com> Date: Wed, 18 Nov 2026 10:36:43 +1100 Subject: [PATCH] fix(silo): read ids from Silo's catalog cards and show why Silo refused a request Silo's v2 catalog cards carry the title's TMDB, IMDb and TVDB ids since Silo-Server/silo-server#3618, so shows no longer need a detail lookup each and a film Silo knows by its IMDb id matches by its TMDB id too. Builds without ids on their cards are looked up as before. Silo puts the reason for a refused field in errors[].detail, which CineSets dropped, so a collection name another one in the library already has (Silo-Server/silo-server#3933, case aside) only said "see errors". Those reasons now show, and a collection a Home or library section still uses says to take it out of the section first. CI now runs against Silo build 2519 (was 1144, from before /api/v1 was retired), Jellyfin 12.4 and Emby 4.10.2.0. --- .github/workflows/ci.yml | 6 +++--- cinesets/servers/silo.py | 19 ++++++++++++++++--- docs/setup.md | 2 +- tests/e2e/run_silo_e2e.py | 2 +- tests/test_silo.py | 31 ++++++++++++++++++++++++++++++- 5 files changed, 51 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 658aeb2..45e4480 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -93,9 +93,9 @@ jobs: server: - {name: "Jellyfin 10.10", kind: jellyfin, image: "jellyfin/jellyfin:10.10.7"} - {name: "Jellyfin 10.11", kind: jellyfin, image: "jellyfin/jellyfin:10.11.11"} - - {name: "Jellyfin 12.2", kind: jellyfin, image: "jellyfin/jellyfin:12.2"} + - {name: "Jellyfin 12.4", kind: jellyfin, image: "jellyfin/jellyfin:12.4"} - {name: "Emby 4.9", kind: emby, image: "emby/embyserver:4.9.5.0"} - - {name: "Emby 4.10", kind: emby, image: "emby/embyserver:4.10.1.0"} + - {name: "Emby 4.10", kind: emby, image: "emby/embyserver:4.10.2.0"} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: @@ -124,7 +124,7 @@ jobs: fail-fast: false matrix: silo: - - {name: "build 1144", image: "ghcr.io/silo-server/silo-server:build-1144"} + - {name: "build 2519", image: "ghcr.io/silo-server/silo-server:build-2519"} steps: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 with: diff --git a/cinesets/servers/silo.py b/cinesets/servers/silo.py index 77cbb9c..514b4b7 100644 --- a/cinesets/servers/silo.py +++ b/cinesets/servers/silo.py @@ -148,12 +148,19 @@ def problem(cls, r): body = None silo = isinstance(body, dict) # Silo answers with problem JSON; anything else is from something in front of it detail = (str(body.get("detail") or body.get("title") or "") if silo else r.text)[:200] + # A refused field only says "see errors" in detail, and the reason is in errors[].detail: since November 2026 + # (Silo-Server/silo-server#3933) that includes a collection name another one in the library has, case aside + reasons = [str(e.get("detail") or "") for e in (body.get("errors") or []) if isinstance(e, dict)] if silo else [] + if any(reasons): + detail += " (" + "; ".join(x for x in reasons if x)[:200] + ")" if r.status_code == 401: detail += (f" (Silo did not accept the API key: make one under {cls.KEY_PAGE} that belongs to an " "administrator and has no scopes, and put it in server.api_key)") elif r.status_code == 403: detail += (" (CineSets needs an API key that belongs to an administrator and has no scopes: make one under " f"{cls.KEY_PAGE} in Silo and put it in server.api_key)") + elif r.status_code == 409 and "section" in detail.lower(): + detail += " (take the collection out of that Home or library section in Silo first, then run CineSets again)" elif r.status_code == 404 and not silo: detail = ("(nothing answered there, so server.url is probably not Silo's own address: use the one its web " "app opens on, not its Jellyfin-compatible port)") @@ -237,13 +244,19 @@ def library_items(self, folder, kind, name): typ = "movie" if kind == "movie" else "series" cards = self.pages(f"/catalog?library_id={quote(folder)}&type={typ}&sort=title&skip_total=true" f"&image_size=small&limit={PAGE}", headers=self.profile()) - out, seen = [], set() + out, seen, carded = [], set(), set() for c in cards: cid = c.get("content_id") if not cid or cid in seen: continue seen.add(cid) - out.append({"id": cid, "name": c.get("title"), "year": c.get("year"), "ids": content_ids(cid), + # Silo builds from 6 November 2026 (Silo-Server/silo-server#3618) put the title's provider ids on its card, + # the same ones its item details give, so a show needs no lookup and a film known by its IMDb id learns + # its TMDB one. Older builds leave them off, and their shows are looked up as before. + card = {k: v for k in ("tmdb", "imdb", "tvdb") for v in [provider_id(c.get(f"{k}_id"))] if v} + if card: + carded.add(cid) + out.append({"id": cid, "name": c.get("title"), "year": c.get("year"), "ids": {**card, **content_ids(cid)}, "backdrop": bool(c.get("backdrop_url") or c.get("backdrop_thumbhash")), "poster": bool(c.get("poster_url") or c.get("poster_thumbhash")), "genres": c.get("genres") or []}) @@ -253,7 +266,7 @@ def library_items(self, folder, kind, name): self._where.setdefault(it["id"], []).append(folder) save_json(self.where_file, self._where) if kind == "show": - self.add_show_ids(out, name) + self.add_show_ids([it for it in out if it["id"] not in carded], name) return out def where(self): diff --git a/docs/setup.md b/docs/setup.md index fd3c26b..2ef9230 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -18,7 +18,7 @@ Back to the [README](../README.md). Running more than one server? Give each its own install: its own folder, `config.yml`, `data/` and schedule. They share nothing, so one can't affect another, and each install only loads the code for its own server. -Every change is tested against real Emby 4.9 and 4.10, Jellyfin 10.10, 10.11 and 12.2, and a pinned Silo build, +Every change is tested against real Emby 4.9 and 4.10, Jellyfin 10.10, 10.11 and 12.4, and a pinned Silo build, and each week against the newest release of each. Emby is fully supported; Jellyfin and Silo are beta until more people have run them. Plex is next. diff --git a/tests/e2e/run_silo_e2e.py b/tests/e2e/run_silo_e2e.py index 4dd3f1e..12ecf2c 100644 --- a/tests/e2e/run_silo_e2e.py +++ b/tests/e2e/run_silo_e2e.py @@ -11,7 +11,7 @@ folder names, and .nfo files give them genres, their other ids and artwork, so nothing depends on online lookups), then runs `cinesets setup` as a new user would, given Silo's Jellyfin-compatible port. Then it checks that CineSets creates manual library collections matched by IMDb, TMDb and TVDB ids (one with a genre left out, one matched by a -show's IMDb id, which only Silo's item details have), with the right titles, libraries, description, display order, +show's IMDb id, which older Silo builds give only in item details), with the right titles, libraries, description, display order, page order and poster. It shrinks and renames them, changes nothing on a repeat run, takes them back with adopt after losing its record, refuses to touch a collection it did not create and removes only its own. """ diff --git a/tests/test_silo.py b/tests/test_silo.py index 14eef34..9dfb524 100644 --- a/tests/test_silo.py +++ b/tests/test_silo.py @@ -99,6 +99,7 @@ def __init__(self): self.rate_limit = 0 self.not_admin = False self.no_poster = {"movie-imdb-tt0133093"} # a title Silo has no poster for + self.card_ids = False # builds from 6 November 2026 put provider ids on catalog cards def add_collection(self, title, lib, kind="manual"): cid = str(self.next_id) @@ -139,7 +140,8 @@ def request(self, method, url, timeout=None, allow_redirects=True, headers=None, assert headers.get("X-Profile-Id") == "77", "the catalogue needs the profile header" typ = "movie" if q["type"] == "movie" else "series" rows = [{"content_id": cid, "type": typ, "title": it["title"], "year": it["year"], "genres": it["genres"], - "backdrop_thumbhash": "x", **({"poster_thumbhash": "p"} if cid not in self.no_poster else {})} + "backdrop_thumbhash": "x", **({"poster_thumbhash": "p"} if cid not in self.no_poster else {}), + **(it["ids"] if self.card_ids else {})} for cid, it in self.items.items() if it["lib"] == q["library_id"] and cid.startswith(typ)] return Resp(data=self.page(rows, q)) if parts[:2] == ["catalog", "items"]: @@ -322,6 +324,33 @@ def test_show_ids_are_looked_up_once(silo_run): assert "Concerts" not in json.dumps(silo_run.fake.calls) +def test_newer_silo_gives_the_ids_on_its_cards(silo_run): + """Silo builds from 6 November 2026 put provider ids on catalog cards: no show is looked up, and a film Silo knows + by its IMDb id also matches by its TMDB one.""" + fake = silo_run.fake + fake.card_ids = True + fake.items["movie-imdb-tt0133093"]["ids"] = {"tmdb_id": "603", "imdb_id": "tt0133093"} + cfg, srv, eng = silo_run() + index = eng.build_index() + assert not [c for c in fake.calls if c[1].startswith("/catalog/items/")] + assert index["show"]["imdb"]["tt0944947"] == "series-tvdb-121361" + assert index["show"]["tmdb"]["1399"] == "series-tvdb-121361" # 1399-game-of-thrones, kept as the number + assert index["show"]["tvdb"]["305288"] == "series-tvdb-305288" + assert index["movie"]["tmdb"]["603"] == "movie-imdb-tt0133093" # never known before cards had ids + + +def test_silo_says_why_it_refused(silo_run): + """A refused field's reason is only in errors[].detail, and a collection a section uses can't be deleted.""" + cfg, srv, eng = silo_run() + clash = Resp(422, {"title": "Unprocessable Entity", "detail": "The request did not pass validation; see errors.", + "errors": [{"detail": "A collection named movies - marvel already exists in this library", + "location": "body.title"}]}) + assert "already exists in this library" in srv.problem(clash) + in_use = Resp(409, {"title": "Conflict", "detail": "The collection is used by a section"}) + assert "take the collection out of that Home or library section" in srv.problem(in_use) + assert srv.problem(Resp(409, {"title": "Conflict", "detail": "Not a manual collection"})) == "Not a manual collection" + + def test_titles_silo_no_longer_has_are_skipped(silo_run, capsys): cfg, srv, eng = silo_run() eng.get_index()