guessit-js 4.4.1 → 4.5.0
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/dist/guessit-js.cjs +150 -11
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +150 -11
- package/dist/guessit-js.js.map +1 -1
- package/package.json +1 -1
package/dist/guessit-js.cjs
CHANGED
|
@@ -3521,7 +3521,7 @@ function episodes(config) {
|
|
|
3521
3521
|
chainBreaker: (matches) => episodesSeasonChainBreaker(matches, config),
|
|
3522
3522
|
disabled: isSeasonEpisodeDisabled
|
|
3523
3523
|
}).defaults({ tags: ["SxxExx"] }).regex(
|
|
3524
|
-
seasonMarkerPattern + `(?<season>\\d+)@?` + episodeMarkerPattern + `@?(?<episode>\\d+)
|
|
3524
|
+
seasonMarkerPattern + `(?<season>\\d+)@?` + episodeMarkerPattern + `@?(?<episode>\\d+)(?:[a-d](?![a-z0-9]))?(?:v(?<version>\\d+))?`
|
|
3525
3525
|
).repeater("+").regex(
|
|
3526
3526
|
allSeparatorsPattern + `@?(?<episode>\\d+)`
|
|
3527
3527
|
).repeater("*");
|
|
@@ -3563,6 +3563,10 @@ function episodes(config) {
|
|
|
3563
3563
|
`(?<season>\\d{1,2})(?:st|nd|rd|th)@?(?:season)(?![^\\W_])`,
|
|
3564
3564
|
{ tags: ["SxxExx", "numfirst"], disabled: isSeasonEpisodeDisabled }
|
|
3565
3565
|
);
|
|
3566
|
+
rebulk.regex(
|
|
3567
|
+
`(?<!\\d)(?<season>\\d{1,2})(?<episodeMarker>x)(?<episode>\\d{2})(?!\\d)`,
|
|
3568
|
+
{ tags: ["SxxExx"], disabled: isSeasonEpisodeDisabled }
|
|
3569
|
+
);
|
|
3566
3570
|
const seasonOnlySepPattern = buildOrPattern(
|
|
3567
3571
|
[...config.season_markers, ...discreteSeparators, ...config.range_separators],
|
|
3568
3572
|
"seasonSeparator",
|
|
@@ -3605,7 +3609,8 @@ function episodes(config) {
|
|
|
3605
3609
|
validator: { season: seasonWordNotYear, season_count: validateRoman },
|
|
3606
3610
|
conflictSolver: seasonEpisodeConflictSolver
|
|
3607
3611
|
}).regex(seasonWordPattern + `@?(?P<season>${numeralWithWords})`).regex(ofWordPattern + `@?(?P<season_count>${numeral})`).repeater("?").regex(
|
|
3608
|
-
|
|
3612
|
+
// an optional comma before the separator covers list forms like ", & 6"
|
|
3613
|
+
`(?:,@?)?@?` + buildOrPattern(
|
|
3609
3614
|
[...config.range_separators, ...discreteSeparators, "@"],
|
|
3610
3615
|
"seasonSeparator",
|
|
3611
3616
|
true
|
|
@@ -3633,6 +3638,24 @@ function episodes(config) {
|
|
|
3633
3638
|
);
|
|
3634
3639
|
}
|
|
3635
3640
|
const episodeWordPattern = buildOrPattern(episodeWords, "episodeMarker");
|
|
3641
|
+
rebulk.regex(
|
|
3642
|
+
buildOrPattern(episodeWords, "episodeMarker") + `@?(?<season>\\d{1,2})\\.(?<episode>\\d{2,3})(?!\\d)`,
|
|
3643
|
+
{ tags: ["SxxExx"], disabled: isSeasonEpisodeDisabled }
|
|
3644
|
+
);
|
|
3645
|
+
rebulk.regex(
|
|
3646
|
+
`(?<=[\\s([_-][\\s._-]?)(?<season>\\d{1,2})\\.(?<episode>\\d{2,3})(?=[\\s)\\]._-]|$)(?!\\.\\d)`,
|
|
3647
|
+
{
|
|
3648
|
+
tags: ["SxxExx", "decimal-episode"],
|
|
3649
|
+
validator: {
|
|
3650
|
+
__parent__: (m) => {
|
|
3651
|
+
const inp = m.inputString ?? "";
|
|
3652
|
+
const before = inp.slice(Math.max(0, m.start - 3), m.start);
|
|
3653
|
+
return /[-([]\s?$|^\s*$|\s-\s$/.test(before) || /[([]/.test(before);
|
|
3654
|
+
}
|
|
3655
|
+
},
|
|
3656
|
+
disabled: isSeasonEpisodeDisabled
|
|
3657
|
+
}
|
|
3658
|
+
);
|
|
3636
3659
|
rebulk.regex(
|
|
3637
3660
|
`(?<![a-zA-Z\\d])` + episodeWordPattern + `@?(?<episode>\\d+)(?:v(?<version>\\d+))?(?:@?` + ofWordPattern + `@?(?<count>\\d+))?`,
|
|
3638
3661
|
{
|
|
@@ -3658,13 +3681,13 @@ function episodes(config) {
|
|
|
3658
3681
|
rebulk.chain({
|
|
3659
3682
|
tags: ["weak-episode"],
|
|
3660
3683
|
disabled: (context) => context?.type === "movie" || isDisabled(context, "episode")
|
|
3661
|
-
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])(?<episode>\\d{2})(?!(?:st|nd|rd|th)\\b)(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{2})`, {
|
|
3684
|
+
}).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})`, {
|
|
3662
3685
|
abbreviations: null
|
|
3663
3686
|
}).repeater("*");
|
|
3664
3687
|
rebulk.chain({
|
|
3665
3688
|
tags: ["weak-episode"],
|
|
3666
3689
|
disabled: (context) => context?.type === "movie" || isDisabled(context, "episode")
|
|
3667
|
-
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])0(?<episode>\\d{1,2})(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])0(?<episode>\\d{1,2})`, {
|
|
3690
|
+
}).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})`, {
|
|
3668
3691
|
abbreviations: null
|
|
3669
3692
|
}).repeater("*");
|
|
3670
3693
|
rebulk.chain({
|
|
@@ -3675,7 +3698,7 @@ function episodes(config) {
|
|
|
3675
3698
|
validator: null,
|
|
3676
3699
|
tags: ["weak-episode"],
|
|
3677
3700
|
name: "weak_episode"
|
|
3678
|
-
}).regex(`(?<![^\\W_])(?<episode>\\d{3,4})(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{3,4})`, {
|
|
3701
|
+
}).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})`, {
|
|
3679
3702
|
abbreviations: null
|
|
3680
3703
|
}).repeater("*");
|
|
3681
3704
|
rebulk.chain({
|
|
@@ -3738,6 +3761,7 @@ function episodes(config) {
|
|
|
3738
3761
|
disabled: (context) => isDisabled(context, "episode_format")
|
|
3739
3762
|
});
|
|
3740
3763
|
rebulk.rules(
|
|
3764
|
+
EpisodeWordBeforeYearAsTitle,
|
|
3741
3765
|
RemoveGroupSuffixSeason,
|
|
3742
3766
|
AnimeTrailingEpisodeRule,
|
|
3743
3767
|
PreferAnchoredWeakEpisodeRule,
|
|
@@ -3794,6 +3818,40 @@ const _RemoveGroupSuffixSeason = class _RemoveGroupSuffixSeason extends Rule {
|
|
|
3794
3818
|
};
|
|
3795
3819
|
_RemoveGroupSuffixSeason.priority = 72;
|
|
3796
3820
|
let RemoveGroupSuffixSeason = _RemoveGroupSuffixSeason;
|
|
3821
|
+
const _EpisodeWordBeforeYearAsTitle = class _EpisodeWordBeforeYearAsTitle extends Rule {
|
|
3822
|
+
constructor() {
|
|
3823
|
+
super(...arguments);
|
|
3824
|
+
this.priority = 60;
|
|
3825
|
+
this.consequence = RemoveMatch;
|
|
3826
|
+
}
|
|
3827
|
+
when(matches, _context) {
|
|
3828
|
+
const toRemove = [];
|
|
3829
|
+
for (const episode of matches.named("episode") ?? []) {
|
|
3830
|
+
const init = episode.initiator ?? episode;
|
|
3831
|
+
const marker = [...init.children ?? []].find((c) => c.name === "episodeMarker");
|
|
3832
|
+
if (!marker || String(marker.raw ?? "").length < 3) continue;
|
|
3833
|
+
const filepart = matches.markers.atMatch(episode, (m) => m.name === "path", 0);
|
|
3834
|
+
if (!filepart) continue;
|
|
3835
|
+
const year = matches.range(episode.end, filepart.end, (m) => !m.private && m.name === "year", 0);
|
|
3836
|
+
if (!year) continue;
|
|
3837
|
+
const seasonish = matches.range(
|
|
3838
|
+
filepart.start,
|
|
3839
|
+
filepart.end,
|
|
3840
|
+
(m) => !m.private && (m.name === "season" || m.name === "episode" && m.tags?.includes("SxxExx")),
|
|
3841
|
+
0
|
|
3842
|
+
);
|
|
3843
|
+
if (seasonish) continue;
|
|
3844
|
+
const between = String(matches.inputString ?? "").slice(episode.end, year.start);
|
|
3845
|
+
if (!/[a-zA-Z]{2,}/.test(between)) continue;
|
|
3846
|
+
toRemove.push(episode);
|
|
3847
|
+
if (!toRemove.includes(init)) toRemove.push(init);
|
|
3848
|
+
for (const c of init.children ?? []) if (!toRemove.includes(c)) toRemove.push(c);
|
|
3849
|
+
}
|
|
3850
|
+
return toRemove.length ? toRemove : false;
|
|
3851
|
+
}
|
|
3852
|
+
};
|
|
3853
|
+
_EpisodeWordBeforeYearAsTitle.priority = 60;
|
|
3854
|
+
let EpisodeWordBeforeYearAsTitle = _EpisodeWordBeforeYearAsTitle;
|
|
3797
3855
|
const _AnimeTrailingEpisodeRule = class _AnimeTrailingEpisodeRule extends Rule {
|
|
3798
3856
|
constructor() {
|
|
3799
3857
|
super(...arguments);
|
|
@@ -4171,7 +4229,8 @@ class RangeExpansionRule extends Rule {
|
|
|
4171
4229
|
const betweenClean = between.replace(/[\s.]/g, "").toLowerCase();
|
|
4172
4230
|
const betweenStripMarkers = betweenClean.replace(/[sexp]/gi, "");
|
|
4173
4231
|
const hasRangeChar = /[-~_]/.test(between);
|
|
4174
|
-
const
|
|
4232
|
+
const seasonColon = name === "season" && betweenClean === ":";
|
|
4233
|
+
const isRange = hasRangeChar || seasonColon || rangeSeps.has(betweenClean) || rangeSeps.has(betweenStripMarkers);
|
|
4175
4234
|
if (isRange) {
|
|
4176
4235
|
for (let v = curVal + 1; v < nextVal; v++) {
|
|
4177
4236
|
const m = new Match(current.start, next.end, {
|
|
@@ -7079,6 +7138,41 @@ const _WordNumeralPartAtTitlePosition = class _WordNumeralPartAtTitlePosition ex
|
|
|
7079
7138
|
};
|
|
7080
7139
|
_WordNumeralPartAtTitlePosition.priority = 64;
|
|
7081
7140
|
let WordNumeralPartAtTitlePosition = _WordNumeralPartAtTitlePosition;
|
|
7141
|
+
const _BonusAtTitlePositionRule = class _BonusAtTitlePositionRule extends Rule {
|
|
7142
|
+
constructor() {
|
|
7143
|
+
super(...arguments);
|
|
7144
|
+
this.priority = 64;
|
|
7145
|
+
this.consequence = RemoveMatch;
|
|
7146
|
+
}
|
|
7147
|
+
when(matches, context) {
|
|
7148
|
+
if (isDisabled(context, "bonus")) return false;
|
|
7149
|
+
const toRemove = [];
|
|
7150
|
+
for (const bonus2 of matches.named("bonus") ?? []) {
|
|
7151
|
+
const filepart = matches.markers.atMatch(bonus2, (m) => m.name === "path", 0);
|
|
7152
|
+
if (!filepart) continue;
|
|
7153
|
+
const anime = matches.range(filepart.start, filepart.end, (m) => m.name === "crc32", 0) || matches.markers.range(
|
|
7154
|
+
filepart.start,
|
|
7155
|
+
filepart.end,
|
|
7156
|
+
(m) => m.name === "group" && m.start === filepart.start,
|
|
7157
|
+
0
|
|
7158
|
+
);
|
|
7159
|
+
if (!anime) continue;
|
|
7160
|
+
const anchor = matches.range(
|
|
7161
|
+
bonus2.end,
|
|
7162
|
+
filepart.end,
|
|
7163
|
+
(m) => !m.private && ["episode", "season", "year", "date"].includes(m.name ?? ""),
|
|
7164
|
+
0
|
|
7165
|
+
);
|
|
7166
|
+
const bonusTitles = matches.named("bonus_title") ?? [];
|
|
7167
|
+
if (!anchor && !bonusTitles.length) continue;
|
|
7168
|
+
toRemove.push(bonus2);
|
|
7169
|
+
toRemove.push(...bonusTitles.filter((bt) => bt.start >= filepart.start && bt.end <= filepart.end));
|
|
7170
|
+
}
|
|
7171
|
+
return toRemove.length ? toRemove : false;
|
|
7172
|
+
}
|
|
7173
|
+
};
|
|
7174
|
+
_BonusAtTitlePositionRule.priority = 64;
|
|
7175
|
+
let BonusAtTitlePositionRule = _BonusAtTitlePositionRule;
|
|
7082
7176
|
const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle extends Rule {
|
|
7083
7177
|
constructor() {
|
|
7084
7178
|
super(...arguments);
|
|
@@ -7096,7 +7190,16 @@ const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle ex
|
|
|
7096
7190
|
(m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
|
|
7097
7191
|
0
|
|
7098
7192
|
);
|
|
7099
|
-
if (!anchor)
|
|
7193
|
+
if (!anchor) {
|
|
7194
|
+
const anyTitle = matches.range(filepart.start, filepart.end, (m) => m.name === "title", 0);
|
|
7195
|
+
if (lead.name === "year" && lead.start === filepart.start && !anyTitle) {
|
|
7196
|
+
lead.name = "title";
|
|
7197
|
+
lead.value = String(matches.inputString ?? "").slice(lead.start, lead.end);
|
|
7198
|
+
out.push(lead);
|
|
7199
|
+
continue;
|
|
7200
|
+
}
|
|
7201
|
+
continue;
|
|
7202
|
+
}
|
|
7100
7203
|
const yearTitled = lead.name === "year" && ["season", "episode"].includes(anchor.name ?? "") && !anchor.tags?.includes("weak-episode") && !anchor.tags?.includes("weak-duplicate");
|
|
7101
7204
|
if (!yearTitled && !["other", "country", "edition"].includes(lead.name ?? "")) continue;
|
|
7102
7205
|
const titles = matches.range(filepart.start, filepart.end, (m) => m.name === "title") ?? [];
|
|
@@ -7230,7 +7333,7 @@ function title(config) {
|
|
|
7230
7333
|
const rebulk = new Rebulk({
|
|
7231
7334
|
disabled: (context) => isDisabled(context, "title")
|
|
7232
7335
|
});
|
|
7233
|
-
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, WordNumeralPartAtTitlePosition, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
|
|
7336
|
+
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, WordNumeralPartAtTitlePosition, BonusAtTitlePositionRule, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
|
|
7234
7337
|
const expectedTitle = buildExpectedFunction("expected_title");
|
|
7235
7338
|
rebulk.functional(expectedTitle, {
|
|
7236
7339
|
name: "title",
|
|
@@ -9222,6 +9325,7 @@ function releaseGroup(config) {
|
|
|
9222
9325
|
new SceneReleaseGroup(cleanGroupname),
|
|
9223
9326
|
AnimeReleaseGroup,
|
|
9224
9327
|
new TrailingTokenAfterEpisodeAsReleaseGroup(cleanGroupname),
|
|
9328
|
+
NumericPrefixedGroupRule,
|
|
9225
9329
|
RemoveSeasonPackReleaseGroup
|
|
9226
9330
|
);
|
|
9227
9331
|
}
|
|
@@ -9567,6 +9671,39 @@ _AnimeReleaseGroup.dependency = ["SceneReleaseGroup", "TitleFromPosition"];
|
|
|
9567
9671
|
_AnimeReleaseGroup.consequence = [RemoveMatch, AppendMatch];
|
|
9568
9672
|
_AnimeReleaseGroup.properties = { release_group: [null] };
|
|
9569
9673
|
let AnimeReleaseGroup = _AnimeReleaseGroup;
|
|
9674
|
+
const _NumericPrefixedGroupRule = class _NumericPrefixedGroupRule extends Rule {
|
|
9675
|
+
constructor() {
|
|
9676
|
+
super(...arguments);
|
|
9677
|
+
this.priority = -32;
|
|
9678
|
+
this.consequence = [RemoveMatch, AppendMatch];
|
|
9679
|
+
}
|
|
9680
|
+
when(matches, _context) {
|
|
9681
|
+
const input = matches.inputString ?? "";
|
|
9682
|
+
const toRemove = [];
|
|
9683
|
+
const toAppend = [];
|
|
9684
|
+
for (const rg of matches.named("release_group") ?? []) {
|
|
9685
|
+
const m = /^(\d{1,3})\s*\[([^\]]+)\]$/.exec(String(rg.value ?? ""));
|
|
9686
|
+
if (!m) continue;
|
|
9687
|
+
const raw = input.slice(rg.start, rg.end);
|
|
9688
|
+
const numLen = m[1].length;
|
|
9689
|
+
toRemove.push(rg);
|
|
9690
|
+
toAppend.push(new Match(rg.start, rg.start + numLen, {
|
|
9691
|
+
name: "episode",
|
|
9692
|
+
value: parseInt(m[1], 10),
|
|
9693
|
+
inputString: input
|
|
9694
|
+
}));
|
|
9695
|
+
const inner = raw.indexOf("[");
|
|
9696
|
+
toAppend.push(new Match(rg.start + inner + 1, rg.end - 1, {
|
|
9697
|
+
name: "release_group",
|
|
9698
|
+
value: m[2],
|
|
9699
|
+
inputString: input
|
|
9700
|
+
}));
|
|
9701
|
+
}
|
|
9702
|
+
return toRemove.length || toAppend.length ? [toRemove, toAppend] : false;
|
|
9703
|
+
}
|
|
9704
|
+
};
|
|
9705
|
+
_NumericPrefixedGroupRule.priority = -32;
|
|
9706
|
+
let NumericPrefixedGroupRule = _NumericPrefixedGroupRule;
|
|
9570
9707
|
const _TrailingTokenAfterEpisodeAsReleaseGroup = class _TrailingTokenAfterEpisodeAsReleaseGroup extends Rule {
|
|
9571
9708
|
constructor(valueFormatter) {
|
|
9572
9709
|
super();
|
|
@@ -10776,10 +10913,11 @@ function imdb(_config) {
|
|
|
10776
10913
|
function volume(_config) {
|
|
10777
10914
|
const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "volume") });
|
|
10778
10915
|
rebulk.regexDefaults({ flags: "i" });
|
|
10779
|
-
rebulk.regex("vol(?:\\d{1,3}|(?:ume)?[-. ]\\d{1,3})", {
|
|
10916
|
+
rebulk.regex("vol(?:\\d{1,3}|(?:ume)?[-. ]{1,2}\\d{1,3})(?:v\\d)?(?:[&+]\\d{1,3})?", {
|
|
10780
10917
|
name: "volume",
|
|
10781
10918
|
validator: sepsSurround,
|
|
10782
|
-
formatter: (value) => parseInt(value.replace(
|
|
10919
|
+
formatter: (value) => parseInt(String(value).replace(/^vol(?:ume)?[-. ]*/i, "").replace(/[v&+].*$/i, ""), 10),
|
|
10920
|
+
conflictSolver: (match, other2) => other2.name === "episode" || other2.name === "season" ? other2 : "__default__"
|
|
10783
10921
|
});
|
|
10784
10922
|
return rebulk;
|
|
10785
10923
|
}
|
|
@@ -11941,7 +12079,8 @@ const advanced_config = {
|
|
|
11941
12079
|
episode_max_range: 100,
|
|
11942
12080
|
max_range_gap: 1,
|
|
11943
12081
|
season_markers: [
|
|
11944
|
-
"s"
|
|
12082
|
+
"s",
|
|
12083
|
+
"sn"
|
|
11945
12084
|
],
|
|
11946
12085
|
season_ep_markers: [
|
|
11947
12086
|
"x",
|