Documentation
¶
Overview ¶
Package epmarker is the one authority for what a release or archive member name claims about its season and episode. A name is read once into tokens, runs of ASCII letters and digits, and every view classifies those tokens; every notation is case-insensitive.
- Find: S##E## markers (S## E## too, across up to three of " ._-") and ##x## tokens. Claims: the episodes stated under a season, ranges expanded.
- FirstIndex, Present: where a marker-shaped token starts, unreadable digits included, so such a name still reaches no fallback.
- Season: the first S##E## marker or S## token, else "Season N", else the cross form.
- StatesEpisode: a marker, E##, EP##, Episode N, " - NN" after the season or a range right after it or opening a bracket; a season pack states a Season and none.
- Absolute: an episode number with no season attached (the caller supplies it); BareEpisode: a leading number in a name with no readable marker.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Absolute ¶
Absolute returns the episode a name with no marker shape states by one number, as batch entries name their files ("[Group] Show - 26" for S02E01): the last " - NN", since a title's own number comes before it, else the first E##, EP## or Episode N, else the first spaced " NN ", since "10 bits" comes after it. A number inside a range or a bare one in brackets is none. ok is false when no form is present, when the deciding number does not fit an int, or when Present reports a marker shape, which numbers the episode explicitly.
func BareEpisode ¶ added in v0.4.35
BareEpisode returns the episode a name states as a bare leading number: "6 - A Golden Crown..srt" states episode 6. The number is the name's first token, one to three digits, followed by one of " ._-", so a resolution ("1080p") or a year ("2011 - ") is none. A name with a readable marker returns false.
A bare number names no season, so this reading is kept apart from Find and Claims; Target.MatchesBareEpisode states what a caller must know to use it.
func FirstIndex ¶
FirstIndex returns the byte offset at which the first marker-shaped token starts, or -1 when name carries none. Used to split a release name into its title portion and its marker portion.
func Present ¶
Present reports whether name carries a marker-shaped token at all. This is the gate for "the name numbers its episodes some other way, fall back": a name containing an unparseable marker is still explicitly numbered, so it must not reach an absolute-number or season-pack fallback.
func Season ¶
Season returns the season of name's first S## token, a marker's S## included, else of "Season N", else of the cross form, so Season never contradicts Find ("Black Sails - 01x08" is season 1). ok is false when name carries no season token or its digits do not fit an int.
func StatesEpisode ¶
StatesEpisode reports whether name states an episode, as one number or a range: a marker-shaped token (Present), an E##, EP## or Episode N, or bare digits after a season statement, as " - 05" or as a range right after it or opening a bracket ("S2 01-12", "S2 [01 ~ 12]"). Other bare digits may be a title's, a volume's ("Vol.1-6"), a bit depth's ("10 bit"), a CRC's or a date's, so none of those states one. A season pack is a name with a Season that states none.
Types ¶
type Marker ¶
Marker is the season/episode pair one token claims. Both numbers are non-negative: they are read from digit runs, so "S00E00" is a legitimate Marker{0, 0} rather than a miss.
func Claims ¶ added in v0.4.35
Claims returns every episode name claims, ordered, deduplicated, nil when it claims none: its markers, and each episode StatesEpisode reads under its marker's season, else the latest season statement before it; a range longer than maxRangeSpan claims its first. It selects archive members, so a number with no season before it ("E01-E02") claims nothing: guessing one risks the wrong episode's subtitle written under the right episode's name.
func Find ¶
Find returns every well-formed single marker in name, in order of appearance, across both notations. Callers that care about precedence pick from the returned order themselves. A marker-shaped token whose season or episode does not fit an int is skipped here but still reported by Present.
type Target ¶ added in v0.4.35
type Target struct {
// contains filtered or unexported fields
}
Target is what a lookup is looking for. The zero Target matches any name, which is what a movie download and a provider that reports no numbering both arrive with, so a caller selecting from candidates needs one loop rather than one per case.
func For ¶ added in v0.4.35
For returns the Target that matches only m, or Any when either half of m is absent. A zero season or episode is how the wire says "this download has no episode to disambiguate", so a caller can hand over a subtitle's fields without deciding what that means.
func (Target) Matches ¶ added in v0.4.35
Matches reports whether name claims the episode t is looking for. An Any target matches every name.
func (Target) MatchesBareEpisode ¶ added in v0.4.35
MatchesBareEpisode reports whether name states t's episode as a bare leading number, with no season anywhere in the name.
Separate from Matches because it is only sound with information the NAME does not carry: the season. Two conditions must hold before a caller uses it, and neither is checkable from here.
The season must be known from outside the name, and known reliably rather than assumed. In subflux it is: the provider search sends seasonNumber to the API and the result's season is stamped from that same request, so a target's season came from Sonarr and not from any filename.
And no member of the same archive may claim a readable marker, which only the caller holding the whole member list can decide. That condition is what stops this reading from ever outvoting a notation that does parse.