guessit-js 4.3.2 → 4.4.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/dist/guessit-js.cjs +128 -24
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +128 -24
- package/dist/guessit-js.js.map +1 -1
- package/package.json +1 -1
package/dist/guessit-js.cjs
CHANGED
|
@@ -3738,6 +3738,7 @@ function episodes(config) {
|
|
|
3738
3738
|
disabled: (context) => isDisabled(context, "episode_format")
|
|
3739
3739
|
});
|
|
3740
3740
|
rebulk.rules(
|
|
3741
|
+
RemoveGroupSuffixSeason,
|
|
3741
3742
|
AnimeTrailingEpisodeRule,
|
|
3742
3743
|
PreferAnchoredWeakEpisodeRule,
|
|
3743
3744
|
SeasonWordDashedEpisodeRule,
|
|
@@ -3756,6 +3757,43 @@ function episodes(config) {
|
|
|
3756
3757
|
);
|
|
3757
3758
|
return rebulk;
|
|
3758
3759
|
}
|
|
3760
|
+
const _RemoveGroupSuffixSeason = class _RemoveGroupSuffixSeason extends Rule {
|
|
3761
|
+
constructor() {
|
|
3762
|
+
super(...arguments);
|
|
3763
|
+
this.priority = 72;
|
|
3764
|
+
this.consequence = RemoveMatch;
|
|
3765
|
+
}
|
|
3766
|
+
when(matches, _context) {
|
|
3767
|
+
const input = matches.inputString ?? "";
|
|
3768
|
+
const toRemove = [];
|
|
3769
|
+
const TOKENS = /* @__PURE__ */ new Set(["audio_codec", "audio_channels", "video_codec", "audio_profile", "other"]);
|
|
3770
|
+
for (const season of matches.named("season") ?? []) {
|
|
3771
|
+
const init = season.initiator ?? season;
|
|
3772
|
+
if (!/^s\d{1,3}$/i.test(String(init.raw ?? ""))) continue;
|
|
3773
|
+
const hasEpisode = [...init.children ?? []].some((c) => c.name === "episode");
|
|
3774
|
+
if (hasEpisode) continue;
|
|
3775
|
+
if (input[init.start - 1] !== "-") continue;
|
|
3776
|
+
const prev = matches.range(
|
|
3777
|
+
Math.max(0, init.start - 12),
|
|
3778
|
+
init.start - 1,
|
|
3779
|
+
(m) => !m.private && TOKENS.has(m.name ?? ""),
|
|
3780
|
+
-1
|
|
3781
|
+
) ?? matches.range(
|
|
3782
|
+
Math.max(0, init.start - 12),
|
|
3783
|
+
init.start - 1,
|
|
3784
|
+
(m) => !m.private && TOKENS.has(m.name ?? ""),
|
|
3785
|
+
0
|
|
3786
|
+
);
|
|
3787
|
+
const inGroup = matches.markers.atMatch(init, (m) => m.name === "group", 0);
|
|
3788
|
+
if (!prev && !inGroup) continue;
|
|
3789
|
+
toRemove.push(season);
|
|
3790
|
+
for (const c of init.children ?? []) if (!toRemove.includes(c)) toRemove.push(c);
|
|
3791
|
+
}
|
|
3792
|
+
return toRemove.length ? toRemove : false;
|
|
3793
|
+
}
|
|
3794
|
+
};
|
|
3795
|
+
_RemoveGroupSuffixSeason.priority = 72;
|
|
3796
|
+
let RemoveGroupSuffixSeason = _RemoveGroupSuffixSeason;
|
|
3759
3797
|
const _AnimeTrailingEpisodeRule = class _AnimeTrailingEpisodeRule extends Rule {
|
|
3760
3798
|
constructor() {
|
|
3761
3799
|
super(...arguments);
|
|
@@ -3776,7 +3814,12 @@ const _AnimeTrailingEpisodeRule = class _AnimeTrailingEpisodeRule extends Rule {
|
|
|
3776
3814
|
(m2) => m2.name === "release_group" && m2.tags?.includes("anime"),
|
|
3777
3815
|
0
|
|
3778
3816
|
);
|
|
3779
|
-
|
|
3817
|
+
const groupCount = (matches.markers.range(
|
|
3818
|
+
filepart.start,
|
|
3819
|
+
filepart.end,
|
|
3820
|
+
(m2) => m2.name === "group"
|
|
3821
|
+
) ?? []).length;
|
|
3822
|
+
if (!crc2 && !animeRg && groupCount < 3) continue;
|
|
3780
3823
|
let done = false;
|
|
3781
3824
|
for (const group of matches.markers.range(filepart.start, filepart.end, (m2) => m2.name === "group") ?? []) {
|
|
3782
3825
|
const core = input.slice(group.start + 1, group.end - 1).trim();
|
|
@@ -3932,10 +3975,11 @@ const _RemoveNumfirstMarkerCollision = class _RemoveNumfirstMarkerCollision exte
|
|
|
3932
3975
|
constructor() {
|
|
3933
3976
|
super(...arguments);
|
|
3934
3977
|
this.priority = 70;
|
|
3935
|
-
this.consequence = RemoveMatch;
|
|
3978
|
+
this.consequence = [RemoveMatch, AppendMatch];
|
|
3936
3979
|
}
|
|
3937
3980
|
when(matches, _context) {
|
|
3938
3981
|
const toRemove = [];
|
|
3982
|
+
const toAppend = [];
|
|
3939
3983
|
const isWeak = (m) => !!(m.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(m.initiator?.name));
|
|
3940
3984
|
const removeWithParent = (m) => {
|
|
3941
3985
|
const init = m.initiator ?? m;
|
|
@@ -3958,10 +4002,18 @@ const _RemoveNumfirstMarkerCollision = class _RemoveNumfirstMarkerCollision exte
|
|
|
3958
4002
|
if (!wordFirst) continue;
|
|
3959
4003
|
const claimed = all.some((m) => !m.private && (m.name === "screen_size" || m.name === "year") && m.start < wordFirst.end && wordFirst.start < m.end);
|
|
3960
4004
|
const gluedOrdinal = /^(?:st|nd|rd|th|ª|º|°)/i.test(String(matches.inputString ?? "").slice(nf.end, nf.end + 2));
|
|
3961
|
-
if (claimed || gluedOrdinal)
|
|
3962
|
-
|
|
4005
|
+
if (claimed || gluedOrdinal) {
|
|
4006
|
+
removeWithParent(wordFirst);
|
|
4007
|
+
if (!claimed) {
|
|
4008
|
+
toAppend.push(new Match(wordFirst.start, wordFirst.end, {
|
|
4009
|
+
name: "episode",
|
|
4010
|
+
value: wordFirst.value,
|
|
4011
|
+
inputString: matches.inputString
|
|
4012
|
+
}));
|
|
4013
|
+
}
|
|
4014
|
+
} else removeWithParent(nf);
|
|
3963
4015
|
}
|
|
3964
|
-
return toRemove.length ? toRemove : false;
|
|
4016
|
+
return toRemove.length || toAppend.length ? [toRemove, toAppend] : false;
|
|
3965
4017
|
}
|
|
3966
4018
|
};
|
|
3967
4019
|
_RemoveNumfirstMarkerCollision.priority = 70;
|
|
@@ -4921,12 +4973,15 @@ const _ValidateVideoCodec = class _ValidateVideoCodec extends Rule {
|
|
|
4921
4973
|
const ret = [];
|
|
4922
4974
|
const codecs = matches.named("video_codec");
|
|
4923
4975
|
const hasAny = (v) => Array.isArray(v) ? v.length > 0 : !!v;
|
|
4976
|
+
const inp = matches.inputString ?? "";
|
|
4924
4977
|
for (const codec of codecs) {
|
|
4925
|
-
|
|
4978
|
+
const bracketBefore = inp[codec.start] === "[" || inp[codec.start - 1] === "[";
|
|
4979
|
+
const bracketAfter = inp[codec.end - 1] === "]" || inp[codec.end] === "]";
|
|
4980
|
+
if (!bracketBefore && !sepsBefore(codec) && !hasAny(matches.atIndex(codec.start - 1, (m) => m.tags?.includes("video-codec-prefix")))) {
|
|
4926
4981
|
ret.push(codec);
|
|
4927
4982
|
continue;
|
|
4928
4983
|
}
|
|
4929
|
-
if (!sepsAfter(codec) && !hasAny(matches.atIndex(codec.end + 1, (m) => m.tags?.includes("video-codec-suffix")))) {
|
|
4984
|
+
if (!bracketAfter && !sepsAfter(codec) && !hasAny(matches.atIndex(codec.end + 1, (m) => m.tags?.includes("video-codec-suffix")))) {
|
|
4930
4985
|
ret.push(codec);
|
|
4931
4986
|
continue;
|
|
4932
4987
|
}
|
|
@@ -6431,7 +6486,20 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
|
|
|
6431
6486
|
console.log(` result: hole=[${trimmedHole.start},${trimmedHole.end}) length=${trimmedHole.length} value="${trimmedHole.value}"`);
|
|
6432
6487
|
}
|
|
6433
6488
|
if (trimmedHole.length > 0 && !this.shouldRemove(trimmedHole) && trimmedHole.value) {
|
|
6434
|
-
|
|
6489
|
+
matches.inputString ?? "";
|
|
6490
|
+
const animeStyle = matches.markers.range(
|
|
6491
|
+
filepart.start,
|
|
6492
|
+
filepart.end,
|
|
6493
|
+
(m) => m.name === "group" && m.start === filepart.start,
|
|
6494
|
+
0
|
|
6495
|
+
) !== void 0 || matches.range(filepart.start, filepart.end, (m) => m.name === "crc32", 0) !== void 0;
|
|
6496
|
+
let splitResult = this.alternativePropertyName && !isDisabled(context, this.alternativePropertyName) ? this.splitTitleAlternative(trimmedHole, inp) : null;
|
|
6497
|
+
if (splitResult && animeStyle && splitResult.alternatives.every((a) => {
|
|
6498
|
+
const v = String(a.value ?? "").trim();
|
|
6499
|
+
return v.length >= 4 || /\s/.test(v);
|
|
6500
|
+
})) {
|
|
6501
|
+
splitResult = null;
|
|
6502
|
+
}
|
|
6435
6503
|
if (splitResult) {
|
|
6436
6504
|
splitResult.title.name = this.matchName;
|
|
6437
6505
|
toAppend.push(splitResult.title);
|
|
@@ -6944,17 +7012,18 @@ const _BracketedTitleFallback = class _BracketedTitleFallback extends Rule {
|
|
|
6944
7012
|
if (rg && g.start <= rg.start && g.end >= rg.end) continue;
|
|
6945
7013
|
const core = input.slice(g.start + 1, g.end - 1);
|
|
6946
7014
|
if (!/[a-zA-Z]{2,}/.test(core)) continue;
|
|
6947
|
-
const
|
|
6948
|
-
|
|
6949
|
-
|
|
7015
|
+
const hole = matches.holes(g.start + 1, g.end - 1, {
|
|
7016
|
+
formatter: cleanup,
|
|
7017
|
+
predicate: (h) => !!h.value,
|
|
7018
|
+
index: 0
|
|
7019
|
+
});
|
|
7020
|
+
if (!hole || !/[a-zA-Z]{3,}/.test(String(hole.value ?? ""))) continue;
|
|
7021
|
+
candidate = hole;
|
|
6950
7022
|
break;
|
|
6951
7023
|
}
|
|
6952
7024
|
if (candidate) {
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
value: cleanup(input.slice(candidate.start + 1, candidate.end - 1)),
|
|
6956
|
-
inputString: input
|
|
6957
|
-
}));
|
|
7025
|
+
candidate.name = "title";
|
|
7026
|
+
toAppend.push(candidate);
|
|
6958
7027
|
continue;
|
|
6959
7028
|
}
|
|
6960
7029
|
if (rg && rg.tags?.includes("anime")) {
|
|
@@ -6980,6 +7049,36 @@ const _BracketedTitleFallback = class _BracketedTitleFallback extends Rule {
|
|
|
6980
7049
|
};
|
|
6981
7050
|
_BracketedTitleFallback.priority = POST_PROCESS;
|
|
6982
7051
|
let BracketedTitleFallback = _BracketedTitleFallback;
|
|
7052
|
+
const _WordNumeralPartAtTitlePosition = class _WordNumeralPartAtTitlePosition extends Rule {
|
|
7053
|
+
constructor() {
|
|
7054
|
+
super(...arguments);
|
|
7055
|
+
this.priority = 64;
|
|
7056
|
+
this.consequence = RemoveMatch;
|
|
7057
|
+
}
|
|
7058
|
+
when(matches, context) {
|
|
7059
|
+
if (isDisabled(context, "part")) return false;
|
|
7060
|
+
const toRemove = [];
|
|
7061
|
+
for (const part2 of matches.named("part") ?? []) {
|
|
7062
|
+
const target = part2.initiator ?? part2;
|
|
7063
|
+
if (/\d/.test(String(target.raw ?? ""))) continue;
|
|
7064
|
+
const filepart = matches.markers.atMatch(part2, (m) => m.name === "path", 0);
|
|
7065
|
+
if (!filepart) continue;
|
|
7066
|
+
const anchor = matches.range(
|
|
7067
|
+
part2.end,
|
|
7068
|
+
filepart.end,
|
|
7069
|
+
(m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
|
|
7070
|
+
0
|
|
7071
|
+
);
|
|
7072
|
+
if (!anchor) continue;
|
|
7073
|
+
toRemove.push(part2);
|
|
7074
|
+
for (const c of [...target.children ?? []]) if (!toRemove.includes(c)) toRemove.push(c);
|
|
7075
|
+
if (target !== part2 && !toRemove.includes(target)) toRemove.push(target);
|
|
7076
|
+
}
|
|
7077
|
+
return toRemove.length ? toRemove : false;
|
|
7078
|
+
}
|
|
7079
|
+
};
|
|
7080
|
+
_WordNumeralPartAtTitlePosition.priority = 64;
|
|
7081
|
+
let WordNumeralPartAtTitlePosition = _WordNumeralPartAtTitlePosition;
|
|
6983
7082
|
const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle extends Rule {
|
|
6984
7083
|
constructor() {
|
|
6985
7084
|
super(...arguments);
|
|
@@ -6989,18 +7088,22 @@ const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle ex
|
|
|
6989
7088
|
const inp = matches.inputString || "";
|
|
6990
7089
|
const out = [];
|
|
6991
7090
|
for (const filepart of matches.markers.named("path")) {
|
|
6992
|
-
|
|
7091
|
+
const lead = matches.range(filepart.start, filepart.end, (m) => !m.private && !!m.value, 0);
|
|
7092
|
+
if (!lead) continue;
|
|
6993
7093
|
const anchor = matches.range(
|
|
6994
|
-
|
|
7094
|
+
lead.end,
|
|
6995
7095
|
filepart.end,
|
|
6996
7096
|
(m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
|
|
6997
7097
|
0
|
|
6998
7098
|
);
|
|
6999
7099
|
if (!anchor) continue;
|
|
7000
|
-
const
|
|
7001
|
-
if (!
|
|
7002
|
-
|
|
7003
|
-
if ((
|
|
7100
|
+
const yearTitled = lead.name === "year" && ["season", "episode"].includes(anchor.name ?? "") && !anchor.tags?.includes("weak-episode") && !anchor.tags?.includes("weak-duplicate");
|
|
7101
|
+
if (!yearTitled && !["other", "country", "edition"].includes(lead.name ?? "")) continue;
|
|
7102
|
+
const titles = matches.range(filepart.start, filepart.end, (m) => m.name === "title") ?? [];
|
|
7103
|
+
if (titles.some((t) => t.start < anchor.end)) continue;
|
|
7104
|
+
if (titles.length && !yearTitled) continue;
|
|
7105
|
+
out.push(...titles);
|
|
7106
|
+
if (lead.name !== "year" && (lead.raw ?? "") === String(lead.value ?? "")) continue;
|
|
7004
7107
|
if (![...inp.slice(filepart.start, lead.start)].every((c) => seps.includes(c))) continue;
|
|
7005
7108
|
out.push(lead);
|
|
7006
7109
|
}
|
|
@@ -7127,7 +7230,7 @@ function title(config) {
|
|
|
7127
7230
|
const rebulk = new Rebulk({
|
|
7128
7231
|
disabled: (context) => isDisabled(context, "title")
|
|
7129
7232
|
});
|
|
7130
|
-
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
|
|
7233
|
+
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, WordNumeralPartAtTitlePosition, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
|
|
7131
7234
|
const expectedTitle = buildExpectedFunction("expected_title");
|
|
7132
7235
|
rebulk.functional(expectedTitle, {
|
|
7133
7236
|
name: "title",
|
|
@@ -11324,7 +11427,8 @@ const advanced_config = {
|
|
|
11324
11427
|
regex: [
|
|
11325
11428
|
"Dolby-Digital",
|
|
11326
11429
|
"DD",
|
|
11327
|
-
"AC-?3D?"
|
|
11430
|
+
"AC-?3D?",
|
|
11431
|
+
"DolbyD"
|
|
11328
11432
|
]
|
|
11329
11433
|
},
|
|
11330
11434
|
"Dolby Atmos": {
|