guessit-js 3.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +174 -0
- package/dist/api.d.ts +41 -0
- package/dist/config/index.d.ts +9 -0
- package/dist/guessit-js.cjs +10050 -0
- package/dist/guessit-js.cjs.map +1 -0
- package/dist/guessit-js.js +10050 -0
- package/dist/guessit-js.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.html +675 -0
- package/dist/language/data.d.ts +24 -0
- package/dist/language/index.d.ts +68 -0
- package/dist/openapi.json +617 -0
- package/dist/options.d.ts +35 -0
- package/dist/reutils.d.ts +8 -0
- package/dist/rules/common/comparators.d.ts +12 -0
- package/dist/rules/common/date.d.ts +6 -0
- package/dist/rules/common/expected.d.ts +7 -0
- package/dist/rules/common/formatters.d.ts +20 -0
- package/dist/rules/common/index.d.ts +27 -0
- package/dist/rules/common/numeral.d.ts +7 -0
- package/dist/rules/common/pattern.d.ts +7 -0
- package/dist/rules/common/quantity.d.ts +21 -0
- package/dist/rules/common/validators.d.ts +8 -0
- package/dist/rules/common/words.d.ts +6 -0
- package/dist/rules/index.d.ts +23 -0
- package/dist/rules/markers/groups.d.ts +9 -0
- package/dist/rules/markers/path.d.ts +3 -0
- package/dist/rules/processors.d.ts +53 -0
- package/dist/rules/properties/audio_codec.d.ts +3 -0
- package/dist/rules/properties/bit_rate.d.ts +3 -0
- package/dist/rules/properties/bonus.d.ts +3 -0
- package/dist/rules/properties/cd.d.ts +3 -0
- package/dist/rules/properties/container.d.ts +3 -0
- package/dist/rules/properties/country.d.ts +3 -0
- package/dist/rules/properties/crc.d.ts +3 -0
- package/dist/rules/properties/date.d.ts +6 -0
- package/dist/rules/properties/edition.d.ts +3 -0
- package/dist/rules/properties/episode_title.d.ts +3 -0
- package/dist/rules/properties/episodes.d.ts +22 -0
- package/dist/rules/properties/film.d.ts +3 -0
- package/dist/rules/properties/language.d.ts +17 -0
- package/dist/rules/properties/mimetype.d.ts +3 -0
- package/dist/rules/properties/other.d.ts +4 -0
- package/dist/rules/properties/part.d.ts +3 -0
- package/dist/rules/properties/release_group.d.ts +3 -0
- package/dist/rules/properties/screen_size.d.ts +10 -0
- package/dist/rules/properties/size.d.ts +3 -0
- package/dist/rules/properties/source.d.ts +3 -0
- package/dist/rules/properties/streaming_service.d.ts +3 -0
- package/dist/rules/properties/title.d.ts +6 -0
- package/dist/rules/properties/type.d.ts +6 -0
- package/dist/rules/properties/video_codec.d.ts +3 -0
- package/dist/rules/properties/website.d.ts +3 -0
- package/dist/wasm-test.html +467 -0
- package/package.json +70 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Context, MatchOptions } from 'rebulk-js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Build a functional pattern function that finds expected titles/groups in the string.
|
|
5
|
+
* Mirrors Python's build_expected_function('expected_title').
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildExpectedFunction(optionName: string): (inputString: string, context?: Context) => Array<[number, number, Partial<MatchOptions>]>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Remove and strip separators from inputString (but keep ',;' characters).
|
|
3
|
+
* Also keeps separators for single characters (e.g., S.H.I.E.L.D.).
|
|
4
|
+
*/
|
|
5
|
+
export declare function cleanup(inputString: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Strip separator characters from both ends of the string.
|
|
8
|
+
*/
|
|
9
|
+
export declare function strip(inputString: string, chars?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Cleanup a raw value to perform raw comparison.
|
|
12
|
+
*/
|
|
13
|
+
export declare function rawCleanup(raw: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Reorder the title by moving a trailing article to the front.
|
|
16
|
+
* "The Dark Knight, The" → "The Dark Knight"
|
|
17
|
+
* Also handles moving leading article to end: not the primary direction in Python.
|
|
18
|
+
* Python's reorder_title moves "title, the" patterns to canonical form.
|
|
19
|
+
*/
|
|
20
|
+
export declare function reorderTitle(title: string, articles?: string[], separators?: string[]): string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common constants and helpers — port of guessit/rules/common/__init__.py
|
|
3
|
+
*/
|
|
4
|
+
/** Characters that can act as separators between words/tokens. */
|
|
5
|
+
export declare const seps = " [](){}+*|=-_~#/\\.,;:";
|
|
6
|
+
/** Separators without group brackets */
|
|
7
|
+
export declare const sepsNoGroups: string;
|
|
8
|
+
/** Separators without filesystem path characters */
|
|
9
|
+
export declare const sepsNoFs: string;
|
|
10
|
+
/** Separators for title splitting */
|
|
11
|
+
export declare const titleSeps = "-+/\\|";
|
|
12
|
+
/** Escape a string for use in a regex character class. */
|
|
13
|
+
export declare function reEscape(s: string): string;
|
|
14
|
+
/** Pre-escaped `seps` safe for use in a regex character class `[sepsPattern]`. */
|
|
15
|
+
export declare const sepsPattern: string;
|
|
16
|
+
/** Pre-escaped `sepsNoGroups` safe for use in a regex character class. */
|
|
17
|
+
export declare const sepsNoGroupsPattern: string;
|
|
18
|
+
/** Strip all separator characters from a string. */
|
|
19
|
+
export declare function stripSeps(s: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* Abbreviation pair: literal `-` expands to a separator character class.
|
|
22
|
+
* Used as: abbreviations=[dash] in regex_defaults.
|
|
23
|
+
*/
|
|
24
|
+
export declare const dash: [string, string];
|
|
25
|
+
export declare const altDash: [string, string];
|
|
26
|
+
/** Make a regex pattern optional. */
|
|
27
|
+
export declare function optional(pattern: string): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Numeral helpers — port of guessit/rules/common/numeral.py
|
|
3
|
+
*/
|
|
4
|
+
export declare function parseRoman(s: string): number | undefined;
|
|
5
|
+
export declare function parseWord(s: string): number | undefined;
|
|
6
|
+
export declare function parseNumber(s: string): number | undefined;
|
|
7
|
+
export declare function numericFunction(value: string): number;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Context } from 'rebulk-js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Check if a property is disabled in the current context.
|
|
5
|
+
* Used by property builders: disabled=lambda context: is_disabled(context, 'video_codec')
|
|
6
|
+
*/
|
|
7
|
+
export declare function isDisabled(context: Context | undefined, name: string): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare abstract class Quantity {
|
|
2
|
+
magnitude: number;
|
|
3
|
+
units: string;
|
|
4
|
+
constructor(magnitude: number, units: string);
|
|
5
|
+
static parseUnits(_value: string): string;
|
|
6
|
+
static fromstring(this: any, string: string): any;
|
|
7
|
+
toString(): string;
|
|
8
|
+
equals(other: unknown): boolean;
|
|
9
|
+
}
|
|
10
|
+
export declare class Size extends Quantity {
|
|
11
|
+
static parseUnits(value: string): string;
|
|
12
|
+
static fromstring(string: string): Size;
|
|
13
|
+
}
|
|
14
|
+
export declare class BitRate extends Quantity {
|
|
15
|
+
static parseUnits(value: string): string;
|
|
16
|
+
static fromstring(string: string): BitRate;
|
|
17
|
+
}
|
|
18
|
+
export declare class FrameRate extends Quantity {
|
|
19
|
+
static parseUnits(_value: string): string;
|
|
20
|
+
static fromstring(string: string): FrameRate;
|
|
21
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Match } from 'rebulk-js';
|
|
2
|
+
|
|
3
|
+
export declare const sepsBefore: (match: Match) => boolean;
|
|
4
|
+
export declare const sepsAfter: (match: Match) => boolean;
|
|
5
|
+
export declare const sepsSurround: (match: Match) => boolean;
|
|
6
|
+
export declare function intCoercable(string: string): boolean;
|
|
7
|
+
export declare function and_(...validators: ((m: Match) => boolean)[]): (m: Match) => boolean;
|
|
8
|
+
export declare function or_(...validators: ((m: Match) => boolean)[]): (m: Match) => boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Rebulk } from 'rebulk-js';
|
|
2
|
+
|
|
3
|
+
export interface AdvancedConfig {
|
|
4
|
+
common_words?: string[];
|
|
5
|
+
groups?: {
|
|
6
|
+
starting: string;
|
|
7
|
+
ending: string;
|
|
8
|
+
};
|
|
9
|
+
audio_codec?: Record<string, unknown>;
|
|
10
|
+
screen_size?: {
|
|
11
|
+
frame_rates: string[];
|
|
12
|
+
interlaced: string[];
|
|
13
|
+
progressive: string[];
|
|
14
|
+
min_ar: number;
|
|
15
|
+
max_ar: number;
|
|
16
|
+
};
|
|
17
|
+
source?: Record<string, unknown>;
|
|
18
|
+
episodes?: Record<string, unknown>;
|
|
19
|
+
language?: Record<string, unknown>;
|
|
20
|
+
country?: Record<string, unknown>;
|
|
21
|
+
[key: string]: unknown;
|
|
22
|
+
}
|
|
23
|
+
export declare function rebulkBuilder(config: AdvancedConfig): Rebulk;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Rebulk, Rule, CustomRule, AppendMatch, RemoveMatch, Match, Matches, Context } from 'rebulk-js';
|
|
2
|
+
|
|
3
|
+
/** Enlarge matches that start/end a group to include bracket characters. */
|
|
4
|
+
export declare class EnlargeGroupMatches extends CustomRule {
|
|
5
|
+
static priority: number;
|
|
6
|
+
when(matches: Matches, _context: Context): [Match[], Match[]] | false;
|
|
7
|
+
then(matches: Matches, whenResponse: unknown, _context: Context): void;
|
|
8
|
+
}
|
|
9
|
+
/** Creates equivalent matches for holes that have the same value as an existing match. */
|
|
10
|
+
export declare class EquivalentHoles extends Rule {
|
|
11
|
+
static priority: number;
|
|
12
|
+
static consequence: typeof AppendMatch;
|
|
13
|
+
when(matches: Matches, _context: Record<string, unknown>): Match[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* If multiple matches with same name and different values exist, keep the one
|
|
17
|
+
* in the most valuable filepart and mark others for removal.
|
|
18
|
+
*/
|
|
19
|
+
export declare class RemoveAmbiguous extends Rule {
|
|
20
|
+
static priority: number;
|
|
21
|
+
static consequence: typeof RemoveMatch;
|
|
22
|
+
protected sortFunction: (markers: Match[], matches: Matches) => Match[];
|
|
23
|
+
protected predicate: ((m: Match) => boolean) | null;
|
|
24
|
+
constructor(sortFn?: (markers: Match[], matches: Matches) => Match[], predicate?: (m: Match) => boolean);
|
|
25
|
+
when(matches: Matches, _context: Record<string, unknown>): Match[];
|
|
26
|
+
}
|
|
27
|
+
export declare class RemoveLessSpecificSeasonEpisode extends RemoveAmbiguous {
|
|
28
|
+
constructor(name: string);
|
|
29
|
+
}
|
|
30
|
+
/** If a season is a valid year and no year found, create a year match. */
|
|
31
|
+
export declare class SeasonYear extends Rule {
|
|
32
|
+
static priority: number;
|
|
33
|
+
static consequence: typeof AppendMatch;
|
|
34
|
+
when(matches: Matches, _context: Record<string, unknown>): Match[];
|
|
35
|
+
}
|
|
36
|
+
/** If year found, no season found, and episode found, create a season match. */
|
|
37
|
+
export declare class YearSeason extends Rule {
|
|
38
|
+
static priority: number;
|
|
39
|
+
static consequence: typeof AppendMatch;
|
|
40
|
+
when(matches: Matches, _context: Record<string, unknown>): Match[];
|
|
41
|
+
}
|
|
42
|
+
/** Empty rule for ordering post-processing. */
|
|
43
|
+
export declare class Processors extends Rule {
|
|
44
|
+
static priority: number;
|
|
45
|
+
when(_matches: Matches, _context: Record<string, unknown>): false;
|
|
46
|
+
}
|
|
47
|
+
/** Strip separator characters from match boundaries. */
|
|
48
|
+
export declare class StripSeparators extends CustomRule {
|
|
49
|
+
static priority: number;
|
|
50
|
+
when(matches: Matches, _context: Context): Matches;
|
|
51
|
+
then(matches: Matches, _whenResponse: unknown, _context: Context): void;
|
|
52
|
+
}
|
|
53
|
+
export declare function processors(_config: Record<string, unknown>): Rebulk;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Rebulk } from 'rebulk-js';
|
|
2
|
+
|
|
3
|
+
interface EpisodesConfig {
|
|
4
|
+
season_max_range: number;
|
|
5
|
+
episode_max_range: number;
|
|
6
|
+
max_range_gap: number;
|
|
7
|
+
season_markers: string[];
|
|
8
|
+
season_ep_markers: string[];
|
|
9
|
+
disc_markers: string[];
|
|
10
|
+
episode_markers: string[];
|
|
11
|
+
range_separators: string[];
|
|
12
|
+
discrete_separators: string[];
|
|
13
|
+
season_words: string[];
|
|
14
|
+
episode_words: string[];
|
|
15
|
+
of_words: string[];
|
|
16
|
+
all_words: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Build the episodes rebulk
|
|
20
|
+
*/
|
|
21
|
+
export declare function episodes(config: EpisodesConfig): Rebulk;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Rebulk } from 'rebulk-js';
|
|
2
|
+
|
|
3
|
+
interface LanguageConfig {
|
|
4
|
+
subtitle_affixes: string[];
|
|
5
|
+
subtitle_prefixes: string[];
|
|
6
|
+
subtitle_suffixes: string[];
|
|
7
|
+
language_affixes: string[];
|
|
8
|
+
language_prefixes: string[];
|
|
9
|
+
language_suffixes: string[];
|
|
10
|
+
weak_affixes: string[];
|
|
11
|
+
synonyms: Record<string, string[]>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Main language property builder
|
|
15
|
+
*/
|
|
16
|
+
export declare function language(config: LanguageConfig, commonWords: Set<string>): Rebulk;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Rebulk } from 'rebulk-js';
|
|
2
|
+
|
|
3
|
+
export interface ScreenSizeConfig {
|
|
4
|
+
frame_rates: string[];
|
|
5
|
+
interlaced: string[];
|
|
6
|
+
progressive: string[];
|
|
7
|
+
min_ar: number;
|
|
8
|
+
max_ar: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function screenSize(config: ScreenSizeConfig): Rebulk;
|