Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ Log a short fixed message and put the values in `extra`: `log.info("poster uploa
| `build_fonts.py` | Fetches the fallback fonts for scripts Inter lacks. | Internet |
| `build_networks.py` | Rebuilds `assets/networks.json` and `assets/provider_networks.json` from TMDB. | `TMDB_API_KEY` |
| `ocr_readings.py` | Adds real OCR readings to `tests/ocr_readings.json`. | `TMDB_API_KEY` |
| `unraid_template.py` | Writes the settings help and `<Changes>` in `templates/posteryard.xml` from `README.md` and `CHANGELOG.md`. `--check` exits 1 when the settings are out of date. | |
| `dockerhub_description.py` | Prints `README.md` as the Docker Hub overview. | |

Run each with `uv run python tools/<script>`.

Expand Down
9 changes: 8 additions & 1 deletion src/posteryard/plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,14 @@ def _guide_walk(self, provider: str) -> list[set[str]]:
batches: list[set[str]] = []
while len(batches) < GUIDE_ID_BATCHES:
start = 1 + len(batches) * GUIDE_IDS
guids = self._guide_guids(provider, start, start + GUIDE_IDS)
try:
guids = self._guide_guids(provider, start, start + GUIDE_IDS)
except http.RequestError as exc:
log.warning(
"the guide ids could not all be read, some titles may get no poster",
extra={"ids": start - 1, "reason": str(exc)},
)
return batches
if not guids:
return batches
batches.append(guids)
Expand Down
18 changes: 18 additions & 0 deletions tests/test_plex.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,24 @@ def test_guide_ids_past_the_limit_are_not_read(
assert "more entries than are read" in caplog.text


def test_guide_ids_are_not_read_again_after_an_error(caplog: pytest.LogCaptureFixture) -> None:
plex, asked = guide_by_id({n: f"g/{n}" for n in range(1, 700)})
get = plex._get

def failing(path: str, **params: Any) -> Any:
if path.endswith(",600"):
asked.append(path)
raise http.HttpError(500, path)
return get(path, **params)

plex._get = failing # type: ignore[method-assign]
assert plex.guide_target(GUIDE, SHOW, "g/100") == "100"
asked.clear()
assert plex.guide_target(GUIDE, SHOW, "g/450") is None
assert len(asked) == 1
assert "could not all be read" in caplog.text


def test_guide_target_is_none_for_an_entry_without_a_guid() -> None:
plex, asked = guide_by_id({1: ""})
assert plex.guide_target(GUIDE, SHOW, "") is None
Expand Down