guessit-js 4.3.1 → 4.4.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 +97 -18
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +97 -18
- package/dist/guessit-js.js.map +1 -1
- package/package.json +1 -1
package/dist/guessit-js.js
CHANGED
|
@@ -3774,7 +3774,12 @@ const _AnimeTrailingEpisodeRule = class _AnimeTrailingEpisodeRule extends Rule {
|
|
|
3774
3774
|
(m2) => m2.name === "release_group" && m2.tags?.includes("anime"),
|
|
3775
3775
|
0
|
|
3776
3776
|
);
|
|
3777
|
-
|
|
3777
|
+
const groupCount = (matches.markers.range(
|
|
3778
|
+
filepart.start,
|
|
3779
|
+
filepart.end,
|
|
3780
|
+
(m2) => m2.name === "group"
|
|
3781
|
+
) ?? []).length;
|
|
3782
|
+
if (!crc2 && !animeRg && groupCount < 3) continue;
|
|
3778
3783
|
let done = false;
|
|
3779
3784
|
for (const group of matches.markers.range(filepart.start, filepart.end, (m2) => m2.name === "group") ?? []) {
|
|
3780
3785
|
const core = input.slice(group.start + 1, group.end - 1).trim();
|
|
@@ -3930,10 +3935,11 @@ const _RemoveNumfirstMarkerCollision = class _RemoveNumfirstMarkerCollision exte
|
|
|
3930
3935
|
constructor() {
|
|
3931
3936
|
super(...arguments);
|
|
3932
3937
|
this.priority = 70;
|
|
3933
|
-
this.consequence = RemoveMatch;
|
|
3938
|
+
this.consequence = [RemoveMatch, AppendMatch];
|
|
3934
3939
|
}
|
|
3935
3940
|
when(matches, _context) {
|
|
3936
3941
|
const toRemove = [];
|
|
3942
|
+
const toAppend = [];
|
|
3937
3943
|
const isWeak = (m) => !!(m.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(m.initiator?.name));
|
|
3938
3944
|
const removeWithParent = (m) => {
|
|
3939
3945
|
const init = m.initiator ?? m;
|
|
@@ -3956,10 +3962,18 @@ const _RemoveNumfirstMarkerCollision = class _RemoveNumfirstMarkerCollision exte
|
|
|
3956
3962
|
if (!wordFirst) continue;
|
|
3957
3963
|
const claimed = all.some((m) => !m.private && (m.name === "screen_size" || m.name === "year") && m.start < wordFirst.end && wordFirst.start < m.end);
|
|
3958
3964
|
const gluedOrdinal = /^(?:st|nd|rd|th|ª|º|°)/i.test(String(matches.inputString ?? "").slice(nf.end, nf.end + 2));
|
|
3959
|
-
if (claimed || gluedOrdinal)
|
|
3960
|
-
|
|
3965
|
+
if (claimed || gluedOrdinal) {
|
|
3966
|
+
removeWithParent(wordFirst);
|
|
3967
|
+
if (!claimed) {
|
|
3968
|
+
toAppend.push(new Match(wordFirst.start, wordFirst.end, {
|
|
3969
|
+
name: "episode",
|
|
3970
|
+
value: wordFirst.value,
|
|
3971
|
+
inputString: matches.inputString
|
|
3972
|
+
}));
|
|
3973
|
+
}
|
|
3974
|
+
} else removeWithParent(nf);
|
|
3961
3975
|
}
|
|
3962
|
-
return toRemove.length ? toRemove : false;
|
|
3976
|
+
return toRemove.length || toAppend.length ? [toRemove, toAppend] : false;
|
|
3963
3977
|
}
|
|
3964
3978
|
};
|
|
3965
3979
|
_RemoveNumfirstMarkerCollision.priority = 70;
|
|
@@ -4551,6 +4565,14 @@ function source(config) {
|
|
|
4551
4565
|
...buildSourcePattern(["HD-?CAM"], "", optional(ripSuffix)),
|
|
4552
4566
|
{ value: { source: "HD Camera", other: "Rip" } }
|
|
4553
4567
|
);
|
|
4568
|
+
rebulk.regex(
|
|
4569
|
+
...buildSourcePattern(["HQ-?CAM"], "", optional(ripSuffix)),
|
|
4570
|
+
{ value: { source: "Camera", other: "Rip" } }
|
|
4571
|
+
);
|
|
4572
|
+
rebulk.regex(
|
|
4573
|
+
...buildSourcePattern(["S-?Print"], "", optional(ripSuffix)),
|
|
4574
|
+
{ value: { source: "Camera" } }
|
|
4575
|
+
);
|
|
4554
4576
|
rebulk.regex(
|
|
4555
4577
|
...buildSourcePattern(["TELESYNC", "TS"], "", optional(ripSuffix)),
|
|
4556
4578
|
{ value: { source: "Telesync", other: "Rip" }, tags: ["video-codec-prefix"], overrides: ["tags"] }
|
|
@@ -4599,6 +4621,10 @@ function source(config) {
|
|
|
4599
4621
|
...buildSourcePattern(["DVD"], "", optional(ripSuffix)),
|
|
4600
4622
|
{ value: { source: "DVD", other: "Rip" } }
|
|
4601
4623
|
);
|
|
4624
|
+
rebulk.regex(
|
|
4625
|
+
...buildSourcePattern(["DVD-?R[59]"], "", ""),
|
|
4626
|
+
{ value: { source: "DVD" } }
|
|
4627
|
+
);
|
|
4602
4628
|
rebulk.regex(
|
|
4603
4629
|
...buildSourcePattern(["LD"], "", ripSuffix),
|
|
4604
4630
|
{ value: { source: "Laserdisc", other: "Rip" } }
|
|
@@ -4907,12 +4933,15 @@ const _ValidateVideoCodec = class _ValidateVideoCodec extends Rule {
|
|
|
4907
4933
|
const ret = [];
|
|
4908
4934
|
const codecs = matches.named("video_codec");
|
|
4909
4935
|
const hasAny = (v) => Array.isArray(v) ? v.length > 0 : !!v;
|
|
4936
|
+
const inp = matches.inputString ?? "";
|
|
4910
4937
|
for (const codec of codecs) {
|
|
4911
|
-
|
|
4938
|
+
const bracketBefore = inp[codec.start] === "[" || inp[codec.start - 1] === "[";
|
|
4939
|
+
const bracketAfter = inp[codec.end - 1] === "]" || inp[codec.end] === "]";
|
|
4940
|
+
if (!bracketBefore && !sepsBefore(codec) && !hasAny(matches.atIndex(codec.start - 1, (m) => m.tags?.includes("video-codec-prefix")))) {
|
|
4912
4941
|
ret.push(codec);
|
|
4913
4942
|
continue;
|
|
4914
4943
|
}
|
|
4915
|
-
if (!sepsAfter(codec) && !hasAny(matches.atIndex(codec.end + 1, (m) => m.tags?.includes("video-codec-suffix")))) {
|
|
4944
|
+
if (!bracketAfter && !sepsAfter(codec) && !hasAny(matches.atIndex(codec.end + 1, (m) => m.tags?.includes("video-codec-suffix")))) {
|
|
4916
4945
|
ret.push(codec);
|
|
4917
4946
|
continue;
|
|
4918
4947
|
}
|
|
@@ -6224,6 +6253,7 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
|
|
|
6224
6253
|
const lastSeg = createMatch(prevEnd, hole.end);
|
|
6225
6254
|
if (lastSeg) segments.push(lastSeg);
|
|
6226
6255
|
if (segments.length < 2) return null;
|
|
6256
|
+
if (/^\d+$/.test(String(segments[0].value ?? "").trim())) return null;
|
|
6227
6257
|
return { title: segments[0], alternatives: segments.slice(1) };
|
|
6228
6258
|
}
|
|
6229
6259
|
/**
|
|
@@ -6416,7 +6446,20 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
|
|
|
6416
6446
|
console.log(` result: hole=[${trimmedHole.start},${trimmedHole.end}) length=${trimmedHole.length} value="${trimmedHole.value}"`);
|
|
6417
6447
|
}
|
|
6418
6448
|
if (trimmedHole.length > 0 && !this.shouldRemove(trimmedHole) && trimmedHole.value) {
|
|
6419
|
-
|
|
6449
|
+
matches.inputString ?? "";
|
|
6450
|
+
const animeStyle = matches.markers.range(
|
|
6451
|
+
filepart.start,
|
|
6452
|
+
filepart.end,
|
|
6453
|
+
(m) => m.name === "group" && m.start === filepart.start,
|
|
6454
|
+
0
|
|
6455
|
+
) !== void 0 || matches.range(filepart.start, filepart.end, (m) => m.name === "crc32", 0) !== void 0;
|
|
6456
|
+
let splitResult = this.alternativePropertyName && !isDisabled(context, this.alternativePropertyName) ? this.splitTitleAlternative(trimmedHole, inp) : null;
|
|
6457
|
+
if (splitResult && animeStyle && splitResult.alternatives.every((a) => {
|
|
6458
|
+
const v = String(a.value ?? "").trim();
|
|
6459
|
+
return v.length >= 4 || /\s/.test(v);
|
|
6460
|
+
})) {
|
|
6461
|
+
splitResult = null;
|
|
6462
|
+
}
|
|
6420
6463
|
if (splitResult) {
|
|
6421
6464
|
splitResult.title.name = this.matchName;
|
|
6422
6465
|
toAppend.push(splitResult.title);
|
|
@@ -6842,6 +6885,38 @@ const _SplitOriginalScriptTitle = class _SplitOriginalScriptTitle extends Rule {
|
|
|
6842
6885
|
};
|
|
6843
6886
|
_SplitOriginalScriptTitle.priority = POST_PROCESS;
|
|
6844
6887
|
let SplitOriginalScriptTitle = _SplitOriginalScriptTitle;
|
|
6888
|
+
const _TrimSeasonWordFromTitle = class _TrimSeasonWordFromTitle extends Rule {
|
|
6889
|
+
constructor() {
|
|
6890
|
+
super(...arguments);
|
|
6891
|
+
this.priority = POST_PROCESS;
|
|
6892
|
+
this.consequence = [RemoveMatch, AppendMatch];
|
|
6893
|
+
}
|
|
6894
|
+
when(matches, context) {
|
|
6895
|
+
if (isDisabled(context, "title")) return false;
|
|
6896
|
+
const input = matches.inputString ?? "";
|
|
6897
|
+
const toRemove = [];
|
|
6898
|
+
const toAppend = [];
|
|
6899
|
+
for (const title2 of matches.named("title") ?? []) {
|
|
6900
|
+
const m = /^(.*\S)[\s._-]+(seasons?|saison)$/i.exec(String(title2.value ?? ""));
|
|
6901
|
+
if (!m) continue;
|
|
6902
|
+
const next = matches.range(title2.end, input.length, (mm) => !mm.private && !!mm.value, 0);
|
|
6903
|
+
if (!next || next.name !== "season") continue;
|
|
6904
|
+
toRemove.push(title2);
|
|
6905
|
+
input.slice(title2.start, title2.end).slice(0, m[1].length + (String(title2.value).length === title2.end - title2.start ? 0 : 0));
|
|
6906
|
+
let newEnd = title2.end;
|
|
6907
|
+
while (newEnd > title2.start && cleanup(input.slice(title2.start, newEnd)).toLowerCase() !== m[1].toLowerCase()) newEnd--;
|
|
6908
|
+
if (newEnd <= title2.start) continue;
|
|
6909
|
+
toAppend.push(new Match(title2.start, newEnd, {
|
|
6910
|
+
name: "title",
|
|
6911
|
+
value: cleanup(input.slice(title2.start, newEnd)),
|
|
6912
|
+
inputString: input
|
|
6913
|
+
}));
|
|
6914
|
+
}
|
|
6915
|
+
return toRemove.length || toAppend.length ? [toRemove, toAppend] : false;
|
|
6916
|
+
}
|
|
6917
|
+
};
|
|
6918
|
+
_TrimSeasonWordFromTitle.priority = POST_PROCESS;
|
|
6919
|
+
let TrimSeasonWordFromTitle = _TrimSeasonWordFromTitle;
|
|
6845
6920
|
const _PreBracketJunkTitle = class _PreBracketJunkTitle extends Rule {
|
|
6846
6921
|
constructor() {
|
|
6847
6922
|
super(...arguments);
|
|
@@ -6897,17 +6972,18 @@ const _BracketedTitleFallback = class _BracketedTitleFallback extends Rule {
|
|
|
6897
6972
|
if (rg && g.start <= rg.start && g.end >= rg.end) continue;
|
|
6898
6973
|
const core = input.slice(g.start + 1, g.end - 1);
|
|
6899
6974
|
if (!/[a-zA-Z]{2,}/.test(core)) continue;
|
|
6900
|
-
const
|
|
6901
|
-
|
|
6902
|
-
|
|
6975
|
+
const hole = matches.holes(g.start + 1, g.end - 1, {
|
|
6976
|
+
formatter: cleanup,
|
|
6977
|
+
predicate: (h) => !!h.value,
|
|
6978
|
+
index: 0
|
|
6979
|
+
});
|
|
6980
|
+
if (!hole || !/[a-zA-Z]{3,}/.test(String(hole.value ?? ""))) continue;
|
|
6981
|
+
candidate = hole;
|
|
6903
6982
|
break;
|
|
6904
6983
|
}
|
|
6905
6984
|
if (candidate) {
|
|
6906
|
-
|
|
6907
|
-
|
|
6908
|
-
value: cleanup(input.slice(candidate.start + 1, candidate.end - 1)),
|
|
6909
|
-
inputString: input
|
|
6910
|
-
}));
|
|
6985
|
+
candidate.name = "title";
|
|
6986
|
+
toAppend.push(candidate);
|
|
6911
6987
|
continue;
|
|
6912
6988
|
}
|
|
6913
6989
|
if (rg && rg.tags?.includes("anime")) {
|
|
@@ -7080,7 +7156,7 @@ function title(config) {
|
|
|
7080
7156
|
const rebulk = new Rebulk({
|
|
7081
7157
|
disabled: (context) => isDisabled(context, "title")
|
|
7082
7158
|
});
|
|
7083
|
-
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle);
|
|
7159
|
+
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
|
|
7084
7160
|
const expectedTitle = buildExpectedFunction("expected_title");
|
|
7085
7161
|
rebulk.functional(expectedTitle, {
|
|
7086
7162
|
name: "title",
|
|
@@ -12248,7 +12324,10 @@ const advanced_config = {
|
|
|
12248
12324
|
},
|
|
12249
12325
|
"High Resolution": "HR",
|
|
12250
12326
|
"Line Dubbed": "LD",
|
|
12251
|
-
"Mic Dubbed":
|
|
12327
|
+
"Mic Dubbed": {
|
|
12328
|
+
string: "MD",
|
|
12329
|
+
tags: "title-word"
|
|
12330
|
+
},
|
|
12252
12331
|
"Micro HD": {
|
|
12253
12332
|
string: [
|
|
12254
12333
|
"mHD",
|