Documentation
¶
Overview ¶
Package media is subflux's identity: the key an episode or movie is stored, matched and served by. A key derives from an external id (TVDB, TMDB or IMDb) and an episode's aired numbering, never from a source's own ids, so two sources naming one item agree on its key.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ValidEpisodeNumber ¶
ValidEpisodeNumber reports whether n lies in 0 to 65,535, the seasons and episodes a key holds; season 0 holds specials.
func ValidExternalID ¶
ValidExternalID reports whether id lies in 1 to 2^53-1, the ids a key holds, so every id survives a round trip through a JavaScript number on the wire.
Types ¶
type ExternalIDs ¶
type ExternalIDs struct{ TVDB, TMDB, IMDb uint64 }
ExternalIDs are an item's ids per scheme; 0 is unknown. IMDb's is numeric: tt0111161 is 111161.
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key names a movie or one episode of a series. Only Choose and ParseKey build one, so every non-zero Key is valid; a movie's season and episode are zero.
func Choose ¶
func Choose(kind Kind, ids ExternalIDs, n Numbering) (Key, bool)
Choose keys an item: an episode by the id of its Numbering.Scheme with its season and episode, a movie by TMDB, then IMDb. An id ValidExternalID refuses counts as unknown. False means unidentified: a zero or unknown kind, an episode under None or with a number ValidEpisodeNumber refuses, or no usable id.
func ParseKey ¶
ParseKey is String's inverse, refusing every other spelling, a series root and any text over 64 bytes.
func (Key) Bytes ¶
Bytes is the root's ten bytes, then season and episode as big-endian uint16s, zero for a movie: fourteen bytes.
func (Key) MarshalText ¶
MarshalText is String; the zero Key, which UnmarshalText would refuse, is an error rather than "".
func (Key) String ¶
String is a movie's root text, or a series' root text followed by -s<season>e<episode>, each padded to two digits. "" for the zero Key.
func (*Key) UnmarshalText ¶
UnmarshalText is ParseKey, leaving k unchanged on a refusal.
type Kind ¶
type Kind uint8
Kind is what a key names.
func (Kind) MarshalText ¶
MarshalText is episode or movie.
func (*Kind) UnmarshalText ¶
UnmarshalText refuses every spelling but MarshalText's.
type Numbering ¶
Numbering is an episode's season and episode and the Scheme whose id keys it; each number passes ValidEpisodeNumber. A key's numbering is TVDB's aired order. A movie's is zero and ignored.
type RootKey ¶
type RootKey struct {
// contains filtered or unexported fields
}
RootKey names a movie or a series. Only Choose, ParseRootKey and Key.Root build one, so every non-zero RootKey is valid.
func ParseRootKey ¶
ParseRootKey is RootKey.String's inverse, refusing every other spelling, an episode key and any text over 64 bytes.
func (RootKey) Bytes ¶
Bytes is kind, scheme and the id as a big-endian uint64: ten bytes, so a prefix scan over one root never reaches another (tmdb-12 against tmdb-120).
func (RootKey) MarshalText ¶
MarshalText is String; the zero RootKey is an error rather than "".
func (RootKey) String ¶
String is the canonical text: tmdb-<id> or tt<id> for a movie; tvdb-<id>, tmdbtv-<id> or imdbtv-tt<id> for a series. Ids are decimal with no leading zero, IMDb's padded to seven digits. "" for the zero RootKey.
func (*RootKey) UnmarshalText ¶
UnmarshalText is ParseRootKey, leaving r unchanged on a refusal.
type Scheme ¶
type Scheme uint8
Scheme is the external id a key is built from. None is a movie's numbering scheme, and an episode numbered under None has no key.
func (Scheme) MarshalText ¶
MarshalText is none, tvdb, tmdb or imdb.
func (*Scheme) UnmarshalText ¶
UnmarshalText refuses every spelling but MarshalText's.
type SourceID ¶
type SourceID string
SourceID names one configured media source: 1 to 32 bytes of [a-z0-9-].
func (SourceID) MarshalText ¶
MarshalText refuses an id outside [a-z0-9-]{1,32}, so no id is written that UnmarshalText would refuse.
func (*SourceID) UnmarshalText ¶
UnmarshalText refuses anything outside [a-z0-9-]{1,32}, leaving id unchanged.