guessit-js 4.3.2 → 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 +47 -16
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +47 -16
- 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;
|
|
@@ -4919,12 +4933,15 @@ const _ValidateVideoCodec = class _ValidateVideoCodec extends Rule {
|
|
|
4919
4933
|
const ret = [];
|
|
4920
4934
|
const codecs = matches.named("video_codec");
|
|
4921
4935
|
const hasAny = (v) => Array.isArray(v) ? v.length > 0 : !!v;
|
|
4936
|
+
const inp = matches.inputString ?? "";
|
|
4922
4937
|
for (const codec of codecs) {
|
|
4923
|
-
|
|
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")))) {
|
|
4924
4941
|
ret.push(codec);
|
|
4925
4942
|
continue;
|
|
4926
4943
|
}
|
|
4927
|
-
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")))) {
|
|
4928
4945
|
ret.push(codec);
|
|
4929
4946
|
continue;
|
|
4930
4947
|
}
|
|
@@ -6429,7 +6446,20 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
|
|
|
6429
6446
|
console.log(` result: hole=[${trimmedHole.start},${trimmedHole.end}) length=${trimmedHole.length} value="${trimmedHole.value}"`);
|
|
6430
6447
|
}
|
|
6431
6448
|
if (trimmedHole.length > 0 && !this.shouldRemove(trimmedHole) && trimmedHole.value) {
|
|
6432
|
-
|
|
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
|
+
}
|
|
6433
6463
|
if (splitResult) {
|
|
6434
6464
|
splitResult.title.name = this.matchName;
|
|
6435
6465
|
toAppend.push(splitResult.title);
|
|
@@ -6942,17 +6972,18 @@ const _BracketedTitleFallback = class _BracketedTitleFallback extends Rule {
|
|
|
6942
6972
|
if (rg && g.start <= rg.start && g.end >= rg.end) continue;
|
|
6943
6973
|
const core = input.slice(g.start + 1, g.end - 1);
|
|
6944
6974
|
if (!/[a-zA-Z]{2,}/.test(core)) continue;
|
|
6945
|
-
const
|
|
6946
|
-
|
|
6947
|
-
|
|
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;
|
|
6948
6982
|
break;
|
|
6949
6983
|
}
|
|
6950
6984
|
if (candidate) {
|
|
6951
|
-
|
|
6952
|
-
|
|
6953
|
-
value: cleanup(input.slice(candidate.start + 1, candidate.end - 1)),
|
|
6954
|
-
inputString: input
|
|
6955
|
-
}));
|
|
6985
|
+
candidate.name = "title";
|
|
6986
|
+
toAppend.push(candidate);
|
|
6956
6987
|
continue;
|
|
6957
6988
|
}
|
|
6958
6989
|
if (rg && rg.tags?.includes("anime")) {
|