guessit-js 4.4.2 → 4.5.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/README.md +3 -3
- package/dist/guessit-js.cjs +226 -15
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +226 -15
- package/dist/guessit-js.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,13 +5,13 @@ Extract metadata (title, year, season, episode, codec, language, etc.) from medi
|
|
|
5
5
|
[](https://www.npmjs.com/package/guessit-js)
|
|
6
6
|
[](https://github.com/opensubtitles/guessit-js/actions/workflows/ci.yml)
|
|
7
7
|
[](https://www.gnu.org/licenses/lgpl-3.0)
|
|
8
|
-
[-brightgreen)](https://github.com/guessit-io/guessit)
|
|
9
9
|
|
|
10
10
|
**[Live Demo](https://opensubtitles.github.io/guessit-js)** · **[API Docs](https://opensubtitles.github.io/guessit-js/docs)** · **[npm](https://www.npmjs.com/package/guessit-js)**
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
14
|
-
- **100% compatibility** with Python guessit 4.4.0 (
|
|
14
|
+
- **100% compatibility** with Python guessit 4.4.0 (1333/1333 fixtures passing, including Python's own grown 4.x corpus) — and **more correct**: ships fixes for 32 historical upstream bugs, Python's still-open #875 and #877, and 104 of the 276 cross-parser cases Python admits failing (see [Differences from Python](#differences-from-python-guessit))
|
|
15
15
|
- **3.5x faster** than Python (6.87ms vs 23.86ms per parse)
|
|
16
16
|
- **50 properties** detected: title, year, season, episode, resolution, codec, language, and more — with a [machine-readable schema](#output-schema)
|
|
17
17
|
- **Single dependency** ([rebulk-js](https://www.npmjs.com/package/rebulk-js))
|
|
@@ -122,7 +122,7 @@ The WASM build is **bit-identical to the JS build** across the entire test corpu
|
|
|
122
122
|
|
|
123
123
|
## Differences from Python guessit
|
|
124
124
|
|
|
125
|
-
guessit-js is a faithful port (
|
|
125
|
+
guessit-js is a faithful port (1333/1333 fixtures, tracking Python 4.4.0), but it is
|
|
126
126
|
**not bug-for-bug identical** — where Python has a genuine parsing bug, guessit-js
|
|
127
127
|
is corrected. Highlights:
|
|
128
128
|
|
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+)(?:[a-d](?![a-z0-9]))?`
|
|
3524
|
+
seasonMarkerPattern + `(?<season>\\d+)@?` + episodeMarkerPattern + `@?(?<episode>\\d+)(?:[a-d](?![a-z0-9]))?(?:v(?<version>\\d+))?`
|
|
3525
3525
|
).repeater("+").regex(
|
|
3526
3526
|
allSeparatorsPattern + `@?(?<episode>\\d+)`
|
|
3527
3527
|
).repeater("*");
|
|
@@ -3681,13 +3681,13 @@ function episodes(config) {
|
|
|
3681
3681
|
rebulk.chain({
|
|
3682
3682
|
tags: ["weak-episode"],
|
|
3683
3683
|
disabled: (context) => context?.type === "movie" || isDisabled(context, "episode")
|
|
3684
|
-
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])(?<episode>\\d{2})(?!(?:st|nd|rd|th)\\b)(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{2})`, {
|
|
3684
|
+
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])(?<episode>\\d{2})(?!(?:st|nd|rd|th)\\b)(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{2})`, {
|
|
3685
3685
|
abbreviations: null
|
|
3686
3686
|
}).repeater("*");
|
|
3687
3687
|
rebulk.chain({
|
|
3688
3688
|
tags: ["weak-episode"],
|
|
3689
3689
|
disabled: (context) => context?.type === "movie" || isDisabled(context, "episode")
|
|
3690
|
-
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])0(?<episode>\\d{1,2})(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])0(?<episode>\\d{1,2})`, {
|
|
3690
|
+
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])0(?<episode>\\d{1,2})(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])0(?<episode>\\d{1,2})`, {
|
|
3691
3691
|
abbreviations: null
|
|
3692
3692
|
}).repeater("*");
|
|
3693
3693
|
rebulk.chain({
|
|
@@ -3698,13 +3698,13 @@ function episodes(config) {
|
|
|
3698
3698
|
validator: null,
|
|
3699
3699
|
tags: ["weak-episode"],
|
|
3700
3700
|
name: "weak_episode"
|
|
3701
|
-
}).regex(`(?<![^\\W_])(?<episode>\\d{3,4})(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{3,4})`, {
|
|
3701
|
+
}).regex(`(?<![^\\W_])(?<episode>\\d{3,4})(?!%)(?:[a-d](?![a-z0-9]))?(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{3,4})`, {
|
|
3702
3702
|
abbreviations: null
|
|
3703
3703
|
}).repeater("*");
|
|
3704
3704
|
rebulk.chain({
|
|
3705
3705
|
tags: ["weak-episode"],
|
|
3706
3706
|
disabled: (context) => context?.type !== "episode" || isDisabled(context, "episode")
|
|
3707
|
-
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])(?<episode>\\d)(?!-[a-z])(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{1,2})`, {
|
|
3707
|
+
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<![^\\W_])(?<episode>\\d)(?!-[a-z])(?!%)(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{1,2})`, {
|
|
3708
3708
|
abbreviations: null
|
|
3709
3709
|
}).repeater("*");
|
|
3710
3710
|
rebulk.chain({
|
|
@@ -3733,7 +3733,7 @@ function episodes(config) {
|
|
|
3733
3733
|
name: "weak_duplicate",
|
|
3734
3734
|
validator: null,
|
|
3735
3735
|
conflictSolver: seasonEpisodeConflictSolver
|
|
3736
|
-
}).regex(`(?<![^\\W_])(?<season>\\d{1,2})(?<episode>\\d{2})(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>x|-)(?<episode>\\d{2})`, {
|
|
3736
|
+
}).regex(`(?<![^\\W_])(?<season>\\d{1,2})(?<episode>\\d{2})(?!%)(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>x|-)(?<episode>\\d{2})`, {
|
|
3737
3737
|
abbreviations: null
|
|
3738
3738
|
}).repeater("*");
|
|
3739
3739
|
rebulk.regex(`v(?<version>\\d+)`, {
|
|
@@ -3761,6 +3761,8 @@ function episodes(config) {
|
|
|
3761
3761
|
disabled: (context) => isDisabled(context, "episode_format")
|
|
3762
3762
|
});
|
|
3763
3763
|
rebulk.rules(
|
|
3764
|
+
EventNumberAsTitleRule,
|
|
3765
|
+
EpisodeWordBeforeYearAsTitle,
|
|
3764
3766
|
RemoveGroupSuffixSeason,
|
|
3765
3767
|
AnimeTrailingEpisodeRule,
|
|
3766
3768
|
PreferAnchoredWeakEpisodeRule,
|
|
@@ -3817,6 +3819,79 @@ const _RemoveGroupSuffixSeason = class _RemoveGroupSuffixSeason extends Rule {
|
|
|
3817
3819
|
};
|
|
3818
3820
|
_RemoveGroupSuffixSeason.priority = 72;
|
|
3819
3821
|
let RemoveGroupSuffixSeason = _RemoveGroupSuffixSeason;
|
|
3822
|
+
const _EventNumberAsTitleRule = class _EventNumberAsTitleRule extends Rule {
|
|
3823
|
+
constructor() {
|
|
3824
|
+
super(...arguments);
|
|
3825
|
+
this.priority = 60;
|
|
3826
|
+
this.consequence = RemoveMatch;
|
|
3827
|
+
}
|
|
3828
|
+
when(matches, _context) {
|
|
3829
|
+
const input = matches.inputString ?? "";
|
|
3830
|
+
const toRemove = [];
|
|
3831
|
+
const isWeak = (m) => !!(m.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(m.initiator?.name));
|
|
3832
|
+
for (const filepart of matches.markers.named("path") ?? []) {
|
|
3833
|
+
const weaks = matches.range(
|
|
3834
|
+
filepart.start,
|
|
3835
|
+
filepart.end,
|
|
3836
|
+
(m) => m.name === "episode" && !m.private && isWeak(m)
|
|
3837
|
+
) ?? [];
|
|
3838
|
+
if (!weaks.length) continue;
|
|
3839
|
+
const strong = matches.range(filepart.start, filepart.end, (m) => !m.private && (m.name === "season" || m.name === "year" || m.name === "date" || m.name === "episode" && m.tags?.includes("SxxExx")), 0);
|
|
3840
|
+
for (const w of weaks) {
|
|
3841
|
+
const init = w.initiator ?? w;
|
|
3842
|
+
const after = input.slice(init.end, init.end + 5);
|
|
3843
|
+
if (/^[\s._-]?PPV/i.test(after)) {
|
|
3844
|
+
for (const c of [init, ...init.children ?? []]) if (!toRemove.includes(c)) toRemove.push(c);
|
|
3845
|
+
continue;
|
|
3846
|
+
}
|
|
3847
|
+
if (!strong && init.start === filepart.start && /^[1-9]\d$/.test(String(init.raw ?? ""))) {
|
|
3848
|
+
const rest = input.slice(init.end, filepart.end);
|
|
3849
|
+
const words = rest.match(/[A-Za-z][a-z]+/g) ?? [];
|
|
3850
|
+
if (words.length >= 2) {
|
|
3851
|
+
for (const c of [init, ...init.children ?? []]) if (!toRemove.includes(c)) toRemove.push(c);
|
|
3852
|
+
}
|
|
3853
|
+
}
|
|
3854
|
+
}
|
|
3855
|
+
}
|
|
3856
|
+
return toRemove.length ? toRemove : false;
|
|
3857
|
+
}
|
|
3858
|
+
};
|
|
3859
|
+
_EventNumberAsTitleRule.priority = 60;
|
|
3860
|
+
let EventNumberAsTitleRule = _EventNumberAsTitleRule;
|
|
3861
|
+
const _EpisodeWordBeforeYearAsTitle = class _EpisodeWordBeforeYearAsTitle extends Rule {
|
|
3862
|
+
constructor() {
|
|
3863
|
+
super(...arguments);
|
|
3864
|
+
this.priority = 60;
|
|
3865
|
+
this.consequence = RemoveMatch;
|
|
3866
|
+
}
|
|
3867
|
+
when(matches, _context) {
|
|
3868
|
+
const toRemove = [];
|
|
3869
|
+
for (const episode of matches.named("episode") ?? []) {
|
|
3870
|
+
const init = episode.initiator ?? episode;
|
|
3871
|
+
const marker = [...init.children ?? []].find((c) => c.name === "episodeMarker");
|
|
3872
|
+
if (!marker || String(marker.raw ?? "").length < 3) continue;
|
|
3873
|
+
const filepart = matches.markers.atMatch(episode, (m) => m.name === "path", 0);
|
|
3874
|
+
if (!filepart) continue;
|
|
3875
|
+
const year = matches.range(episode.end, filepart.end, (m) => !m.private && m.name === "year", 0);
|
|
3876
|
+
if (!year) continue;
|
|
3877
|
+
const seasonish = matches.range(
|
|
3878
|
+
filepart.start,
|
|
3879
|
+
filepart.end,
|
|
3880
|
+
(m) => !m.private && (m.name === "season" || m.name === "episode" && m.tags?.includes("SxxExx")),
|
|
3881
|
+
0
|
|
3882
|
+
);
|
|
3883
|
+
if (seasonish) continue;
|
|
3884
|
+
const between = String(matches.inputString ?? "").slice(episode.end, year.start);
|
|
3885
|
+
if (!/[a-zA-Z]{2,}/.test(between)) continue;
|
|
3886
|
+
toRemove.push(episode);
|
|
3887
|
+
if (!toRemove.includes(init)) toRemove.push(init);
|
|
3888
|
+
for (const c of init.children ?? []) if (!toRemove.includes(c)) toRemove.push(c);
|
|
3889
|
+
}
|
|
3890
|
+
return toRemove.length ? toRemove : false;
|
|
3891
|
+
}
|
|
3892
|
+
};
|
|
3893
|
+
_EpisodeWordBeforeYearAsTitle.priority = 60;
|
|
3894
|
+
let EpisodeWordBeforeYearAsTitle = _EpisodeWordBeforeYearAsTitle;
|
|
3820
3895
|
const _AnimeTrailingEpisodeRule = class _AnimeTrailingEpisodeRule extends Rule {
|
|
3821
3896
|
constructor() {
|
|
3822
3897
|
super(...arguments);
|
|
@@ -7026,8 +7101,10 @@ const _BracketedTitleFallback = class _BracketedTitleFallback extends Rule {
|
|
|
7026
7101
|
const toRemove = [];
|
|
7027
7102
|
const toAppend = [];
|
|
7028
7103
|
for (const filepart of matches.markers.named("path")) {
|
|
7029
|
-
const
|
|
7030
|
-
|
|
7104
|
+
const titlesHere = matches.range(filepart.start, filepart.end, (m) => m.name === "title") ?? [];
|
|
7105
|
+
const realTitle = titlesHere.find((t) => /[\p{L}\p{N}]/u.test(String(t.value ?? "")));
|
|
7106
|
+
if (realTitle) continue;
|
|
7107
|
+
toRemove.push(...titlesHere);
|
|
7031
7108
|
const groups2 = matches.markers.range(filepart.start, filepart.end, (m) => m.name === "group") ?? [];
|
|
7032
7109
|
if (!groups2.length) continue;
|
|
7033
7110
|
const rg = matches.range(filepart.start, filepart.end, (m) => m.name === "release_group", 0);
|
|
@@ -7036,6 +7113,25 @@ const _BracketedTitleFallback = class _BracketedTitleFallback extends Rule {
|
|
|
7036
7113
|
if (rg && g.start <= rg.start && g.end >= rg.end) continue;
|
|
7037
7114
|
const core = input.slice(g.start + 1, g.end - 1);
|
|
7038
7115
|
if (!/[a-zA-Z]{2,}/.test(core)) continue;
|
|
7116
|
+
const softInner = matches.range(
|
|
7117
|
+
g.start,
|
|
7118
|
+
g.end,
|
|
7119
|
+
(m) => !m.private && ["episode_title", "alternative_title"].includes(m.name ?? "")
|
|
7120
|
+
) ?? [];
|
|
7121
|
+
const hardInner = matches.range(
|
|
7122
|
+
g.start,
|
|
7123
|
+
g.end,
|
|
7124
|
+
(m) => !m.private && !["episode_title", "alternative_title"].includes(m.name ?? "")
|
|
7125
|
+
) ?? [];
|
|
7126
|
+
if (softInner.length && !hardInner.length) {
|
|
7127
|
+
toRemove.push(...softInner);
|
|
7128
|
+
candidate = new Match(g.start + 1, g.end - 1, {
|
|
7129
|
+
name: "title",
|
|
7130
|
+
value: cleanup(input.slice(g.start + 1, g.end - 1)),
|
|
7131
|
+
inputString: input
|
|
7132
|
+
});
|
|
7133
|
+
break;
|
|
7134
|
+
}
|
|
7039
7135
|
const hole = matches.holes(g.start + 1, g.end - 1, {
|
|
7040
7136
|
formatter: cleanup,
|
|
7041
7137
|
predicate: (h) => !!h.value,
|
|
@@ -7103,6 +7199,76 @@ const _WordNumeralPartAtTitlePosition = class _WordNumeralPartAtTitlePosition ex
|
|
|
7103
7199
|
};
|
|
7104
7200
|
_WordNumeralPartAtTitlePosition.priority = 64;
|
|
7105
7201
|
let WordNumeralPartAtTitlePosition = _WordNumeralPartAtTitlePosition;
|
|
7202
|
+
const _BonusAtTitlePositionRule = class _BonusAtTitlePositionRule extends Rule {
|
|
7203
|
+
constructor() {
|
|
7204
|
+
super(...arguments);
|
|
7205
|
+
this.priority = 64;
|
|
7206
|
+
this.consequence = RemoveMatch;
|
|
7207
|
+
}
|
|
7208
|
+
when(matches, context) {
|
|
7209
|
+
if (isDisabled(context, "bonus")) return false;
|
|
7210
|
+
const toRemove = [];
|
|
7211
|
+
for (const bonus2 of matches.named("bonus") ?? []) {
|
|
7212
|
+
const filepart = matches.markers.atMatch(bonus2, (m) => m.name === "path", 0);
|
|
7213
|
+
if (!filepart) continue;
|
|
7214
|
+
const anime = matches.range(filepart.start, filepart.end, (m) => m.name === "crc32", 0) || matches.markers.range(
|
|
7215
|
+
filepart.start,
|
|
7216
|
+
filepart.end,
|
|
7217
|
+
(m) => m.name === "group" && m.start === filepart.start,
|
|
7218
|
+
0
|
|
7219
|
+
);
|
|
7220
|
+
if (!anime) continue;
|
|
7221
|
+
const anchor = matches.range(
|
|
7222
|
+
bonus2.end,
|
|
7223
|
+
filepart.end,
|
|
7224
|
+
(m) => !m.private && ["episode", "season", "year", "date"].includes(m.name ?? ""),
|
|
7225
|
+
0
|
|
7226
|
+
);
|
|
7227
|
+
const bonusTitles = matches.named("bonus_title") ?? [];
|
|
7228
|
+
if (!anchor && !bonusTitles.length) continue;
|
|
7229
|
+
toRemove.push(bonus2);
|
|
7230
|
+
toRemove.push(...bonusTitles.filter((bt) => bt.start >= filepart.start && bt.end <= filepart.end));
|
|
7231
|
+
}
|
|
7232
|
+
return toRemove.length ? toRemove : false;
|
|
7233
|
+
}
|
|
7234
|
+
};
|
|
7235
|
+
_BonusAtTitlePositionRule.priority = 64;
|
|
7236
|
+
let BonusAtTitlePositionRule = _BonusAtTitlePositionRule;
|
|
7237
|
+
const _LanguageWordInAnimeTitle = class _LanguageWordInAnimeTitle extends Rule {
|
|
7238
|
+
constructor() {
|
|
7239
|
+
super(...arguments);
|
|
7240
|
+
this.priority = 64;
|
|
7241
|
+
this.consequence = RemoveMatch;
|
|
7242
|
+
}
|
|
7243
|
+
when(matches, context) {
|
|
7244
|
+
if (isDisabled(context, "language")) return false;
|
|
7245
|
+
const toRemove = [];
|
|
7246
|
+
for (const lang of matches.named("language") ?? []) {
|
|
7247
|
+
const raw = String(lang.raw ?? "");
|
|
7248
|
+
if (raw.length > 3 || !/^[A-Z][a-z]{0,2}$/.test(raw)) continue;
|
|
7249
|
+
const filepart = matches.markers.atMatch(lang, (m) => m.name === "path", 0);
|
|
7250
|
+
if (!filepart) continue;
|
|
7251
|
+
const leadingBracket = matches.markers.range(
|
|
7252
|
+
filepart.start,
|
|
7253
|
+
filepart.end,
|
|
7254
|
+
(m) => m.name === "group" && m.start === filepart.start,
|
|
7255
|
+
0
|
|
7256
|
+
);
|
|
7257
|
+
if (!leadingBracket) continue;
|
|
7258
|
+
const anchor = matches.range(
|
|
7259
|
+
lang.end,
|
|
7260
|
+
filepart.end,
|
|
7261
|
+
(m) => !m.private && ["episode", "season", "year", "date"].includes(m.name ?? ""),
|
|
7262
|
+
0
|
|
7263
|
+
);
|
|
7264
|
+
if (!anchor) continue;
|
|
7265
|
+
toRemove.push(lang);
|
|
7266
|
+
}
|
|
7267
|
+
return toRemove.length ? toRemove : false;
|
|
7268
|
+
}
|
|
7269
|
+
};
|
|
7270
|
+
_LanguageWordInAnimeTitle.priority = 64;
|
|
7271
|
+
let LanguageWordInAnimeTitle = _LanguageWordInAnimeTitle;
|
|
7106
7272
|
const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle extends Rule {
|
|
7107
7273
|
constructor() {
|
|
7108
7274
|
super(...arguments);
|
|
@@ -7120,7 +7286,16 @@ const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle ex
|
|
|
7120
7286
|
(m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
|
|
7121
7287
|
0
|
|
7122
7288
|
);
|
|
7123
|
-
if (!anchor)
|
|
7289
|
+
if (!anchor) {
|
|
7290
|
+
const anyTitle = matches.range(filepart.start, filepart.end, (m) => m.name === "title", 0);
|
|
7291
|
+
if (lead.name === "year" && lead.start === filepart.start && !anyTitle) {
|
|
7292
|
+
lead.name = "title";
|
|
7293
|
+
lead.value = String(matches.inputString ?? "").slice(lead.start, lead.end);
|
|
7294
|
+
out.push(lead);
|
|
7295
|
+
continue;
|
|
7296
|
+
}
|
|
7297
|
+
continue;
|
|
7298
|
+
}
|
|
7124
7299
|
const yearTitled = lead.name === "year" && ["season", "episode"].includes(anchor.name ?? "") && !anchor.tags?.includes("weak-episode") && !anchor.tags?.includes("weak-duplicate");
|
|
7125
7300
|
if (!yearTitled && !["other", "country", "edition"].includes(lead.name ?? "")) continue;
|
|
7126
7301
|
const titles = matches.range(filepart.start, filepart.end, (m) => m.name === "title") ?? [];
|
|
@@ -7254,7 +7429,7 @@ function title(config) {
|
|
|
7254
7429
|
const rebulk = new Rebulk({
|
|
7255
7430
|
disabled: (context) => isDisabled(context, "title")
|
|
7256
7431
|
});
|
|
7257
|
-
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, WordNumeralPartAtTitlePosition, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
|
|
7432
|
+
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, WordNumeralPartAtTitlePosition, BonusAtTitlePositionRule, LanguageWordInAnimeTitle, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
|
|
7258
7433
|
const expectedTitle = buildExpectedFunction("expected_title");
|
|
7259
7434
|
rebulk.functional(expectedTitle, {
|
|
7260
7435
|
name: "title",
|
|
@@ -9246,6 +9421,7 @@ function releaseGroup(config) {
|
|
|
9246
9421
|
new SceneReleaseGroup(cleanGroupname),
|
|
9247
9422
|
AnimeReleaseGroup,
|
|
9248
9423
|
new TrailingTokenAfterEpisodeAsReleaseGroup(cleanGroupname),
|
|
9424
|
+
NumericPrefixedGroupRule,
|
|
9249
9425
|
RemoveSeasonPackReleaseGroup
|
|
9250
9426
|
);
|
|
9251
9427
|
}
|
|
@@ -9591,6 +9767,39 @@ _AnimeReleaseGroup.dependency = ["SceneReleaseGroup", "TitleFromPosition"];
|
|
|
9591
9767
|
_AnimeReleaseGroup.consequence = [RemoveMatch, AppendMatch];
|
|
9592
9768
|
_AnimeReleaseGroup.properties = { release_group: [null] };
|
|
9593
9769
|
let AnimeReleaseGroup = _AnimeReleaseGroup;
|
|
9770
|
+
const _NumericPrefixedGroupRule = class _NumericPrefixedGroupRule extends Rule {
|
|
9771
|
+
constructor() {
|
|
9772
|
+
super(...arguments);
|
|
9773
|
+
this.priority = -32;
|
|
9774
|
+
this.consequence = [RemoveMatch, AppendMatch];
|
|
9775
|
+
}
|
|
9776
|
+
when(matches, _context) {
|
|
9777
|
+
const input = matches.inputString ?? "";
|
|
9778
|
+
const toRemove = [];
|
|
9779
|
+
const toAppend = [];
|
|
9780
|
+
for (const rg of matches.named("release_group") ?? []) {
|
|
9781
|
+
const m = /^(\d{1,3})\s*\[([^\]]+)\]$/.exec(String(rg.value ?? ""));
|
|
9782
|
+
if (!m) continue;
|
|
9783
|
+
const raw = input.slice(rg.start, rg.end);
|
|
9784
|
+
const numLen = m[1].length;
|
|
9785
|
+
toRemove.push(rg);
|
|
9786
|
+
toAppend.push(new Match(rg.start, rg.start + numLen, {
|
|
9787
|
+
name: "episode",
|
|
9788
|
+
value: parseInt(m[1], 10),
|
|
9789
|
+
inputString: input
|
|
9790
|
+
}));
|
|
9791
|
+
const inner = raw.indexOf("[");
|
|
9792
|
+
toAppend.push(new Match(rg.start + inner + 1, rg.end - 1, {
|
|
9793
|
+
name: "release_group",
|
|
9794
|
+
value: m[2],
|
|
9795
|
+
inputString: input
|
|
9796
|
+
}));
|
|
9797
|
+
}
|
|
9798
|
+
return toRemove.length || toAppend.length ? [toRemove, toAppend] : false;
|
|
9799
|
+
}
|
|
9800
|
+
};
|
|
9801
|
+
_NumericPrefixedGroupRule.priority = -32;
|
|
9802
|
+
let NumericPrefixedGroupRule = _NumericPrefixedGroupRule;
|
|
9594
9803
|
const _TrailingTokenAfterEpisodeAsReleaseGroup = class _TrailingTokenAfterEpisodeAsReleaseGroup extends Rule {
|
|
9595
9804
|
constructor(valueFormatter) {
|
|
9596
9805
|
super();
|
|
@@ -10800,10 +11009,11 @@ function imdb(_config) {
|
|
|
10800
11009
|
function volume(_config) {
|
|
10801
11010
|
const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "volume") });
|
|
10802
11011
|
rebulk.regexDefaults({ flags: "i" });
|
|
10803
|
-
rebulk.regex("vol(?:\\d{1,3}|(?:ume)?[-. ]\\d{1,3})", {
|
|
11012
|
+
rebulk.regex("vol(?:\\d{1,3}|(?:ume)?[-. ]{1,2}\\d{1,3})(?:v\\d)?(?:[&+]\\d{1,3})?", {
|
|
10804
11013
|
name: "volume",
|
|
10805
11014
|
validator: sepsSurround,
|
|
10806
|
-
formatter: (value) => parseInt(value.replace(
|
|
11015
|
+
formatter: (value) => parseInt(String(value).replace(/^vol(?:ume)?[-. ]*/i, "").replace(/[v&+].*$/i, ""), 10),
|
|
11016
|
+
conflictSolver: (match, other2) => other2.name === "episode" || other2.name === "season" ? other2 : "__default__"
|
|
10807
11017
|
});
|
|
10808
11018
|
return rebulk;
|
|
10809
11019
|
}
|
|
@@ -11428,8 +11638,8 @@ const advanced_config = {
|
|
|
11428
11638
|
"sub"
|
|
11429
11639
|
],
|
|
11430
11640
|
groups: {
|
|
11431
|
-
starting: "([{",
|
|
11432
|
-
ending: ")]}"
|
|
11641
|
+
starting: "([{【「(",
|
|
11642
|
+
ending: ")]}】」)"
|
|
11433
11643
|
},
|
|
11434
11644
|
audio_codec: {
|
|
11435
11645
|
audio_codec: {
|
|
@@ -12581,7 +12791,8 @@ const advanced_config = {
|
|
|
12581
12791
|
string: [
|
|
12582
12792
|
"Ova",
|
|
12583
12793
|
"Oav"
|
|
12584
|
-
]
|
|
12794
|
+
],
|
|
12795
|
+
tags: "title-word"
|
|
12585
12796
|
},
|
|
12586
12797
|
"Original Net Animation": "Ona",
|
|
12587
12798
|
"Original Animation DVD": "Oad",
|