Documentation
¶
Overview ¶
Package mediasource is what subflux learns from its media sources (Sonarr, Radarr): the facts a source reports about its series and movies, its change cursor, and the errors every source call answers with.
Index ¶
- Variables
- type Capabilities
- type Catalogue
- type CatalogueEpisode
- type CatalogueOrder
- type Cause
- type Change
- type Cursor
- type EpisodeTitle
- type ExtraPlace
- type Item
- type JoinQuery
- type Joined
- type Listed
- type NativeID
- type NativeRef
- type Order
- type Place
- type Root
- type RootEvidence
- type SeriesEvidence
- type SourceError
- type TagRef
- type TitleSet
Constants ¶
This section is empty.
Variables ¶
ErrAiredOrderUnavailable wraps a join for a series in another order whose list agrees with no SkyHook reading; the Set reports its root unread, so nothing under it is retired or written.
var ErrRescanOutcomeUnknown = errors.New("rescan outcome unknown")
ErrRescanOutcomeUnknown wraps a Rescan the source may have run; the caller never sends it again.
Functions ¶
This section is empty.
Types ¶
type Capabilities ¶
Capabilities are what a source can do beyond listing its library.
type Catalogue ¶
type Catalogue struct {
// Fetched is when SkyHook answered this reading's order requests.
Fetched time.Time
// Orders lists every order but the aired one and "absolute".
Orders []CatalogueOrder
// Episodes are the aired order, SkyHook's "official" answer.
Episodes []CatalogueEpisode
TVDB uint64
}
Catalogue is one SkyHook reading of a TVDB series' episode orders. Places and air dates are the same in every language, so it holds no title.
func (Catalogue) Reordered ¶
Reordered is the order index of a catalogue Validate accepts: some order moves a regular episode. Whether an order is listed says nothing; most DVD orders move none.
func (Catalogue) Validate ¶
Validate refuses a series or episode id media.ValidExternalID refuses, a repeated episode id, a season or episode media.ValidEpisodeNumber refuses, an air date neither "" nor YYYY-MM-DD, a repeated or empty order type, an "official" or "absolute" one, Places not parallel to Episodes, and Extra out of order. Two Extra entries may share a place, as two Places may.
type CatalogueEpisode ¶
type CatalogueEpisode struct {
// AirDate is YYYY-MM-DD, or "" when SkyHook lists none.
AirDate string
// ID is the TVDB episode id, SkyHook's metadataId, distinct in a catalogue.
ID uint64
// Season, Episode and Absolute are aired; Absolute is 0 when none.
Season, Episode, Absolute int
}
CatalogueEpisode is one episode of the aired order.
type CatalogueOrder ¶
type CatalogueOrder struct {
Type, Name string
// Places is parallel to Catalogue.Episodes.
Places []Place
// Extra are the order's episodes the aired list lacks, ascending by season
// and episode.
Extra []ExtraPlace
}
CatalogueOrder is one order's places for the catalogue's episodes.
type Cause ¶
type Cause uint8
Cause is why a source call failed.
type Change ¶
type Change struct{ Root NativeRef }
Change names a root whose items may have changed, a deletion included.
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor is a source's change position, opaque to all but the adapter that wrote it, which reads its own format version from the bytes and answers Expired for a version it cannot read. The zero Cursor asks for the head.
func (Cursor) MarshalBinary ¶
MarshalBinary returns a copy of the cursor's bytes, none for the zero Cursor.
func (*Cursor) UnmarshalBinary ¶
UnmarshalBinary keeps a copy of b, refusing nothing, so a stored cursor in an unreadable format reaches the adapter's Expired rather than failing every read of it. Empty b is the zero Cursor.
type EpisodeTitle ¶
EpisodeTitle is one episode's title in a TitleSet's language.
type ExtraPlace ¶
type ExtraPlace struct {
// AirDate is YYYY-MM-DD, or "" when SkyHook lists none.
AirDate string
Season, Episode int
}
ExtraPlace is an order's place for an episode the aired list lacks; such an episode can agree with a source's list but has no aired key.
type Item ¶
type Item struct {
// AudioLangs are the file's audio tracks, in track order.
AudioLangs []language.Tag
Tags []TagRef
Native NativeID
Title string
// AirDate is YYYY-MM-DD as the source lists it; "" while unaired.
AirDate string
VideoPath, SceneName string
OriginalLang language.Tag
External media.ExternalIDs
// Numbering is the episode's place in TVDB's aired order, the one its key
// is chosen by; the Set sets it from the aired join, overwriting any
// adapter's value.
Numbering media.Numbering
// SeriesNumbering is the episode's place in Root.Order, as the source
// lists and names it; it equals Numbering under the aired order.
SeriesNumbering media.Numbering
// Absolute is the aired absolute number, 0 when none: the source's own
// under the aired order, the join's under any other.
Absolute int
// Excluded is set by the Set alone, from the source's exclude tags.
Excluded bool
}
Item is one episode or movie of a Root, whose kind it shares.
type JoinQuery ¶
type JoinQuery struct {
// Episodes are in the series' order.
Episodes []Listed
// Source and Root name the root whose stored evidence the join reads.
Source media.SourceID
Root NativeRef
Language language.Tag
Order Order
TVDB uint64
}
JoinQuery is one series as a source lists it, for the Set's aired join.
type NativeID ¶
type NativeID string
NativeID is a source's own id for a root or item: 1 to 64 bytes of [A-Za-z0-9._:-], canonical decimal on Sonarr and Radarr. It is never identity; media.Key is.
type Order ¶
Order is a series' episode order as its source names it; a movie's is zero. Name is "" while the source names none, and Aired means the order's numbers are TVDB's aired order.
type Place ¶
Place is an episode's season and episode in one order; Listed is false when the order leaves the episode out.
type Root ¶
type Root struct {
// Evidence is the root's SkyHook evidence from the aired join, nil when
// none.
Evidence *RootEvidence
AltTitles []string
Title string
// Link is the root's page in the source's web UI, under public_url, else
// url: an absolute http or https URL, or "".
Link string
// Language is the series' metadata language, zero when the source reports
// none; the aired join asks SkyHook in it.
Language language.Tag
Order Order
Native NativeRef
External media.ExternalIDs
// Year is the series' or movie's year, 0 when the source gives none.
Year int
}
Root is a series or a movie as its source reports it.
type RootEvidence ¶
type RootEvidence struct {
Held *SeriesEvidence
Bound SeriesEvidence
}
RootEvidence is one root's evidence: Bound, the chosen reading (under any order but the aired one, the reading its stored keys came from), and Held, a later reading its source's list has not agreed with, nil when none.
func (RootEvidence) Validate ¶
func (r RootEvidence) Validate() error
Validate refuses an invalid reading, title sets repeated or out of order by Language, a title for an id its catalogue lacks, and a Held for another TVDB id or fetched no later than Bound.
type SeriesEvidence ¶
SeriesEvidence is one reading, never a mix: its catalogue and its title sets, ascending by Language, each holding the catalogue's aired episodes.
type SourceError ¶
SourceError is every failure of a source call. Op is the method name.
func (*SourceError) Error ¶
func (e *SourceError) Error() string
Error is "source <id> <op>: <cause>: <err>", leaving out an unset Source, Op or Err.
func (*SourceError) Unwrap ¶
func (e *SourceError) Unwrap() error
Unwrap returns Err, so errors.Is and httpx.IsTransient see the cause.
type TitleSet ¶
type TitleSet struct {
// Language is an ISO 639-2/T code.
Language string
// Titles ascend by ID.
Titles []EpisodeTitle
// Found is false when SkyHook answered 404 for Language.
Found bool
}
TitleSet is one language's episode titles of a reading; an episode with no title in Language is absent.
func (TitleSet) Validate ¶
Validate refuses a Language that is not three ASCII lowercase letters, a title when Found is false, an empty title, and ids media.ValidExternalID refuses or not strictly ascending.