feat(api): series, season and episode endpoints #81
Reference in New Issue
Block a user
Delete Branch "issue/39-series-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Implements the API half of #39. The UI half is left out — see below.
Adds the series equivalents of the movie endpoints, plus season and
episode granularity:
/api/seriesCRUD, each response carrying a status derived from itsepisodes (§4.2) rather than a stored column.
/api/series/{id}/seasons— read, and create the season a metadatarefresh reveals. Creation runs
arr_core::tracking::apply_auto_trackinstead of taking
wantedfrom the request, so the §4.1 rule stays inone place.
PATCHon a season setstrackedandwantedindependently:trackedis the rule for episodes not yet revealed,wantedis theone-click season grab written onto the episodes already there.
PATCH /api/episodes/{id}sets the only intent the aggregate carries./api/episodes/{id}/search,/releasesand/releases/{id}/grab,plus owner tags on series.
GET /api/releasesnow takesmovie_idorepisode_id; passingboth or neither is a 422.
Two things worth knowing:
arr-db'sMoviePolicyis nowTitlePolicy, withMoviePolicykept asan alias so
arr-daemonis untouched. Episodes needed the same loaderand the old name had become a lie.
The series table has no TVDB ID, so an episode search cannot use
t=tvsearch&tvdbid=;tv_requestfalls back to a text search carryingthe
SxxEyytag. That is the documented fallback (§6.1), but ID searchstays unavailable until TV metadata refresh lands and can populate one.
The UI is not in this PR. The issue says the UI reuses the phase 5
components — buckets, chips, derived status. Those are #31, #32 and #33,
all still open, so there is nothing to reuse yet and building them here
would be implementing three other issues inline. Series views should
follow once they land.
Verification
just cigreen locally: fmt, clippy-D warnings, machete, 208 tests,biome and tsc.
New tests cover auto_track deciding whether a revealed season arrives
wanted, season versus single-episode intent, the derived status changing
as an episode is imported, blocked stopping episode search, grab scoping
to the episode's own releases, owner filtering, cascade on delete, and
the episode manual search reaching the indexer as
q=Bluey S01E02.@@ -0,0 +613,4 @@apply_auto_track(&core_series(&series), &mut revealed);let [revealed] = revealed;let season_id = sqlx::query!(Creating the season and its episodes is not atomic. Duplicate episode numbers insert the season and earlier episodes before the unique constraint returns 500, so a retry cannot create the intended season. Validate duplicates before writing or use a transaction.
Fixed in
2e14e0b. Duplicate episode numbers are now a 422 checked beforeanything is written, and the season plus its episodes insert inside one
transaction, so a rejected request leaves the season number free for the
retry.
Test covers it: the duplicate body is rejected,
seasonsis still emptyafterwards, and the corrected retry succeeds.
Reviewed
2e14e0b19cfcf2c25baa045d975bdc7a5489bf40. No findings.