Documentation
¶
Overview ¶
Package parser extracts structured metadata (show name, season, episode numbers, quality, release group, etc.) from release filenames and titles.
This is a minimal implementation that covers the common S01E05 / S01E05E06 patterns required by the importer. A richer implementation (handling daily episodes, anime absolute numbering, scene naming conventions) can replace this file without changing the public API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeTitle ¶
NormalizeTitle lowercases a title and strips all non-alphanumeric characters so two titles can be compared without being tripped up by dots, underscores, spaces, or punctuation.
Example:
NormalizeTitle("Breaking.Bad") == NormalizeTitle("breaking bad") == "breakingbad"
func TitleMatches ¶
TitleMatches reports whether a release's parsed show title refers to the same series as seriesTitle. Comparison is strict after normalization, with one concession: a trailing 4-digit year on the release side is allowed ("Breaking Bad 2008" matches "Breaking Bad") since indexer releases frequently embed the premiere year.
It does NOT do any fuzzy matching, substring matching, or word-set comparison — those let unrelated releases slip through and cause the exact wrong-torrent bug this is meant to prevent. Use TitleMatchesAny when the series carries explicit alternate titles (from TMDB).
func TitleMatchesAny ¶
TitleMatchesAny reports whether a release's parsed show title matches any of the supplied candidate titles using the strict TitleMatches rules. Pass the canonical series title together with any alternate titles (from TMDB).
This is the right call for indexer-result filtering: an "Andor" series with alternate "Star Wars: Andor" will match release "Star Wars Andor S01..." because one of the candidates ("Star Wars: Andor") is itself a strict match. The strict semantics are preserved per-candidate — no fuzzy logic is added at the aggregate level.
Types ¶
type EpisodeInfo ¶
type EpisodeInfo struct {
// Season is the parsed season number (1-indexed; 0 = specials / unknown).
Season int
// Episodes is the list of episode numbers found in the filename.
// A multi-episode file like S02E03E04 will have [3, 4].
Episodes []int
// IsSeasonPack is true when the filename or directory name indicates an
// entire season rather than individual episodes (e.g. "Show.S02.BluRay").
IsSeasonPack bool
// AbsoluteEpisode is the parsed absolute episode number from anime-
// style titles ("[Group] Show - 48 [1080p]" → 48). Zero when the
// title doesn't match the absolute-pattern OR when SxxExx took
// precedence (the SxxExx form is preferred whenever both could
// apply, since it's less ambiguous).
AbsoluteEpisode int
}
EpisodeInfo holds the TV-episode-specific fields parsed from a filename.
type ParsedRelease ¶
type ParsedRelease struct {
// ShowTitle is the show name portion of the filename, with dots/underscores
// replaced by spaces and trimmed.
ShowTitle string
// EpisodeInfo carries the season/episode position data.
EpisodeInfo EpisodeInfo
// Year is the 4-digit year if one was present in the title (0 = absent).
Year int
}
ParsedRelease is the result of parsing a single filename or release title.
func Parse ¶
func Parse(filename string) ParsedRelease
Parse extracts structured information from a filename or release title. It is intentionally lenient: fields that cannot be determined are left at their zero values rather than returning an error.
func (ParsedRelease) String ¶
func (p ParsedRelease) String() string
String returns a human-readable representation of a ParsedRelease for logging and debugging.