releaseparse

package
v0.3.18 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: GPL-3.0 Imports: 10 Imported by: 0

Documentation

Overview

Package releaseparse parses scene and P2P release names into core.ReleaseInfo. It is pure string work and safe for concurrent use.

Index

Constants

View Source
const (
	LanguageMulti              = "multi"
	LanguageDual               = "dual"
	LanguageSpanishLatino      = "spanish-latino"
	LanguageSpanishSpain       = "spanish-spain"
	LanguagePortugueseBrazil   = "portuguese-brazil"
	LanguagePortuguesePortugal = "portuguese-portugal"
)

Language names are the release parser's lower-case English names ("french", "japanese"). A regional variant that release groups label separately carries its region after a hyphen ("spanish-latino", "portuguese-brazil"); its base is the part before the hyphen.

View Source
const (
	LanguageNoMatch = iota
	// LanguageBaseMatch is the right language in another (or an unstated)
	// regional variant: Castilian or unlabelled Spanish for a Latino
	// preference.
	LanguageBaseMatch
	// LanguageExactMatch is the wanted language; a preference without a
	// variant accepts every variant of its language.
	LanguageExactMatch
)

Language match strengths (LanguageMatch).

Variables

This section is empty.

Functions

func AbsoluteConflict

func AbsoluteConflict(parsed core.ReleaseInfo, absolute int) bool

AbsoluteConflict reports whether parsed info names absolute episode numbers and none of them is the wanted absolute count: the release names a different episode, whatever season numbering it also carries. A cour-numbered release's number is cour-local, not series-absolute, so cour releases never conflict on it.

func AnimeReleaseStyle

func AnimeReleaseStyle(name string, info core.ReleaseInfo) bool

AnimeReleaseStyle reports whether a release name carries anime-specific packaging conventions that distinguish an animated series from a non-animated namesake:

  • absolute episode numbering ("Show - 001", "Show S01E01 (001)");
  • a bracketed fansub or anime release group ("[SubsPlease] Show...", "Show [Ember]");
  • a bracketed 8-hex CRC32 checksum ("[A1B2C3D4]");
  • anime release metadata tags ("[Dual Audio]", "BD"/"BDMUX", or "Batch").

func AnimeSearchEpisode added in v0.2.44

func AnimeSearchEpisode(req core.SearchRequest) int

AnimeSearchEpisode is the absolute episode number an anime episode request is also searched by ("Show 1071"), or 0: the catalogue's count, or the episode itself in the first season.

func ClassicPackEpisode

func ClassicPackEpisode(filePath string, wantSeason int) (int, bool)

ClassicPackEpisode extracts a classic pack episode key for wantSeason when no standard SxxExx marker is present ("Season 2/05 - Title.mkv", "205 - Title.avi", or miniseries "Part 2 - Title.mkv").

func ClassicPackEpisodeMatches

func ClassicPackEpisodeMatches(filePath string, wantSeason, wantEp int) bool

ClassicPackEpisodeMatches reports whether a file in a season pack names the wanted episode the classic way, when no SxxExx is present: "Season 2/05 - Title.mkv", "205 - Title.avi", or a miniseries "Part 2 - Title.mkv". A season folder in the path must be the wanted season.

func CompareTitleIDs added in v0.2.4

func CompareTitleIDs(reported, expected core.IDs) (matched, conflicting bool)

CompareTitleIDs compares only shared identifier namespaces. A matching identifier is positive evidence. TMDB/TVDB conflicts always win; an IMDb conflict is tolerated only when both TMDB and TVDB independently agree. Missing identifiers carry no evidence and never become a match merely because the indexer was queried with the expected identifiers.

func DisclaimsDirector added in v0.2.49

func DisclaimsDirector(name, director string) bool

DisclaimsDirector recognizes a narrowly phrased post-year disclaimer. It requires the complete director name: aliases and initials are not evidence.

func DropTitleLanguages

func DropTitleLanguages(langs []string, name, title string) []string

DropTitleLanguages removes languages named only by the title's own words ("The French Dispatch", "The German Doctor") when the normalized title occurs inside name.

func EpisodeMatches

func EpisodeMatches(parsed core.ReleaseInfo, season, episode int) bool

EpisodeMatches reports whether parsed info is exactly the wanted episode (not a season pack, season matches, episode is listed).

func EpisodeMatchesAbsolute added in v0.2.44

func EpisodeMatchesAbsolute(parsed core.ReleaseInfo, absolute int) bool

EpisodeMatchesAbsolute reports whether parsed info is the episode whose number counted from the series start is absolute: an anime release numbered that way ("Show - 1071" or "Show S10E01 (0337)").

func EpisodeMatchesNumbering

func EpisodeMatchesNumbering(parsed core.ReleaseInfo, season, episode, absolute int) bool

EpisodeMatchesNumbering accepts canonical season numbering or verified absolute numbering. Some anime releases put the absolute number in Eyyyy; allow that only in season 1 or at 100+, never for specials or cour resets.

func EpisodeMatchesRequest

func EpisodeMatchesRequest(info core.ReleaseInfo, req core.SearchRequest) bool

EpisodeMatchesRequest reports whether parsed info matches req's canonical episode, verified absolute count, anime cour mapping, or configured release numbering aliases. Shared by the resolver and Stremio stream name selection.

func EpisodeSeriesYear added in v0.2.4

func EpisodeSeriesYear(name string, parsedYear int) int

EpisodeSeriesYear reads only the series portion of a TV name. A year in an episode title or after a season/episode boundary must not be mistaken for the show's premiere year.

func EpisodeTitleEvidence

func EpisodeTitleEvidence(name, want string) bool

EpisodeTitleEvidence reports a positively matching episode subtitle. Unlike EpisodeTitleMatches, missing or generic subtitles carry no evidence.

func EpisodeTitleMatches added in v0.2.4

func EpisodeTitleMatches(name, want string) bool

EpisodeTitleMatches rejects an explicitly different episode title between SxxExx and the technical metadata. Unnamed scene releases remain eligible. A title is only extracted when a recognized metadata boundary follows it.

func ExplicitDub added in v0.2.9

func ExplicitDub(name string) bool

ExplicitDub reports a dub declaration in release metadata, not a title word. Language parsing alone is not enough: foreign originals remain welcome.

func FlagLanguages added in v0.2.44

func FlagLanguages(text string) []string

FlagLanguages returns the languages named by flag emoji in text, in order of appearance. Unknown flags are ignored.

func HardSubbed

func HardSubbed(name string) bool

HardSubbed identifies explicit burned-in subtitle tags. Optional subtitle tracks (Subtitles, SUBPACK, MULTISUB) do not constitute this evidence.

func HasUsableInfo

func HasUsableInfo(info core.ReleaseInfo) bool

HasUsableInfo reports whether parsed info carries enough technical detail to consider a release whose title cannot be verified.

func IsBaitFile

func IsBaitFile(s string) bool

IsBaitFile reports whether s names an executable or shortcut bait file (.lnk, .exe, .scr, .bat, .msi, or double extensions like .mkv.lnk / .mp4.exe).

func IsNonVideoRelease

func IsNonVideoRelease(name, fileName string, expectedTitles ...string) bool

IsNonVideoRelease reports whether a release name or file hint identifies executable/shortcut bait or a non-video release (soundtrack/OST, ebook/EPUB, audiobook). expectedTitles optionally lists known titles of the requested movie or series so words that belong to the title itself (e.g. "Soundtrack") are not mistaken for non-video release tags.

func IsObfuscated

func IsObfuscated(title string) bool

IsObfuscated reports whether a name/title looks like a hash or random string with no readable words.

func IsPlaceholderResult

func IsPlaceholderResult(name string) bool

IsPlaceholderResult reports synthetic "no results" rows returned by Torznab/Jackett/Prowlarr bridges when an indexer refuses a text search (for example, "No results! Make sure to use the IMDb ID to search"). Real releases carrying technical metadata, years or episode markers are kept.

func IsVideoRelease

func IsVideoRelease(name string) bool

IsVideoRelease reports whether name carries positive video release evidence (resolution, video codec/container, HDR, or video source tag) and is not a bait or non-video release (eBook, audiobook, soundtrack/OST).

func KeywordMatch

func KeywordMatch(name, keyword string) bool

KeywordMatch matches a complete token sequence, treating release separators alike. Subtitle keywords have no hidden aliases.

func KnownLanguage

func KnownLanguage(v string) bool

KnownLanguage reports whether v names a language the parser knows, in any form LanguageName accepts.

func LanguageBase added in v0.2.44

func LanguageBase(name string) string

LanguageBase is a language name without its regional variant.

func LanguageMatch added in v0.2.44

func LanguageMatch(release, want string) int

LanguageMatch reports how well a release language satisfies a wanted language. Both may be any form LanguageName accepts.

func LanguageName added in v0.2.44

func LanguageName(v string) string

LanguageName names a language preference or code the way the parser names release languages: ISO 639 codes and BCP 47 tags ("fr", "fra", "es-419", "pt-BR"), parser names ("french", "Spanish-Latino") and the scene words for regional variants ("latino", "castellano", "brazilian"). Unknown values are returned lower-cased.

func MiniseriesPart added in v0.2.4

func MiniseriesPart(name string) (seriesTitle string, part int, ok bool)

MiniseriesPart extracts the series title and 1-based part number from a miniseries release named "Show.Name.Part.3.Episode.Title.1080p.BluRay" or "Show.Name.1990.Pt.01.720p". It is used only when resolving a Season 1 episode so movie titles ("Dune Part Two") are unaffected.

func MovieFileMatches

func MovieFileMatches(name string, titles []string, year int) bool

MovieFileMatches requires an exact parsed title, never a prefix that can admit sequels. A year carried by the file or its nearest titled folder must agree too. Trailing language/audio/subtitle labels (e.g. "The.Mummy.FRENCH", "The Mummy (English)") and generic language-only filenames ("French/movie.mkv") inside single-movie dual-language packs are accepted when no folder contradicts the movie's title or year.

func NamesSpecial

func NamesSpecial(name string) bool

NamesSpecial requires an explicit special marker. Bare episode numbers and regular season packs do not establish season zero.

func NormalizeTitle

func NormalizeTitle(s string) string

NormalizeTitle lowercases, strips diacritics and punctuation, expands "&" to "and", and drops a leading article, for title comparisons.

func OrderMovieCandidates

func OrderMovieCandidates(cands []MovieCandidate, titles []string, originalLang string, wanted []string) []int

OrderMovieCandidates returns a permutation of [0..len(cands)-1] preferring full-length, top-resolution candidates whose parsed audio matches wanted (in priority order) before falling back to largest byte size.

func Parse

func Parse(name string) core.ReleaseInfo

Parse extracts structured info from a release name.

func ParseEdition

func ParseEdition(name string) string

ParseEdition identifies explicit cut labels without guessing from runtime.

func ParseSize added in v0.3.4

func ParseSize(s string) int64

ParseSize reads sizes such as "1.4 GiB", "700 MB", "1,234.5 KB", "1.234,5 MB" or raw byte counts. Like Cardigann, decimal and binary units are both treated as powers of 1024. Unparseable input is 0.

func SeriesYearMatches added in v0.2.4

func SeriesYearMatches(releaseYear, showYear int) bool

SeriesYearMatches distinguishes same-named series and reboots. A year explicitly present in a TV release identifies the series, not the episode's air year. Releases omitting a year remain eligible.

func SpecialCountOnly

func SpecialCountOnly(name string, shows ...string) bool

SpecialCountOnly rejects group-local OAD/OVA counts without a title or an explicit S00Exx identity. A parent folder cannot confer a title on a count.

func SpecialMatches

func SpecialMatches(name, want string, others, shows []string) bool

func SpecialNamesAnother

func SpecialNamesAnother(name, want string, others, shows []string) bool

SpecialNamesAnother compares the basename and immediate folder, ignoring the show name. A stronger sibling title overrides a coincidental number.

func SpecialSeriesTitle

func SpecialSeriesTitle(name string) string

SpecialSeriesTitle reads the actual series prefix before a specials label. It never supplies a query's title as evidence for an add-on's answer.

func SpecialTitleAgrees

func SpecialTitleAgrees(name, want string, shows ...string) bool

SpecialTitleAgrees allows abbreviated subtitles after S00Exx only when at least half their meaningful words occur in the catalogue subtitle.

func SpecialTitleEvidence

func SpecialTitleEvidence(name, want string, shows ...string) bool

SpecialTitleEvidence is positive title evidence for a named OVA/OAD without catalogue episode numbering. Missing subtitles never provide evidence.

func SpecialTitleNumberConflict

func SpecialTitleNumberConflict(a, b map[string]bool) bool

func SpecialTitleWords

func SpecialTitleWords(title string, shows ...string) map[string]bool

SpecialTitleWords drops filler, technical tags and the show's own names. Numbers are kept to distinguish named parts.

func StripTrailingLanguage

func StripTrailingLanguage(title string) (string, bool)

StripTrailingLanguage removes one scene language token from a parsed title. It is a fallback for identity gates handling previously parsed releases; it deliberately uses the scene vocabulary rather than arbitrary language names.

func TitleAliases added in v0.2.4

func TitleAliases(title string) []string

TitleAliases returns alternative search query titles for titles with initialisms, explicit subtitles, parenthetical disambiguators or Roman numerals. Ordinary titles return nil so standard searches spend no extra budget hits.

func TitleMatches

func TitleMatches(parsed core.ReleaseInfo, want string) bool

TitleMatches reports whether a parsed release title matches the wanted title.

func TitleMatchesAny

func TitleMatchesAny(parsed core.ReleaseInfo, want string, alts []string) bool

TitleMatchesAny reports whether parsed matches want or any of the supplied alternative titles.

func TitlesMatch

func TitlesMatch(a, b string) bool

TitlesMatch reports whether two raw titles are the same after normalisation.

func Tokens

func Tokens(s string) []string

Tokens splits release punctuation without matching parts of words.

func TrailingRegionTag added in v0.2.4

func TrailingRegionTag(title string) string

TrailingRegionTag returns the canonical region code ("us", "uk", "au", "ca", "nz") when a release or show title ends with an explicit country disambiguator ("The.Office.US", "Ghosts (UK)"), or "".

func YearMatches

func YearMatches(got, want int) bool

YearMatches reports whether two years agree within ±1 (zero = unknown).

Types

type MovieCandidate

type MovieCandidate struct {
	Path string
	Size int64
}

MovieCandidate describes one playable movie file or archive set for language-aware multi-file pack ordering.

type PackEpisodeSizeGate

type PackEpisodeSizeGate struct {
	// contains filtered or unexported fields
}

PackEpisodeSizeGate rejects season-pack episode files whose per-episode byte size is an implausible outlier (< 15% or > 400% of the pack's median episode size), preventing samples, teasers, or full-season recap/extras files from standing in for an episode.

func NewPackEpisodeSizeGate

func NewPackEpisodeSizeGate(entries []PackSizedFile, targetSeason, targetCour int) PackEpisodeSizeGate

NewPackEpisodeSizeGate builds a size gate from the playable candidates of a season pack for targetSeason (and optional targetCour). Specials (season <= 0) and single-episode releases are unconstrained.

func (PackEpisodeSizeGate) Accept

func (g PackEpisodeSizeGate) Accept(filePath string, size int64) bool

Accept reports whether a candidate episode file's size falls within the season pack's plausible episode size bounds ([15%, 400%] of median).

type PackSizedFile

type PackSizedFile struct {
	Path string
	Size int64
}

PackSizedFile describes one candidate episode file or archive unit in a pack.

Jump to

Keyboard shortcuts

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