guessit-js 4.5.0 → 4.5.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 +3 -3
- package/dist/guessit-js.cjs +108 -11
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +108 -11
- package/dist/guessit-js.js.map +1 -1
- package/package.json +1 -1
package/dist/guessit-js.js
CHANGED
|
@@ -3679,13 +3679,13 @@ function episodes(config) {
|
|
|
3679
3679
|
rebulk.chain({
|
|
3680
3680
|
tags: ["weak-episode"],
|
|
3681
3681
|
disabled: (context) => context?.type === "movie" || isDisabled(context, "episode")
|
|
3682
|
-
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])(?<episode>\\d{2})(?!(?:st|nd|rd|th)\\b)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{2})`, {
|
|
3682
|
+
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])(?<episode>\\d{2})(?!(?:st|nd|rd|th)\\b)(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{2})`, {
|
|
3683
3683
|
abbreviations: null
|
|
3684
3684
|
}).repeater("*");
|
|
3685
3685
|
rebulk.chain({
|
|
3686
3686
|
tags: ["weak-episode"],
|
|
3687
3687
|
disabled: (context) => context?.type === "movie" || isDisabled(context, "episode")
|
|
3688
|
-
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])0(?<episode>\\d{1,2})(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])0(?<episode>\\d{1,2})`, {
|
|
3688
|
+
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])0(?<episode>\\d{1,2})(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])0(?<episode>\\d{1,2})`, {
|
|
3689
3689
|
abbreviations: null
|
|
3690
3690
|
}).repeater("*");
|
|
3691
3691
|
rebulk.chain({
|
|
@@ -3696,13 +3696,13 @@ function episodes(config) {
|
|
|
3696
3696
|
validator: null,
|
|
3697
3697
|
tags: ["weak-episode"],
|
|
3698
3698
|
name: "weak_episode"
|
|
3699
|
-
}).regex(`(?<![^\\W_])(?<episode>\\d{3,4})(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{3,4})`, {
|
|
3699
|
+
}).regex(`(?<![^\\W_])(?<episode>\\d{3,4})(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{3,4})`, {
|
|
3700
3700
|
abbreviations: null
|
|
3701
3701
|
}).repeater("*");
|
|
3702
3702
|
rebulk.chain({
|
|
3703
3703
|
tags: ["weak-episode"],
|
|
3704
3704
|
disabled: (context) => context?.type !== "episode" || isDisabled(context, "episode")
|
|
3705
|
-
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])(?<episode>\\d)(?!-[a-z])(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{1,2})`, {
|
|
3705
|
+
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])(?<episode>\\d)(?!-[a-z])(?!%)(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{1,2})`, {
|
|
3706
3706
|
abbreviations: null
|
|
3707
3707
|
}).repeater("*");
|
|
3708
3708
|
rebulk.chain({
|
|
@@ -3731,7 +3731,7 @@ function episodes(config) {
|
|
|
3731
3731
|
name: "weak_duplicate",
|
|
3732
3732
|
validator: null,
|
|
3733
3733
|
conflictSolver: seasonEpisodeConflictSolver
|
|
3734
|
-
}).regex(`(?<![^\\W_])(?<season>\\d{1,2})(?<episode>\\d{2})(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>x|-)(?<episode>\\d{2})`, {
|
|
3734
|
+
}).regex(`(?<![^\\W_])(?<season>\\d{1,2})(?<episode>\\d{2})(?!%)(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>x|-)(?<episode>\\d{2})`, {
|
|
3735
3735
|
abbreviations: null
|
|
3736
3736
|
}).repeater("*");
|
|
3737
3737
|
rebulk.regex(`v(?<version>\\d+)`, {
|
|
@@ -3759,6 +3759,7 @@ function episodes(config) {
|
|
|
3759
3759
|
disabled: (context) => isDisabled(context, "episode_format")
|
|
3760
3760
|
});
|
|
3761
3761
|
rebulk.rules(
|
|
3762
|
+
EventNumberAsTitleRule,
|
|
3762
3763
|
EpisodeWordBeforeYearAsTitle,
|
|
3763
3764
|
RemoveGroupSuffixSeason,
|
|
3764
3765
|
AnimeTrailingEpisodeRule,
|
|
@@ -3816,6 +3817,45 @@ const _RemoveGroupSuffixSeason = class _RemoveGroupSuffixSeason extends Rule {
|
|
|
3816
3817
|
};
|
|
3817
3818
|
_RemoveGroupSuffixSeason.priority = 72;
|
|
3818
3819
|
let RemoveGroupSuffixSeason = _RemoveGroupSuffixSeason;
|
|
3820
|
+
const _EventNumberAsTitleRule = class _EventNumberAsTitleRule extends Rule {
|
|
3821
|
+
constructor() {
|
|
3822
|
+
super(...arguments);
|
|
3823
|
+
this.priority = 60;
|
|
3824
|
+
this.consequence = RemoveMatch;
|
|
3825
|
+
}
|
|
3826
|
+
when(matches, _context) {
|
|
3827
|
+
const input = matches.inputString ?? "";
|
|
3828
|
+
const toRemove = [];
|
|
3829
|
+
const isWeak = (m) => !!(m.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(m.initiator?.name));
|
|
3830
|
+
for (const filepart of matches.markers.named("path") ?? []) {
|
|
3831
|
+
const weaks = matches.range(
|
|
3832
|
+
filepart.start,
|
|
3833
|
+
filepart.end,
|
|
3834
|
+
(m) => m.name === "episode" && !m.private && isWeak(m)
|
|
3835
|
+
) ?? [];
|
|
3836
|
+
if (!weaks.length) continue;
|
|
3837
|
+
const strong = matches.range(filepart.start, filepart.end, (m) => !m.private && (m.name === "season" || m.name === "year" || m.name === "date" || m.name === "episode" && m.tags?.includes("SxxExx")), 0);
|
|
3838
|
+
for (const w of weaks) {
|
|
3839
|
+
const init = w.initiator ?? w;
|
|
3840
|
+
const after = input.slice(init.end, init.end + 5);
|
|
3841
|
+
if (/^[\s._-]?PPV/i.test(after)) {
|
|
3842
|
+
for (const c of [init, ...init.children ?? []]) if (!toRemove.includes(c)) toRemove.push(c);
|
|
3843
|
+
continue;
|
|
3844
|
+
}
|
|
3845
|
+
if (!strong && init.start === filepart.start && /^[1-9]\d$/.test(String(init.raw ?? ""))) {
|
|
3846
|
+
const rest = input.slice(init.end, filepart.end);
|
|
3847
|
+
const words = rest.match(/[A-Za-z][a-z]+/g) ?? [];
|
|
3848
|
+
if (words.length >= 2) {
|
|
3849
|
+
for (const c of [init, ...init.children ?? []]) if (!toRemove.includes(c)) toRemove.push(c);
|
|
3850
|
+
}
|
|
3851
|
+
}
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
return toRemove.length ? toRemove : false;
|
|
3855
|
+
}
|
|
3856
|
+
};
|
|
3857
|
+
_EventNumberAsTitleRule.priority = 60;
|
|
3858
|
+
let EventNumberAsTitleRule = _EventNumberAsTitleRule;
|
|
3819
3859
|
const _EpisodeWordBeforeYearAsTitle = class _EpisodeWordBeforeYearAsTitle extends Rule {
|
|
3820
3860
|
constructor() {
|
|
3821
3861
|
super(...arguments);
|
|
@@ -7059,8 +7099,10 @@ const _BracketedTitleFallback = class _BracketedTitleFallback extends Rule {
|
|
|
7059
7099
|
const toRemove = [];
|
|
7060
7100
|
const toAppend = [];
|
|
7061
7101
|
for (const filepart of matches.markers.named("path")) {
|
|
7062
|
-
const
|
|
7063
|
-
|
|
7102
|
+
const titlesHere = matches.range(filepart.start, filepart.end, (m) => m.name === "title") ?? [];
|
|
7103
|
+
const realTitle = titlesHere.find((t) => /[\p{L}\p{N}]/u.test(String(t.value ?? "")));
|
|
7104
|
+
if (realTitle) continue;
|
|
7105
|
+
toRemove.push(...titlesHere);
|
|
7064
7106
|
const groups2 = matches.markers.range(filepart.start, filepart.end, (m) => m.name === "group") ?? [];
|
|
7065
7107
|
if (!groups2.length) continue;
|
|
7066
7108
|
const rg = matches.range(filepart.start, filepart.end, (m) => m.name === "release_group", 0);
|
|
@@ -7069,6 +7111,25 @@ const _BracketedTitleFallback = class _BracketedTitleFallback extends Rule {
|
|
|
7069
7111
|
if (rg && g.start <= rg.start && g.end >= rg.end) continue;
|
|
7070
7112
|
const core = input.slice(g.start + 1, g.end - 1);
|
|
7071
7113
|
if (!/[a-zA-Z]{2,}/.test(core)) continue;
|
|
7114
|
+
const softInner = matches.range(
|
|
7115
|
+
g.start,
|
|
7116
|
+
g.end,
|
|
7117
|
+
(m) => !m.private && ["episode_title", "alternative_title"].includes(m.name ?? "")
|
|
7118
|
+
) ?? [];
|
|
7119
|
+
const hardInner = matches.range(
|
|
7120
|
+
g.start,
|
|
7121
|
+
g.end,
|
|
7122
|
+
(m) => !m.private && !["episode_title", "alternative_title"].includes(m.name ?? "")
|
|
7123
|
+
) ?? [];
|
|
7124
|
+
if (softInner.length && !hardInner.length) {
|
|
7125
|
+
toRemove.push(...softInner);
|
|
7126
|
+
candidate = new Match(g.start + 1, g.end - 1, {
|
|
7127
|
+
name: "title",
|
|
7128
|
+
value: cleanup(input.slice(g.start + 1, g.end - 1)),
|
|
7129
|
+
inputString: input
|
|
7130
|
+
});
|
|
7131
|
+
break;
|
|
7132
|
+
}
|
|
7072
7133
|
const hole = matches.holes(g.start + 1, g.end - 1, {
|
|
7073
7134
|
formatter: cleanup,
|
|
7074
7135
|
predicate: (h) => !!h.value,
|
|
@@ -7171,6 +7232,41 @@ const _BonusAtTitlePositionRule = class _BonusAtTitlePositionRule extends Rule {
|
|
|
7171
7232
|
};
|
|
7172
7233
|
_BonusAtTitlePositionRule.priority = 64;
|
|
7173
7234
|
let BonusAtTitlePositionRule = _BonusAtTitlePositionRule;
|
|
7235
|
+
const _LanguageWordInAnimeTitle = class _LanguageWordInAnimeTitle extends Rule {
|
|
7236
|
+
constructor() {
|
|
7237
|
+
super(...arguments);
|
|
7238
|
+
this.priority = 64;
|
|
7239
|
+
this.consequence = RemoveMatch;
|
|
7240
|
+
}
|
|
7241
|
+
when(matches, context) {
|
|
7242
|
+
if (isDisabled(context, "language")) return false;
|
|
7243
|
+
const toRemove = [];
|
|
7244
|
+
for (const lang of matches.named("language") ?? []) {
|
|
7245
|
+
const raw = String(lang.raw ?? "");
|
|
7246
|
+
if (raw.length > 3 || !/^[A-Z][a-z]{0,2}$/.test(raw)) continue;
|
|
7247
|
+
const filepart = matches.markers.atMatch(lang, (m) => m.name === "path", 0);
|
|
7248
|
+
if (!filepart) continue;
|
|
7249
|
+
const leadingBracket = matches.markers.range(
|
|
7250
|
+
filepart.start,
|
|
7251
|
+
filepart.end,
|
|
7252
|
+
(m) => m.name === "group" && m.start === filepart.start,
|
|
7253
|
+
0
|
|
7254
|
+
);
|
|
7255
|
+
if (!leadingBracket) continue;
|
|
7256
|
+
const anchor = matches.range(
|
|
7257
|
+
lang.end,
|
|
7258
|
+
filepart.end,
|
|
7259
|
+
(m) => !m.private && ["episode", "season", "year", "date"].includes(m.name ?? ""),
|
|
7260
|
+
0
|
|
7261
|
+
);
|
|
7262
|
+
if (!anchor) continue;
|
|
7263
|
+
toRemove.push(lang);
|
|
7264
|
+
}
|
|
7265
|
+
return toRemove.length ? toRemove : false;
|
|
7266
|
+
}
|
|
7267
|
+
};
|
|
7268
|
+
_LanguageWordInAnimeTitle.priority = 64;
|
|
7269
|
+
let LanguageWordInAnimeTitle = _LanguageWordInAnimeTitle;
|
|
7174
7270
|
const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle extends Rule {
|
|
7175
7271
|
constructor() {
|
|
7176
7272
|
super(...arguments);
|
|
@@ -7331,7 +7427,7 @@ function title(config) {
|
|
|
7331
7427
|
const rebulk = new Rebulk({
|
|
7332
7428
|
disabled: (context) => isDisabled(context, "title")
|
|
7333
7429
|
});
|
|
7334
|
-
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, WordNumeralPartAtTitlePosition, BonusAtTitlePositionRule, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
|
|
7430
|
+
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, WordNumeralPartAtTitlePosition, BonusAtTitlePositionRule, LanguageWordInAnimeTitle, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
|
|
7335
7431
|
const expectedTitle = buildExpectedFunction("expected_title");
|
|
7336
7432
|
rebulk.functional(expectedTitle, {
|
|
7337
7433
|
name: "title",
|
|
@@ -11540,8 +11636,8 @@ const advanced_config = {
|
|
|
11540
11636
|
"sub"
|
|
11541
11637
|
],
|
|
11542
11638
|
groups: {
|
|
11543
|
-
starting: "([{",
|
|
11544
|
-
ending: ")]}"
|
|
11639
|
+
starting: "([{【「(",
|
|
11640
|
+
ending: ")]}】」)"
|
|
11545
11641
|
},
|
|
11546
11642
|
audio_codec: {
|
|
11547
11643
|
audio_codec: {
|
|
@@ -12693,7 +12789,8 @@ const advanced_config = {
|
|
|
12693
12789
|
string: [
|
|
12694
12790
|
"Ova",
|
|
12695
12791
|
"Oav"
|
|
12696
|
-
]
|
|
12792
|
+
],
|
|
12793
|
+
tags: "title-word"
|
|
12697
12794
|
},
|
|
12698
12795
|
"Original Net Animation": "Ona",
|
|
12699
12796
|
"Original Animation DVD": "Oad",
|