guessit-js 4.4.2 → 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 +122 -8
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +122 -8
- 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+)(?:[a-d](?![a-z0-9]))?`
|
|
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("*");
|
|
@@ -3681,13 +3681,13 @@ function episodes(config) {
|
|
|
3681
3681
|
rebulk.chain({
|
|
3682
3682
|
tags: ["weak-episode"],
|
|
3683
3683
|
disabled: (context) => context?.type === "movie" || isDisabled(context, "episode")
|
|
3684
|
-
}).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})`, {
|
|
3685
3685
|
abbreviations: null
|
|
3686
3686
|
}).repeater("*");
|
|
3687
3687
|
rebulk.chain({
|
|
3688
3688
|
tags: ["weak-episode"],
|
|
3689
3689
|
disabled: (context) => context?.type === "movie" || isDisabled(context, "episode")
|
|
3690
|
-
}).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})`, {
|
|
3691
3691
|
abbreviations: null
|
|
3692
3692
|
}).repeater("*");
|
|
3693
3693
|
rebulk.chain({
|
|
@@ -3698,7 +3698,7 @@ function episodes(config) {
|
|
|
3698
3698
|
validator: null,
|
|
3699
3699
|
tags: ["weak-episode"],
|
|
3700
3700
|
name: "weak_episode"
|
|
3701
|
-
}).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})`, {
|
|
3702
3702
|
abbreviations: null
|
|
3703
3703
|
}).repeater("*");
|
|
3704
3704
|
rebulk.chain({
|
|
@@ -3761,6 +3761,7 @@ function episodes(config) {
|
|
|
3761
3761
|
disabled: (context) => isDisabled(context, "episode_format")
|
|
3762
3762
|
});
|
|
3763
3763
|
rebulk.rules(
|
|
3764
|
+
EpisodeWordBeforeYearAsTitle,
|
|
3764
3765
|
RemoveGroupSuffixSeason,
|
|
3765
3766
|
AnimeTrailingEpisodeRule,
|
|
3766
3767
|
PreferAnchoredWeakEpisodeRule,
|
|
@@ -3817,6 +3818,40 @@ const _RemoveGroupSuffixSeason = class _RemoveGroupSuffixSeason extends Rule {
|
|
|
3817
3818
|
};
|
|
3818
3819
|
_RemoveGroupSuffixSeason.priority = 72;
|
|
3819
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;
|
|
3820
3855
|
const _AnimeTrailingEpisodeRule = class _AnimeTrailingEpisodeRule extends Rule {
|
|
3821
3856
|
constructor() {
|
|
3822
3857
|
super(...arguments);
|
|
@@ -7103,6 +7138,41 @@ const _WordNumeralPartAtTitlePosition = class _WordNumeralPartAtTitlePosition ex
|
|
|
7103
7138
|
};
|
|
7104
7139
|
_WordNumeralPartAtTitlePosition.priority = 64;
|
|
7105
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;
|
|
7106
7176
|
const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle extends Rule {
|
|
7107
7177
|
constructor() {
|
|
7108
7178
|
super(...arguments);
|
|
@@ -7120,7 +7190,16 @@ const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle ex
|
|
|
7120
7190
|
(m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
|
|
7121
7191
|
0
|
|
7122
7192
|
);
|
|
7123
|
-
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
|
+
}
|
|
7124
7203
|
const yearTitled = lead.name === "year" && ["season", "episode"].includes(anchor.name ?? "") && !anchor.tags?.includes("weak-episode") && !anchor.tags?.includes("weak-duplicate");
|
|
7125
7204
|
if (!yearTitled && !["other", "country", "edition"].includes(lead.name ?? "")) continue;
|
|
7126
7205
|
const titles = matches.range(filepart.start, filepart.end, (m) => m.name === "title") ?? [];
|
|
@@ -7254,7 +7333,7 @@ function title(config) {
|
|
|
7254
7333
|
const rebulk = new Rebulk({
|
|
7255
7334
|
disabled: (context) => isDisabled(context, "title")
|
|
7256
7335
|
});
|
|
7257
|
-
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);
|
|
7258
7337
|
const expectedTitle = buildExpectedFunction("expected_title");
|
|
7259
7338
|
rebulk.functional(expectedTitle, {
|
|
7260
7339
|
name: "title",
|
|
@@ -9246,6 +9325,7 @@ function releaseGroup(config) {
|
|
|
9246
9325
|
new SceneReleaseGroup(cleanGroupname),
|
|
9247
9326
|
AnimeReleaseGroup,
|
|
9248
9327
|
new TrailingTokenAfterEpisodeAsReleaseGroup(cleanGroupname),
|
|
9328
|
+
NumericPrefixedGroupRule,
|
|
9249
9329
|
RemoveSeasonPackReleaseGroup
|
|
9250
9330
|
);
|
|
9251
9331
|
}
|
|
@@ -9591,6 +9671,39 @@ _AnimeReleaseGroup.dependency = ["SceneReleaseGroup", "TitleFromPosition"];
|
|
|
9591
9671
|
_AnimeReleaseGroup.consequence = [RemoveMatch, AppendMatch];
|
|
9592
9672
|
_AnimeReleaseGroup.properties = { release_group: [null] };
|
|
9593
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;
|
|
9594
9707
|
const _TrailingTokenAfterEpisodeAsReleaseGroup = class _TrailingTokenAfterEpisodeAsReleaseGroup extends Rule {
|
|
9595
9708
|
constructor(valueFormatter) {
|
|
9596
9709
|
super();
|
|
@@ -10800,10 +10913,11 @@ function imdb(_config) {
|
|
|
10800
10913
|
function volume(_config) {
|
|
10801
10914
|
const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "volume") });
|
|
10802
10915
|
rebulk.regexDefaults({ flags: "i" });
|
|
10803
|
-
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})?", {
|
|
10804
10917
|
name: "volume",
|
|
10805
10918
|
validator: sepsSurround,
|
|
10806
|
-
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__"
|
|
10807
10921
|
});
|
|
10808
10922
|
return rebulk;
|
|
10809
10923
|
}
|