Documentation
¶
Overview ¶
Package mediaid builds the stable identifier subflux addresses one media item by: "tmdb-27205" for a movie, "tvdb-121361-s01e09" for an episode, plus the prefixes that select a whole season or series in one scan.
The identifier is the bbolt key for every per-item row (search_attempts, subtitle_state, scan_state, backoff) and a path segment in the HTTP API, so the format here is storage and wire contract in both directions: Episode and SeasonPrefix must agree through the episode separator or a season's rows stop being one prefix scan, and ValidPrefix is what keeps a client-supplied prefix from selecting arbitrary rows.
Separate from the subtitle FILENAME builders even though both spell a media item's name: those address a file on a filesystem shared with Windows clients and this addresses a row in a database, and of the nine consumers only manualops and search use both.
Index ¶
- func Build(req *subflux.SearchRequest) string
- func Episode(tvdbID int, imdbID string, ep SeasonEpisode) string
- func Movie(tmdbID int, imdbID string) string
- func SeasonPrefix(tvdbID int, imdbID string, season int) string
- func SeriesPrefix(tvdbID int, imdbID string) string
- func ValidPrefix(prefix string) bool
- type SeasonEpisode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build(req *subflux.SearchRequest) string
Build creates a stable identifier for a media item from a search request. Movies use TMDB ID (canonical for Radarr), episodes use TVDB ID (canonical for Sonarr). IMDB is only used as a last resort fallback.
func Episode ¶
func Episode(tvdbID int, imdbID string, ep SeasonEpisode) string
Episode returns the canonical media ID for an episode. Prefer TVDB (Sonarr's canonical source), fall back to IMDB.
func Movie ¶
Movie returns the canonical media ID for a movie. Prefer TMDB (Radarr's canonical source), fall back to IMDB.
func SeasonPrefix ¶
SeasonPrefix returns the media ID prefix shared by every episode of one season, mirroring Episode's format through the episode separator (e.g. "tvdb-123-s05e"). Episode(tvdb, imdb, SeasonEpisode{season, N}) has this prefix for every N in 0-99, so backoff and state rows for a season are one prefix scan. Returns "" when neither ID is available (matching Episode's unidentified-media fallback shape only per season would be meaninglessly broad).
func SeriesPrefix ¶
SeriesPrefix returns the media ID prefix for all episodes of a series. Used by coverage and missing-count queries to match all episodes via LIKE.
func ValidPrefix ¶
ValidPrefix checks that a prefix parameter matches expected media ID formats. Prevents arbitrary prefix queries that could produce confusing results if the app is exposed without auth.
Types ¶
type SeasonEpisode ¶
SeasonEpisode is one episode's position inside a series. The two numbers always travel together and as adjacent int parameters they were silently transposable: s09e01 and s01e09 are both well-formed IDs, so a swap writes a valid-looking primary key for a DIFFERENT episode instead of failing. Build it with keyed fields — an unkeyed literal reintroduces the hazard.