guessit-js 4.4.0 → 4.4.2
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 +110 -12
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +110 -12
- 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]))?`
|
|
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
|
{
|
|
@@ -3738,6 +3761,7 @@ function episodes(config) {
|
|
|
3738
3761
|
disabled: (context) => isDisabled(context, "episode_format")
|
|
3739
3762
|
});
|
|
3740
3763
|
rebulk.rules(
|
|
3764
|
+
RemoveGroupSuffixSeason,
|
|
3741
3765
|
AnimeTrailingEpisodeRule,
|
|
3742
3766
|
PreferAnchoredWeakEpisodeRule,
|
|
3743
3767
|
SeasonWordDashedEpisodeRule,
|
|
@@ -3756,6 +3780,43 @@ function episodes(config) {
|
|
|
3756
3780
|
);
|
|
3757
3781
|
return rebulk;
|
|
3758
3782
|
}
|
|
3783
|
+
const _RemoveGroupSuffixSeason = class _RemoveGroupSuffixSeason extends Rule {
|
|
3784
|
+
constructor() {
|
|
3785
|
+
super(...arguments);
|
|
3786
|
+
this.priority = 72;
|
|
3787
|
+
this.consequence = RemoveMatch;
|
|
3788
|
+
}
|
|
3789
|
+
when(matches, _context) {
|
|
3790
|
+
const input = matches.inputString ?? "";
|
|
3791
|
+
const toRemove = [];
|
|
3792
|
+
const TOKENS = /* @__PURE__ */ new Set(["audio_codec", "audio_channels", "video_codec", "audio_profile", "other"]);
|
|
3793
|
+
for (const season of matches.named("season") ?? []) {
|
|
3794
|
+
const init = season.initiator ?? season;
|
|
3795
|
+
if (!/^s\d{1,3}$/i.test(String(init.raw ?? ""))) continue;
|
|
3796
|
+
const hasEpisode = [...init.children ?? []].some((c) => c.name === "episode");
|
|
3797
|
+
if (hasEpisode) continue;
|
|
3798
|
+
if (input[init.start - 1] !== "-") continue;
|
|
3799
|
+
const prev = matches.range(
|
|
3800
|
+
Math.max(0, init.start - 12),
|
|
3801
|
+
init.start - 1,
|
|
3802
|
+
(m) => !m.private && TOKENS.has(m.name ?? ""),
|
|
3803
|
+
-1
|
|
3804
|
+
) ?? matches.range(
|
|
3805
|
+
Math.max(0, init.start - 12),
|
|
3806
|
+
init.start - 1,
|
|
3807
|
+
(m) => !m.private && TOKENS.has(m.name ?? ""),
|
|
3808
|
+
0
|
|
3809
|
+
);
|
|
3810
|
+
const inGroup = matches.markers.atMatch(init, (m) => m.name === "group", 0);
|
|
3811
|
+
if (!prev && !inGroup) continue;
|
|
3812
|
+
toRemove.push(season);
|
|
3813
|
+
for (const c of init.children ?? []) if (!toRemove.includes(c)) toRemove.push(c);
|
|
3814
|
+
}
|
|
3815
|
+
return toRemove.length ? toRemove : false;
|
|
3816
|
+
}
|
|
3817
|
+
};
|
|
3818
|
+
_RemoveGroupSuffixSeason.priority = 72;
|
|
3819
|
+
let RemoveGroupSuffixSeason = _RemoveGroupSuffixSeason;
|
|
3759
3820
|
const _AnimeTrailingEpisodeRule = class _AnimeTrailingEpisodeRule extends Rule {
|
|
3760
3821
|
constructor() {
|
|
3761
3822
|
super(...arguments);
|
|
@@ -4133,7 +4194,8 @@ class RangeExpansionRule extends Rule {
|
|
|
4133
4194
|
const betweenClean = between.replace(/[\s.]/g, "").toLowerCase();
|
|
4134
4195
|
const betweenStripMarkers = betweenClean.replace(/[sexp]/gi, "");
|
|
4135
4196
|
const hasRangeChar = /[-~_]/.test(between);
|
|
4136
|
-
const
|
|
4197
|
+
const seasonColon = name === "season" && betweenClean === ":";
|
|
4198
|
+
const isRange = hasRangeChar || seasonColon || rangeSeps.has(betweenClean) || rangeSeps.has(betweenStripMarkers);
|
|
4137
4199
|
if (isRange) {
|
|
4138
4200
|
for (let v = curVal + 1; v < nextVal; v++) {
|
|
4139
4201
|
const m = new Match(current.start, next.end, {
|
|
@@ -7011,6 +7073,36 @@ const _BracketedTitleFallback = class _BracketedTitleFallback extends Rule {
|
|
|
7011
7073
|
};
|
|
7012
7074
|
_BracketedTitleFallback.priority = POST_PROCESS;
|
|
7013
7075
|
let BracketedTitleFallback = _BracketedTitleFallback;
|
|
7076
|
+
const _WordNumeralPartAtTitlePosition = class _WordNumeralPartAtTitlePosition extends Rule {
|
|
7077
|
+
constructor() {
|
|
7078
|
+
super(...arguments);
|
|
7079
|
+
this.priority = 64;
|
|
7080
|
+
this.consequence = RemoveMatch;
|
|
7081
|
+
}
|
|
7082
|
+
when(matches, context) {
|
|
7083
|
+
if (isDisabled(context, "part")) return false;
|
|
7084
|
+
const toRemove = [];
|
|
7085
|
+
for (const part2 of matches.named("part") ?? []) {
|
|
7086
|
+
const target = part2.initiator ?? part2;
|
|
7087
|
+
if (/\d/.test(String(target.raw ?? ""))) continue;
|
|
7088
|
+
const filepart = matches.markers.atMatch(part2, (m) => m.name === "path", 0);
|
|
7089
|
+
if (!filepart) continue;
|
|
7090
|
+
const anchor = matches.range(
|
|
7091
|
+
part2.end,
|
|
7092
|
+
filepart.end,
|
|
7093
|
+
(m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
|
|
7094
|
+
0
|
|
7095
|
+
);
|
|
7096
|
+
if (!anchor) continue;
|
|
7097
|
+
toRemove.push(part2);
|
|
7098
|
+
for (const c of [...target.children ?? []]) if (!toRemove.includes(c)) toRemove.push(c);
|
|
7099
|
+
if (target !== part2 && !toRemove.includes(target)) toRemove.push(target);
|
|
7100
|
+
}
|
|
7101
|
+
return toRemove.length ? toRemove : false;
|
|
7102
|
+
}
|
|
7103
|
+
};
|
|
7104
|
+
_WordNumeralPartAtTitlePosition.priority = 64;
|
|
7105
|
+
let WordNumeralPartAtTitlePosition = _WordNumeralPartAtTitlePosition;
|
|
7014
7106
|
const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle extends Rule {
|
|
7015
7107
|
constructor() {
|
|
7016
7108
|
super(...arguments);
|
|
@@ -7020,18 +7112,22 @@ const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle ex
|
|
|
7020
7112
|
const inp = matches.inputString || "";
|
|
7021
7113
|
const out = [];
|
|
7022
7114
|
for (const filepart of matches.markers.named("path")) {
|
|
7023
|
-
|
|
7115
|
+
const lead = matches.range(filepart.start, filepart.end, (m) => !m.private && !!m.value, 0);
|
|
7116
|
+
if (!lead) continue;
|
|
7024
7117
|
const anchor = matches.range(
|
|
7025
|
-
|
|
7118
|
+
lead.end,
|
|
7026
7119
|
filepart.end,
|
|
7027
7120
|
(m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
|
|
7028
7121
|
0
|
|
7029
7122
|
);
|
|
7030
7123
|
if (!anchor) continue;
|
|
7031
|
-
const
|
|
7032
|
-
if (!
|
|
7033
|
-
|
|
7034
|
-
if ((
|
|
7124
|
+
const yearTitled = lead.name === "year" && ["season", "episode"].includes(anchor.name ?? "") && !anchor.tags?.includes("weak-episode") && !anchor.tags?.includes("weak-duplicate");
|
|
7125
|
+
if (!yearTitled && !["other", "country", "edition"].includes(lead.name ?? "")) continue;
|
|
7126
|
+
const titles = matches.range(filepart.start, filepart.end, (m) => m.name === "title") ?? [];
|
|
7127
|
+
if (titles.some((t) => t.start < anchor.end)) continue;
|
|
7128
|
+
if (titles.length && !yearTitled) continue;
|
|
7129
|
+
out.push(...titles);
|
|
7130
|
+
if (lead.name !== "year" && (lead.raw ?? "") === String(lead.value ?? "")) continue;
|
|
7035
7131
|
if (![...inp.slice(filepart.start, lead.start)].every((c) => seps.includes(c))) continue;
|
|
7036
7132
|
out.push(lead);
|
|
7037
7133
|
}
|
|
@@ -7158,7 +7254,7 @@ function title(config) {
|
|
|
7158
7254
|
const rebulk = new Rebulk({
|
|
7159
7255
|
disabled: (context) => isDisabled(context, "title")
|
|
7160
7256
|
});
|
|
7161
|
-
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
|
|
7257
|
+
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, WordNumeralPartAtTitlePosition, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
|
|
7162
7258
|
const expectedTitle = buildExpectedFunction("expected_title");
|
|
7163
7259
|
rebulk.functional(expectedTitle, {
|
|
7164
7260
|
name: "title",
|
|
@@ -11355,7 +11451,8 @@ const advanced_config = {
|
|
|
11355
11451
|
regex: [
|
|
11356
11452
|
"Dolby-Digital",
|
|
11357
11453
|
"DD",
|
|
11358
|
-
"AC-?3D?"
|
|
11454
|
+
"AC-?3D?",
|
|
11455
|
+
"DolbyD"
|
|
11359
11456
|
]
|
|
11360
11457
|
},
|
|
11361
11458
|
"Dolby Atmos": {
|
|
@@ -11868,7 +11965,8 @@ const advanced_config = {
|
|
|
11868
11965
|
episode_max_range: 100,
|
|
11869
11966
|
max_range_gap: 1,
|
|
11870
11967
|
season_markers: [
|
|
11871
|
-
"s"
|
|
11968
|
+
"s",
|
|
11969
|
+
"sn"
|
|
11872
11970
|
],
|
|
11873
11971
|
season_ep_markers: [
|
|
11874
11972
|
"x",
|