epmarker

package
v0.10.0-dev.74 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

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.

  • Claims: S##E## markers (S## E## too, across up to three of " ._-") and ##x## tokens, then 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## or S## token, else "Season N", else ##x##.
  • 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

func Absolute(name string) (episode int, ok bool)

Absolute returns the episode a name with no marker shape states by one number, as batch entries name their files ("[Group] Show - 26"): the last " - NN", since a title's number comes first, else the first E##, EP## or Episode N, else the last spaced NN that is no bit depth and that a space, the name's end or a file suffix follows ("Mob Psycho 100 05.mkv" states 5, "Show 02 10 bits" 2). A range's number or a bracketed bare one is none. ok is false when no form is present, the number overflows an int, or Present reports a marker shape.

func BareEpisode added in v0.4.35

func BareEpisode(name string) (episode int, ok bool)

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: a caller reads it only under a season known from outside the name, where no other name it reads alongside claims a marker.

func FirstIndex

func FirstIndex(name string) int

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

func Present(name string) bool

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

func Season(name string) (season int, ok bool)

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 Claims ("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

func StatesEpisode(name string) bool

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

type Marker struct {
	Season  int
	Episode int
}

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

func Claims(name string) []Marker

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 (Marker) String added in v0.4.35

func (m Marker) String() string

String renders a marker in the canonical S##E## form, which is what a diagnostic naming the episode a caller looked for should say.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL