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.cjs
CHANGED
|
@@ -3776,7 +3776,12 @@ const _AnimeTrailingEpisodeRule = class _AnimeTrailingEpisodeRule extends Rule {
|
|
|
3776
3776
|
(m2) => m2.name === "release_group" && m2.tags?.includes("anime"),
|
|
3777
3777
|
0
|
|
3778
3778
|
);
|
|
3779
|
-
|
|
3779
|
+
const groupCount = (matches.markers.range(
|
|
3780
|
+
filepart.start,
|
|
3781
|
+
filepart.end,
|
|
3782
|
+
(m2) => m2.name === "group"
|
|
3783
|
+
) ?? []).length;
|
|
3784
|
+
if (!crc2 && !animeRg && groupCount < 3) continue;
|
|
3780
3785
|
let done = false;
|
|
3781
3786
|
for (const group of matches.markers.range(filepart.start, filepart.end, (m2) => m2.name === "group") ?? []) {
|
|
3782
3787
|
const core = input.slice(group.start + 1, group.end - 1).trim();
|
|
@@ -3932,10 +3937,11 @@ const _RemoveNumfirstMarkerCollision = class _RemoveNumfirstMarkerCollision exte
|
|
|
3932
3937
|
constructor() {
|
|
3933
3938
|
super(...arguments);
|
|
3934
3939
|
this.priority = 70;
|
|
3935
|
-
this.consequence = RemoveMatch;
|
|
3940
|
+
this.consequence = [RemoveMatch, AppendMatch];
|
|
3936
3941
|
}
|
|
3937
3942
|
when(matches, _context) {
|
|
3938
3943
|
const toRemove = [];
|
|
3944
|
+
const toAppend = [];
|
|
3939
3945
|
const isWeak = (m) => !!(m.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(m.initiator?.name));
|
|
3940
3946
|
const removeWithParent = (m) => {
|
|
3941
3947
|
const init = m.initiator ?? m;
|
|
@@ -3958,10 +3964,18 @@ const _RemoveNumfirstMarkerCollision = class _RemoveNumfirstMarkerCollision exte
|
|
|
3958
3964
|
if (!wordFirst) continue;
|
|
3959
3965
|
const claimed = all.some((m) => !m.private && (m.name === "screen_size" || m.name === "year") && m.start < wordFirst.end && wordFirst.start < m.end);
|
|
3960
3966
|
const gluedOrdinal = /^(?:st|nd|rd|th|ª|º|°)/i.test(String(matches.inputString ?? "").slice(nf.end, nf.end + 2));
|
|
3961
|
-
if (claimed || gluedOrdinal)
|
|
3962
|
-
|
|
3967
|
+
if (claimed || gluedOrdinal) {
|
|
3968
|
+
removeWithParent(wordFirst);
|
|
3969
|
+
if (!claimed) {
|
|
3970
|
+
toAppend.push(new Match(wordFirst.start, wordFirst.end, {
|
|
3971
|
+
name: "episode",
|
|
3972
|
+
value: wordFirst.value,
|
|
3973
|
+
inputString: matches.inputString
|
|
3974
|
+
}));
|
|
3975
|
+
}
|
|
3976
|
+
} else removeWithParent(nf);
|
|
3963
3977
|
}
|
|
3964
|
-
return toRemove.length ? toRemove : false;
|
|
3978
|
+
return toRemove.length || toAppend.length ? [toRemove, toAppend] : false;
|
|
3965
3979
|
}
|
|
3966
3980
|
};
|
|
3967
3981
|
_RemoveNumfirstMarkerCollision.priority = 70;
|
|
@@ -4921,12 +4935,15 @@ const _ValidateVideoCodec = class _ValidateVideoCodec extends Rule {
|
|
|
4921
4935
|
const ret = [];
|
|
4922
4936
|
const codecs = matches.named("video_codec");
|
|
4923
4937
|
const hasAny = (v) => Array.isArray(v) ? v.length > 0 : !!v;
|
|
4938
|
+
const inp = matches.inputString ?? "";
|
|
4924
4939
|
for (const codec of codecs) {
|
|
4925
|
-
|
|
4940
|
+
const bracketBefore = inp[codec.start] === "[" || inp[codec.start - 1] === "[";
|
|
4941
|
+
const bracketAfter = inp[codec.end - 1] === "]" || inp[codec.end] === "]";
|
|
4942
|
+
if (!bracketBefore && !sepsBefore(codec) && !hasAny(matches.atIndex(codec.start - 1, (m) => m.tags?.includes("video-codec-prefix")))) {
|
|
4926
4943
|
ret.push(codec);
|
|
4927
4944
|
continue;
|
|
4928
4945
|
}
|
|
4929
|
-
if (!sepsAfter(codec) && !hasAny(matches.atIndex(codec.end + 1, (m) => m.tags?.includes("video-codec-suffix")))) {
|
|
4946
|
+
if (!bracketAfter && !sepsAfter(codec) && !hasAny(matches.atIndex(codec.end + 1, (m) => m.tags?.includes("video-codec-suffix")))) {
|
|
4930
4947
|
ret.push(codec);
|
|
4931
4948
|
continue;
|
|
4932
4949
|
}
|
|
@@ -6431,7 +6448,20 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
|
|
|
6431
6448
|
console.log(` result: hole=[${trimmedHole.start},${trimmedHole.end}) length=${trimmedHole.length} value="${trimmedHole.value}"`);
|
|
6432
6449
|
}
|
|
6433
6450
|
if (trimmedHole.length > 0 && !this.shouldRemove(trimmedHole) && trimmedHole.value) {
|
|
6434
|
-
|
|
6451
|
+
matches.inputString ?? "";
|
|
6452
|
+
const animeStyle = matches.markers.range(
|
|
6453
|
+
filepart.start,
|
|
6454
|
+
filepart.end,
|
|
6455
|
+
(m) => m.name === "group" && m.start === filepart.start,
|
|
6456
|
+
0
|
|
6457
|
+
) !== void 0 || matches.range(filepart.start, filepart.end, (m) => m.name === "crc32", 0) !== void 0;
|
|
6458
|
+
let splitResult = this.alternativePropertyName && !isDisabled(context, this.alternativePropertyName) ? this.splitTitleAlternative(trimmedHole, inp) : null;
|
|
6459
|
+
if (splitResult && animeStyle && splitResult.alternatives.every((a) => {
|
|
6460
|
+
const v = String(a.value ?? "").trim();
|
|
6461
|
+
return v.length >= 4 || /\s/.test(v);
|
|
6462
|
+
})) {
|
|
6463
|
+
splitResult = null;
|
|
6464
|
+
}
|
|
6435
6465
|
if (splitResult) {
|
|
6436
6466
|
splitResult.title.name = this.matchName;
|
|
6437
6467
|
toAppend.push(splitResult.title);
|
|
@@ -6944,17 +6974,18 @@ const _BracketedTitleFallback = class _BracketedTitleFallback extends Rule {
|
|
|
6944
6974
|
if (rg && g.start <= rg.start && g.end >= rg.end) continue;
|
|
6945
6975
|
const core = input.slice(g.start + 1, g.end - 1);
|
|
6946
6976
|
if (!/[a-zA-Z]{2,}/.test(core)) continue;
|
|
6947
|
-
const
|
|
6948
|
-
|
|
6949
|
-
|
|
6977
|
+
const hole = matches.holes(g.start + 1, g.end - 1, {
|
|
6978
|
+
formatter: cleanup,
|
|
6979
|
+
predicate: (h) => !!h.value,
|
|
6980
|
+
index: 0
|
|
6981
|
+
});
|
|
6982
|
+
if (!hole || !/[a-zA-Z]{3,}/.test(String(hole.value ?? ""))) continue;
|
|
6983
|
+
candidate = hole;
|
|
6950
6984
|
break;
|
|
6951
6985
|
}
|
|
6952
6986
|
if (candidate) {
|
|
6953
|
-
|
|
6954
|
-
|
|
6955
|
-
value: cleanup(input.slice(candidate.start + 1, candidate.end - 1)),
|
|
6956
|
-
inputString: input
|
|
6957
|
-
}));
|
|
6987
|
+
candidate.name = "title";
|
|
6988
|
+
toAppend.push(candidate);
|
|
6958
6989
|
continue;
|
|
6959
6990
|
}
|
|
6960
6991
|
if (rg && rg.tags?.includes("anime")) {
|