guessit-js 4.0.2 → 4.2.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/data/tlds.d.ts +1 -0
- package/dist/guessit-js.cjs +862 -166
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +862 -166
- package/dist/guessit-js.js.map +1 -1
- package/dist/rules/processors.d.ts +7 -0
- package/dist/rules/properties/episodes.d.ts +9 -2
- package/dist/rules/properties/other.d.ts +7 -1
- package/dist/schema.d.ts +2 -2
- package/package.json +1 -1
package/dist/guessit-js.js
CHANGED
|
@@ -3231,6 +3231,43 @@ function isDisabled(context, name) {
|
|
|
3231
3231
|
if (includes && includes.length > 0 && !includes.includes(name)) return true;
|
|
3232
3232
|
return false;
|
|
3233
3233
|
}
|
|
3234
|
+
const CJK_DIGITS = {
|
|
3235
|
+
"零": 0,
|
|
3236
|
+
"一": 1,
|
|
3237
|
+
"二": 2,
|
|
3238
|
+
"两": 2,
|
|
3239
|
+
"三": 3,
|
|
3240
|
+
"四": 4,
|
|
3241
|
+
"五": 5,
|
|
3242
|
+
"六": 6,
|
|
3243
|
+
"七": 7,
|
|
3244
|
+
"八": 8,
|
|
3245
|
+
"九": 9
|
|
3246
|
+
};
|
|
3247
|
+
const CJK_NUMBER = "(?:\\d{1,4}|[一二两三四五六七八九]?十[一二两三四五六七八九]?|[零一二两三四五六七八九])";
|
|
3248
|
+
function parseCjkNumber(value) {
|
|
3249
|
+
if (/^\d+$/.test(value)) return parseInt(value, 10);
|
|
3250
|
+
if (value.includes("十")) {
|
|
3251
|
+
const [tens, ones] = value.split("十");
|
|
3252
|
+
const tensValue = tens ? CJK_DIGITS[tens] : 1;
|
|
3253
|
+
const onesValue = ones ? CJK_DIGITS[ones] : 0;
|
|
3254
|
+
return tensValue * 10 + onesValue;
|
|
3255
|
+
}
|
|
3256
|
+
return CJK_DIGITS[value];
|
|
3257
|
+
}
|
|
3258
|
+
function splitWords(entries) {
|
|
3259
|
+
const words = [];
|
|
3260
|
+
const numfirst = [];
|
|
3261
|
+
for (const entry of entries) {
|
|
3262
|
+
if (typeof entry === "object") {
|
|
3263
|
+
if (entry.numfirst) numfirst.push(entry.value);
|
|
3264
|
+
words.push(entry.value);
|
|
3265
|
+
} else {
|
|
3266
|
+
words.push(entry);
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
return { words, numfirst };
|
|
3270
|
+
}
|
|
3234
3271
|
function episodesSeasonChainBreaker(matches, config) {
|
|
3235
3272
|
const episodes2 = matches.named("episode") || [];
|
|
3236
3273
|
if (episodes2.length > 1 && Math.abs(episodes2[episodes2.length - 1].value - episodes2[episodes2.length - 2].value) > config.episode_max_range) {
|
|
@@ -3250,6 +3287,18 @@ function episodesSeasonChainBreaker(matches, config) {
|
|
|
3250
3287
|
return false;
|
|
3251
3288
|
}
|
|
3252
3289
|
function seasonEpisodeConflictSolver(match, other2) {
|
|
3290
|
+
const famChild = (p) => {
|
|
3291
|
+
if (p?.name) return null;
|
|
3292
|
+
const ch = [...p?.children ?? []];
|
|
3293
|
+
return ch.find((c) => c.name === "season" || c.name === "episode") ?? null;
|
|
3294
|
+
};
|
|
3295
|
+
const mChild = famChild(match);
|
|
3296
|
+
const oChild = famChild(other2);
|
|
3297
|
+
if (mChild && oChild) {
|
|
3298
|
+
const mNumfirst = !!mChild.tags?.includes("numfirst");
|
|
3299
|
+
const oNumfirst = !!oChild.tags?.includes("numfirst");
|
|
3300
|
+
if (mNumfirst !== oNumfirst) return null;
|
|
3301
|
+
}
|
|
3253
3302
|
if (match.name !== other2.name) {
|
|
3254
3303
|
if (match.name === "episode" && other2.name === "year") {
|
|
3255
3304
|
return match;
|
|
@@ -3269,6 +3318,38 @@ function seasonEpisodeConflictSolver(match, other2) {
|
|
|
3269
3318
|
}
|
|
3270
3319
|
}
|
|
3271
3320
|
if (["season", "episode"].includes(match.name) && ["season", "episode"].includes(other2.name) && match.initiator !== other2.initiator) {
|
|
3321
|
+
const isWeak = (m) => !!(m.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(m.initiator?.name));
|
|
3322
|
+
const matchNumfirst = !!match.tags?.includes("numfirst");
|
|
3323
|
+
const otherNumfirst = !!other2.tags?.includes("numfirst");
|
|
3324
|
+
if (matchNumfirst !== otherNumfirst && !isWeak(match) && !isWeak(other2) && match.start < other2.end && other2.start < match.end) {
|
|
3325
|
+
const nf = matchNumfirst ? match : other2;
|
|
3326
|
+
const wf = matchNumfirst ? other2 : match;
|
|
3327
|
+
const input = match.inputString ?? "";
|
|
3328
|
+
const digitToken = (from, dir) => {
|
|
3329
|
+
let i = from;
|
|
3330
|
+
while (i >= 0 && i < input.length && seps.includes(input[i])) i += dir;
|
|
3331
|
+
let tok = "";
|
|
3332
|
+
while (i >= 0 && i < input.length && /\d/.test(input[i])) {
|
|
3333
|
+
tok = tok + input[i];
|
|
3334
|
+
i += dir;
|
|
3335
|
+
}
|
|
3336
|
+
return tok;
|
|
3337
|
+
};
|
|
3338
|
+
const isYearLike = (t) => t.length === 4 && +t >= 1900 && +t <= 2100;
|
|
3339
|
+
const nfInit = nf.initiator ?? nf;
|
|
3340
|
+
const wfInit = wf.initiator ?? wf;
|
|
3341
|
+
const nfDangling = (() => {
|
|
3342
|
+
const t = digitToken(nfInit.end, 1);
|
|
3343
|
+
return t.length >= 1 && t.length <= 4 && !isYearLike(t);
|
|
3344
|
+
})();
|
|
3345
|
+
const wfDangling = (() => {
|
|
3346
|
+
const before = input.slice(Math.max(0, wfInit.start - 12), wfInit.start);
|
|
3347
|
+
const m = /(\d{1,3})(?:ª|º|°|a|o|-?(?:й|я|е|го|ая|ый|ое))?[\s.,_\-–]*$/iu.exec(before);
|
|
3348
|
+
return !!(m && !isYearLike(m[1]));
|
|
3349
|
+
})();
|
|
3350
|
+
if (wfDangling && !nfDangling) return wf;
|
|
3351
|
+
return nf;
|
|
3352
|
+
}
|
|
3272
3353
|
const matchIsWeak = !!(match.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(match.initiator?.name));
|
|
3273
3354
|
const otherIsWeak = !!(other2.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(other2.initiator?.name));
|
|
3274
3355
|
if (matchIsWeak && otherIsWeak) {
|
|
@@ -3320,11 +3401,41 @@ function seasonWordNotYear(match) {
|
|
|
3320
3401
|
function episodes(config) {
|
|
3321
3402
|
config.range_separators;
|
|
3322
3403
|
const discreteSeparators = config.discrete_separators;
|
|
3323
|
-
seps.split("").filter((s) => !config.range_separators.includes(s));
|
|
3404
|
+
const weakDiscreteSeparators = seps.split("").filter((s) => !config.range_separators.includes(s) && s !== "/" && s !== "\\");
|
|
3324
3405
|
const allSeparators = [
|
|
3325
3406
|
...config.range_separators,
|
|
3326
|
-
...discreteSeparators
|
|
3407
|
+
...discreteSeparators,
|
|
3408
|
+
...weakDiscreteSeparators
|
|
3327
3409
|
];
|
|
3410
|
+
const moduleOrderingValidator = orderingValidator;
|
|
3411
|
+
const localOrderingValidator = (match) => {
|
|
3412
|
+
if (!moduleOrderingValidator(match)) return false;
|
|
3413
|
+
const isConsecutive = (prop) => {
|
|
3414
|
+
let previous = null;
|
|
3415
|
+
let valid = true;
|
|
3416
|
+
const children = match.children;
|
|
3417
|
+
const named = children?.named?.(prop) ?? [];
|
|
3418
|
+
for (const current of Array.isArray(named) ? named : [named]) {
|
|
3419
|
+
if (previous) {
|
|
3420
|
+
const separator = children.previous?.(current, (m) => m.name === prop + "Separator", 0);
|
|
3421
|
+
if (separator) {
|
|
3422
|
+
const sraw = String(separator.raw ?? "");
|
|
3423
|
+
if (!config.range_separators.includes(sraw) && weakDiscreteSeparators.includes(sraw)) {
|
|
3424
|
+
const gap = Number(current.value) - Number(previous.value);
|
|
3425
|
+
if (!(gap > 0 && gap <= config.max_range_gap + 1)) valid = false;
|
|
3426
|
+
}
|
|
3427
|
+
if (discreteSeparators.includes(sraw)) {
|
|
3428
|
+
valid = true;
|
|
3429
|
+
break;
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
}
|
|
3433
|
+
previous = current;
|
|
3434
|
+
}
|
|
3435
|
+
return valid;
|
|
3436
|
+
};
|
|
3437
|
+
return isConsecutive("episode") && isConsecutive("season");
|
|
3438
|
+
};
|
|
3328
3439
|
const wordNumerals = [
|
|
3329
3440
|
"zero",
|
|
3330
3441
|
"one",
|
|
@@ -3372,15 +3483,16 @@ function episodes(config) {
|
|
|
3372
3483
|
}
|
|
3373
3484
|
const rebulk = new Rebulk().regexDefaults({ flags: "i" }).stringDefaults({ ignoreCase: true }).defaults({
|
|
3374
3485
|
privateNames: ["episodeSeparator", "seasonSeparator", "episodeMarker", "seasonMarker"],
|
|
3375
|
-
formatter: { season: (v) => parseInt(v, 10), episode: (v) => parseInt(v, 10), version: (v) => parseInt(v, 10) },
|
|
3486
|
+
formatter: { season: (v) => parseInt(v, 10), episode: (v) => parseInt(v, 10), version: (v) => parseInt(v, 10), count: (v) => parseInt(v, 10) },
|
|
3376
3487
|
children: true,
|
|
3377
3488
|
privateParent: true,
|
|
3378
3489
|
conflictSolver: seasonEpisodeConflictSolver,
|
|
3379
3490
|
abbreviations: [altDash]
|
|
3380
3491
|
});
|
|
3381
|
-
rebulk.regex(
|
|
3382
|
-
rebulk.regex(
|
|
3383
|
-
rebulk.regex("(?<season>\\d{1,2})
|
|
3492
|
+
rebulk.regex(`第(?<episode>${CJK_NUMBER})[話话集]`, { tags: ["SxxExx"], formatter: { episode: parseCjkNumber } });
|
|
3493
|
+
rebulk.regex(`第(?<season>${CJK_NUMBER})季`, { tags: ["SxxExx"], formatter: { season: parseCjkNumber } });
|
|
3494
|
+
rebulk.regex("(?:シーズン|シリーズ)(?<season>\\d{1,2})(?!\\d)", { tags: ["SxxExx"] });
|
|
3495
|
+
rebulk.regex("(?<!\\d)(?<season>\\d{1,2})期", {});
|
|
3384
3496
|
const seasonMarkerPattern = buildOrPattern(config.season_markers, "seasonMarker");
|
|
3385
3497
|
const episodeMarkerPattern = buildOrPattern(
|
|
3386
3498
|
[...config.episode_markers, ...config.disc_markers],
|
|
@@ -3395,7 +3507,7 @@ function episodes(config) {
|
|
|
3395
3507
|
tags: ["SxxExx"],
|
|
3396
3508
|
validateAll: true,
|
|
3397
3509
|
validator: {
|
|
3398
|
-
__parent__: and_(sepsSurround,
|
|
3510
|
+
__parent__: and_(sepsSurround, localOrderingValidator)
|
|
3399
3511
|
},
|
|
3400
3512
|
chainBreaker: (matches) => episodesSeasonChainBreaker(matches, config),
|
|
3401
3513
|
disabled: isSeasonEpisodeDisabled
|
|
@@ -3405,6 +3517,7 @@ function episodes(config) {
|
|
|
3405
3517
|
allSeparatorsPattern + `@?(?<episode>\\d+)`
|
|
3406
3518
|
).repeater("*");
|
|
3407
3519
|
const seasonEpMarkerPattern = buildOrPattern(config.season_ep_markers, "episodeMarker");
|
|
3520
|
+
const asymmetricSeasonEpMarker = `(?!@` + buildOrPattern(config.season_ep_markers) + `\\d)`;
|
|
3408
3521
|
rebulk.chain({
|
|
3409
3522
|
tags: ["SxxExx"],
|
|
3410
3523
|
validateAll: true,
|
|
@@ -3413,7 +3526,7 @@ function episodes(config) {
|
|
|
3413
3526
|
},
|
|
3414
3527
|
disabled: isSeasonEpisodeDisabled
|
|
3415
3528
|
}).defaults({ tags: ["SxxExx"] }).regex(
|
|
3416
|
-
`(?<season>\\d+)
|
|
3529
|
+
`(?<season>\\d+)` + asymmetricSeasonEpMarker + `@?` + seasonEpMarkerPattern + `@?(?<episode>\\d+)`
|
|
3417
3530
|
).repeater("+");
|
|
3418
3531
|
rebulk.chain({
|
|
3419
3532
|
tags: ["SxxExx"],
|
|
@@ -3422,13 +3535,17 @@ function episodes(config) {
|
|
|
3422
3535
|
__parent__: and_(sepsSurround, orderingValidator)
|
|
3423
3536
|
},
|
|
3424
3537
|
disabled: isSeasonEpisodeDisabled
|
|
3425
|
-
}).defaults({ tags: ["SxxExx"] }).regex(`(?<season>\\d+)
|
|
3538
|
+
}).defaults({ tags: ["SxxExx"] }).regex(`(?<season>\\d+)` + asymmetricSeasonEpMarker + `@?` + seasonEpMarkerPattern + `@?(?<episode>\\d+)`).regex(
|
|
3426
3539
|
buildOrPattern(
|
|
3427
3540
|
[...config.season_ep_markers, ...discreteSeparators, ...config.range_separators],
|
|
3428
3541
|
"episodeSeparator",
|
|
3429
3542
|
true
|
|
3430
3543
|
) + `(?<episode>\\d+)`
|
|
3431
3544
|
).repeater("*");
|
|
3545
|
+
rebulk.regex(
|
|
3546
|
+
`t(?<season>\\d{1,2})@?` + buildOrPattern(config.episode_markers, "episodeMarker") + `@?(?<episode>\\d{1,4})`,
|
|
3547
|
+
{ tags: ["SxxExx"], disabled: isSeasonEpisodeDisabled }
|
|
3548
|
+
);
|
|
3432
3549
|
const seasonOnlySepPattern = buildOrPattern(
|
|
3433
3550
|
[...config.season_markers, ...discreteSeparators, ...config.range_separators],
|
|
3434
3551
|
"seasonSeparator",
|
|
@@ -3451,7 +3568,9 @@ function episodes(config) {
|
|
|
3451
3568
|
disabled: (context) => isDisabled(context, "episode_details")
|
|
3452
3569
|
});
|
|
3453
3570
|
}
|
|
3454
|
-
const
|
|
3571
|
+
const { words: seasonWords, numfirst: seasonWordsNumfirst } = splitWords(config.season_words);
|
|
3572
|
+
const { words: episodeWords, numfirst: episodeWordsNumfirst } = splitWords(config.episode_words);
|
|
3573
|
+
const seasonWordPattern = buildOrPattern(seasonWords, "seasonMarker");
|
|
3455
3574
|
const ofWordPattern = buildOrPattern(config.of_words);
|
|
3456
3575
|
rebulk.chain({
|
|
3457
3576
|
validateAll: true,
|
|
@@ -3475,7 +3594,28 @@ function episodes(config) {
|
|
|
3475
3594
|
true
|
|
3476
3595
|
) + `@?(?P<season>\\d+)`
|
|
3477
3596
|
).repeater("*");
|
|
3478
|
-
const
|
|
3597
|
+
const ofCountPattern = `(?:@?` + ofWordPattern + `@?(?<count>\\d+))?`;
|
|
3598
|
+
if (seasonWordsNumfirst.length > 0) {
|
|
3599
|
+
rebulk.regex(
|
|
3600
|
+
`(?<season>\\d{1,2})` + config.ordinal_suffix + `@?@?` + buildOrPattern(seasonWordsNumfirst, "seasonMarker") + `(?![^\\W\\d_])` + ofCountPattern,
|
|
3601
|
+
{
|
|
3602
|
+
tags: ["SxxExx", "numfirst"],
|
|
3603
|
+
formatter: { season: parseNumber, count: (v) => parseInt(v, 10) },
|
|
3604
|
+
disabled: isSeasonEpisodeDisabled
|
|
3605
|
+
}
|
|
3606
|
+
);
|
|
3607
|
+
}
|
|
3608
|
+
if (episodeWordsNumfirst.length > 0) {
|
|
3609
|
+
rebulk.regex(
|
|
3610
|
+
`(?<episode>\\d{1,3})` + config.ordinal_suffix + `@?@?` + buildOrPattern(episodeWordsNumfirst, "episodeMarker") + `(?![^\\W\\d_])` + ofCountPattern,
|
|
3611
|
+
{
|
|
3612
|
+
tags: ["SxxExx", "numfirst"],
|
|
3613
|
+
formatter: { episode: parseNumber, count: (v) => parseInt(v, 10) },
|
|
3614
|
+
disabled: (context) => isDisabled(context, "episode")
|
|
3615
|
+
}
|
|
3616
|
+
);
|
|
3617
|
+
}
|
|
3618
|
+
const episodeWordPattern = buildOrPattern(episodeWords, "episodeMarker");
|
|
3479
3619
|
rebulk.regex(
|
|
3480
3620
|
`(?<![a-zA-Z\\d])` + episodeWordPattern + `@?(?<episode>\\d+)(?:v(?<version>\\d+))?(?:@?` + ofWordPattern + `@?(?<count>\\d+))?`,
|
|
3481
3621
|
{
|
|
@@ -3501,13 +3641,13 @@ function episodes(config) {
|
|
|
3501
3641
|
rebulk.chain({
|
|
3502
3642
|
tags: ["weak-episode"],
|
|
3503
3643
|
disabled: (context) => context?.type === "movie" || isDisabled(context, "episode")
|
|
3504
|
-
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<episode>\\d{2})(?!(?:st|nd|rd|th)\\b)`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{2})`, {
|
|
3644
|
+
}).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})`, {
|
|
3505
3645
|
abbreviations: null
|
|
3506
3646
|
}).repeater("*");
|
|
3507
3647
|
rebulk.chain({
|
|
3508
3648
|
tags: ["weak-episode"],
|
|
3509
3649
|
disabled: (context) => context?.type === "movie" || isDisabled(context, "episode")
|
|
3510
|
-
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`0(?<episode>\\d{1,2})`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])0(?<episode>\\d{1,2})`, {
|
|
3650
|
+
}).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})`, {
|
|
3511
3651
|
abbreviations: null
|
|
3512
3652
|
}).repeater("*");
|
|
3513
3653
|
rebulk.chain({
|
|
@@ -3518,13 +3658,13 @@ function episodes(config) {
|
|
|
3518
3658
|
validator: null,
|
|
3519
3659
|
tags: ["weak-episode"],
|
|
3520
3660
|
name: "weak_episode"
|
|
3521
|
-
}).regex(`(?<episode>\\d{3,4})`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{3,4})`, {
|
|
3661
|
+
}).regex(`(?<![^\\W_])(?<episode>\\d{3,4})(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{3,4})`, {
|
|
3522
3662
|
abbreviations: null
|
|
3523
3663
|
}).repeater("*");
|
|
3524
3664
|
rebulk.chain({
|
|
3525
3665
|
tags: ["weak-episode"],
|
|
3526
3666
|
disabled: (context) => context?.type !== "episode" || isDisabled(context, "episode")
|
|
3527
|
-
}).defaults({ validator: null, tags: ["weak-episode"] }).regex(`(?<episode>\\d)`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>[x-])(?<episode>\\d{1,2})`, {
|
|
3667
|
+
}).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})`, {
|
|
3528
3668
|
abbreviations: null
|
|
3529
3669
|
}).repeater("*");
|
|
3530
3670
|
rebulk.chain({
|
|
@@ -3553,7 +3693,7 @@ function episodes(config) {
|
|
|
3553
3693
|
name: "weak_duplicate",
|
|
3554
3694
|
validator: null,
|
|
3555
3695
|
conflictSolver: seasonEpisodeConflictSolver
|
|
3556
|
-
}).regex(`(?<season>\\d{1,2})(?<episode>\\d{2})`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>x|-)(?<episode>\\d{2})`, {
|
|
3696
|
+
}).regex(`(?<![^\\W_])(?<season>\\d{1,2})(?<episode>\\d{2})(?!(?![vV]\\d)[^\\W_])`).regex(`v(?<version>\\d+)`).repeater("?").regex(`(?<episodeSeparator>x|-)(?<episode>\\d{2})`, {
|
|
3557
3697
|
abbreviations: null
|
|
3558
3698
|
}).repeater("*");
|
|
3559
3699
|
rebulk.regex(`v(?<version>\\d+)`, {
|
|
@@ -3561,9 +3701,11 @@ function episodes(config) {
|
|
|
3561
3701
|
disabled: (context) => isDisabled(context, "version")
|
|
3562
3702
|
});
|
|
3563
3703
|
rebulk.regex(
|
|
3564
|
-
|
|
3704
|
+
// The lookbehind keeps this off token tails: "AC3-de[42]" is not "episode 3 of 42"
|
|
3705
|
+
// ('de' is also a Spanish of-word — codec suffixes must stay intact).
|
|
3706
|
+
`(?<![^\\W_])(?<episode>\\d+)@?` + ofWordPattern + `@?(?<count>\\d+)@?` + episodeWordPattern + "?",
|
|
3565
3707
|
{
|
|
3566
|
-
formatter: { episode: (v) => parseInt(v, 10),
|
|
3708
|
+
formatter: { episode: (v) => parseInt(v, 10), count: (v) => parseInt(v, 10) },
|
|
3567
3709
|
preMatchProcessor: (match) => {
|
|
3568
3710
|
match.value = cleanup(match.value);
|
|
3569
3711
|
return match;
|
|
@@ -3579,6 +3721,8 @@ function episodes(config) {
|
|
|
3579
3721
|
disabled: (context) => isDisabled(context, "episode_format")
|
|
3580
3722
|
});
|
|
3581
3723
|
rebulk.rules(
|
|
3724
|
+
RemoveNumfirstMarkerCollision,
|
|
3725
|
+
CountValidator,
|
|
3582
3726
|
new DiscMarkerRule(config),
|
|
3583
3727
|
FixCorruptedGroupBoundaryValues,
|
|
3584
3728
|
new RangeExpansionRule(config),
|
|
@@ -3592,6 +3736,73 @@ function episodes(config) {
|
|
|
3592
3736
|
);
|
|
3593
3737
|
return rebulk;
|
|
3594
3738
|
}
|
|
3739
|
+
const _RemoveNumfirstMarkerCollision = class _RemoveNumfirstMarkerCollision extends Rule {
|
|
3740
|
+
constructor() {
|
|
3741
|
+
super(...arguments);
|
|
3742
|
+
this.priority = 70;
|
|
3743
|
+
this.consequence = RemoveMatch;
|
|
3744
|
+
}
|
|
3745
|
+
when(matches, _context) {
|
|
3746
|
+
const toRemove = [];
|
|
3747
|
+
const isWeak = (m) => !!(m.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(m.initiator?.name));
|
|
3748
|
+
const removeWithParent = (m) => {
|
|
3749
|
+
const init = m.initiator ?? m;
|
|
3750
|
+
if (!toRemove.includes(m)) toRemove.push(m);
|
|
3751
|
+
for (const child of init.children ?? []) {
|
|
3752
|
+
if (!toRemove.includes(child)) toRemove.push(child);
|
|
3753
|
+
}
|
|
3754
|
+
};
|
|
3755
|
+
const all = [...matches];
|
|
3756
|
+
const numfirsts = all.filter((m) => (m.name === "season" || m.name === "episode") && m.tags?.includes("numfirst"));
|
|
3757
|
+
for (const nf of numfirsts) {
|
|
3758
|
+
const nfInit = nf.initiator ?? nf;
|
|
3759
|
+
const wordFirst = all.find((w) => {
|
|
3760
|
+
if (w.name !== "season" && w.name !== "episode") return false;
|
|
3761
|
+
if (w.tags?.includes("numfirst") || isWeak(w)) return false;
|
|
3762
|
+
const wInit = w.initiator ?? w;
|
|
3763
|
+
if (wInit === nfInit) return false;
|
|
3764
|
+
return wInit.start < nfInit.end && nfInit.start < wInit.end;
|
|
3765
|
+
});
|
|
3766
|
+
if (!wordFirst) continue;
|
|
3767
|
+
const claimed = all.some((m) => !m.private && (m.name === "screen_size" || m.name === "year") && m.start < wordFirst.end && wordFirst.start < m.end);
|
|
3768
|
+
if (claimed) removeWithParent(wordFirst);
|
|
3769
|
+
else removeWithParent(nf);
|
|
3770
|
+
}
|
|
3771
|
+
return toRemove.length ? toRemove : false;
|
|
3772
|
+
}
|
|
3773
|
+
};
|
|
3774
|
+
_RemoveNumfirstMarkerCollision.priority = 70;
|
|
3775
|
+
let RemoveNumfirstMarkerCollision = _RemoveNumfirstMarkerCollision;
|
|
3776
|
+
const _CountValidator = class _CountValidator extends Rule {
|
|
3777
|
+
constructor() {
|
|
3778
|
+
super(...arguments);
|
|
3779
|
+
this.priority = 64;
|
|
3780
|
+
this.consequence = [RemoveMatch, new RenameMatch("episode_count"), new RenameMatch("season_count")];
|
|
3781
|
+
}
|
|
3782
|
+
when(matches, _context) {
|
|
3783
|
+
const toRemove = [];
|
|
3784
|
+
const episodeCount = [];
|
|
3785
|
+
const seasonCount = [];
|
|
3786
|
+
for (const count of matches.named("count") ?? []) {
|
|
3787
|
+
const numbers = matches.range(
|
|
3788
|
+
count.initiator.start,
|
|
3789
|
+
count.start,
|
|
3790
|
+
(m) => m.name === "episode" || m.name === "season"
|
|
3791
|
+
);
|
|
3792
|
+
const numbered = numbers.length ? numbers[numbers.length - 1] : void 0;
|
|
3793
|
+
if (!numbered) toRemove.push(count);
|
|
3794
|
+
else if (numbered.name === "episode") episodeCount.push(count);
|
|
3795
|
+
else seasonCount.push(count);
|
|
3796
|
+
}
|
|
3797
|
+
if (toRemove.length || episodeCount.length || seasonCount.length) {
|
|
3798
|
+
return [toRemove, episodeCount, seasonCount];
|
|
3799
|
+
}
|
|
3800
|
+
return false;
|
|
3801
|
+
}
|
|
3802
|
+
};
|
|
3803
|
+
_CountValidator.priority = 64;
|
|
3804
|
+
_CountValidator.consequence = [RemoveMatch, new RenameMatch("episode_count"), new RenameMatch("season_count")];
|
|
3805
|
+
let CountValidator = _CountValidator;
|
|
3595
3806
|
const _DiscMarkerRule = class _DiscMarkerRule extends Rule {
|
|
3596
3807
|
constructor(config) {
|
|
3597
3808
|
super();
|
|
@@ -4197,6 +4408,14 @@ function source(config) {
|
|
|
4197
4408
|
...buildSourcePattern(["DVD"], "", optional(ripSuffix)),
|
|
4198
4409
|
{ value: { source: "DVD", other: "Rip" } }
|
|
4199
4410
|
);
|
|
4411
|
+
rebulk.regex(
|
|
4412
|
+
...buildSourcePattern(["LD"], "", ripSuffix),
|
|
4413
|
+
{ value: { source: "Laserdisc", other: "Rip" } }
|
|
4414
|
+
);
|
|
4415
|
+
rebulk.regex(
|
|
4416
|
+
...buildSourcePattern(["LASERDISC"], "", optional(ripSuffix)),
|
|
4417
|
+
{ value: { source: "Laserdisc", other: "Rip" } }
|
|
4418
|
+
);
|
|
4200
4419
|
rebulk.regex(
|
|
4201
4420
|
...buildSourcePattern(["DM"], "", optional(ripSuffix)),
|
|
4202
4421
|
{ value: { source: "Digital Master", other: "Rip" } }
|
|
@@ -4774,6 +4993,10 @@ const COMPOUND_PROFILES = {
|
|
|
4774
4993
|
"Dolby Digital": "EX"
|
|
4775
4994
|
};
|
|
4776
4995
|
const _CompoundAudioProfileRule = class _CompoundAudioProfileRule extends Rule {
|
|
4996
|
+
constructor() {
|
|
4997
|
+
super(...arguments);
|
|
4998
|
+
this.priority = 128;
|
|
4999
|
+
}
|
|
4777
5000
|
enabled(context) {
|
|
4778
5001
|
return !isDisabled(context, "audio_profile");
|
|
4779
5002
|
}
|
|
@@ -4816,6 +5039,7 @@ const _CompoundAudioProfileRule = class _CompoundAudioProfileRule extends Rule {
|
|
|
4816
5039
|
}
|
|
4817
5040
|
}
|
|
4818
5041
|
};
|
|
5042
|
+
_CompoundAudioProfileRule.priority = 128;
|
|
4819
5043
|
_CompoundAudioProfileRule.consequence = AppendMatch;
|
|
4820
5044
|
let CompoundAudioProfileRule = _CompoundAudioProfileRule;
|
|
4821
5045
|
const _AudioProfileRule = class _AudioProfileRule extends Rule {
|
|
@@ -4900,17 +5124,29 @@ const _AudioValidatorRule = class _AudioValidatorRule extends Rule {
|
|
|
4900
5124
|
}
|
|
4901
5125
|
when(matches, _context) {
|
|
4902
5126
|
const ret = [];
|
|
4903
|
-
const
|
|
5127
|
+
const AUDIO_PROPS = ["audio_codec", "audio_profile", "audio_channels"];
|
|
5128
|
+
const audioProps = AUDIO_PROPS.flatMap((n) => [...matches.named(n)]);
|
|
4904
5129
|
for (const prop of audioProps) {
|
|
4905
5130
|
if (!sepsBefore(prop)) {
|
|
4906
|
-
const
|
|
4907
|
-
|
|
5131
|
+
const validBefore = matches.range(
|
|
5132
|
+
prop.start - 1,
|
|
5133
|
+
prop.start,
|
|
5134
|
+
(m) => AUDIO_PROPS.includes(m.name ?? "")
|
|
5135
|
+
);
|
|
5136
|
+
if (!(Array.isArray(validBefore) ? validBefore.length : validBefore)) {
|
|
4908
5137
|
ret.push(prop);
|
|
5138
|
+
continue;
|
|
4909
5139
|
}
|
|
4910
|
-
}
|
|
4911
|
-
|
|
4912
|
-
|
|
5140
|
+
}
|
|
5141
|
+
if (!sepsAfter(prop)) {
|
|
5142
|
+
const validAfter = matches.range(
|
|
5143
|
+
prop.end,
|
|
5144
|
+
prop.end + 1,
|
|
5145
|
+
(m) => AUDIO_PROPS.includes(m.name ?? "")
|
|
5146
|
+
);
|
|
5147
|
+
if (!(Array.isArray(validAfter) ? validAfter.length : validAfter)) {
|
|
4913
5148
|
ret.push(prop);
|
|
5149
|
+
continue;
|
|
4914
5150
|
}
|
|
4915
5151
|
}
|
|
4916
5152
|
}
|
|
@@ -5017,7 +5253,8 @@ function screenSize(config) {
|
|
|
5017
5253
|
const frameRatePattern = buildOrPattern(frameRates, "frame_rate");
|
|
5018
5254
|
const interlacedPattern = buildOrPattern([...interlaced], "height");
|
|
5019
5255
|
const progressivePattern = buildOrPattern([...progressive], "height");
|
|
5020
|
-
const
|
|
5256
|
+
const resSeparator = `(?:x|\\*|×)`;
|
|
5257
|
+
const resPattern = `(?:(?<width>\\d{3,4})${resSeparator})?`;
|
|
5021
5258
|
rebulk.regex(resPattern + interlacedPattern + `(?<scan_type>i)` + frameRatePattern + `?`);
|
|
5022
5259
|
rebulk.regex(resPattern + progressivePattern + `(?<scan_type>p)` + frameRatePattern + `?`);
|
|
5023
5260
|
rebulk.regex(resPattern + progressivePattern + `(?<scan_type>p)?(?:hd)`);
|
|
@@ -5026,7 +5263,7 @@ function screenSize(config) {
|
|
|
5026
5263
|
value: "2160p",
|
|
5027
5264
|
conflictSolver: (match, other2) => other2.name === "screen_size" ? "__default__" : match
|
|
5028
5265
|
});
|
|
5029
|
-
rebulk.regex(`(?<width>\\d{3,4})
|
|
5266
|
+
rebulk.regex(`(?<width>\\d{3,4})(?:${resSeparator}|-${resSeparator}-)(?<height>\\d{3,4})(?:up)?`, {
|
|
5030
5267
|
conflictSolver: (match, other2) => other2.name === "screen_size" ? "__default__" : other2
|
|
5031
5268
|
});
|
|
5032
5269
|
rebulk.regex(frameRatePattern + `-?(?:p|fps)`, {
|
|
@@ -5060,7 +5297,7 @@ const _PostProcessScreenSize = class _PostProcessScreenSize extends Rule {
|
|
|
5060
5297
|
let values = match.children.toDict();
|
|
5061
5298
|
if (!("height" in values)) {
|
|
5062
5299
|
const raw = String(match.raw ?? "");
|
|
5063
|
-
const rxWxH = /^(\d{3,4})\s*[xX
|
|
5300
|
+
const rxWxH = /^(\d{3,4})\s*[xX*×]\s*(\d{3,4})(?:up)?$/i;
|
|
5064
5301
|
const mWxH = rxWxH.exec(raw);
|
|
5065
5302
|
if (mWxH) {
|
|
5066
5303
|
values = { width: mWxH[1], height: mWxH[2], scan_type: void 0 };
|
|
@@ -5125,10 +5362,19 @@ const _ResolveScreenSizeConflicts = class _ResolveScreenSizeConflicts extends Ru
|
|
|
5125
5362
|
const conflicts = matches.conflicting(screenSizeMatch, (m) => ["season", "episode"].includes(m.name ?? "")) ?? [];
|
|
5126
5363
|
if (conflicts.length === 0) continue;
|
|
5127
5364
|
let hasNeighbor = false;
|
|
5128
|
-
const
|
|
5129
|
-
|
|
5130
|
-
|
|
5131
|
-
|
|
5365
|
+
const allScreensizes = matches.range(filepart.start, filepart.end, (m) => m.name === "screen_size") ?? [];
|
|
5366
|
+
const groupOf = (m) => matches.markers.atMatch(m, (marker) => marker.name === "group", 0);
|
|
5367
|
+
const following = matches.range(
|
|
5368
|
+
screenSizeMatch.end,
|
|
5369
|
+
filepart.end,
|
|
5370
|
+
(m) => m.name === "video_profile" || m.name === "video_codec",
|
|
5371
|
+
0
|
|
5372
|
+
);
|
|
5373
|
+
if (following && matches.holes(screenSizeMatch.end, following.start, { predicate: (h) => !!(h.value && String(h.value).replace(new RegExp(`[${sepsPattern}]`, "g"), "")) }).length === 0) {
|
|
5374
|
+
if (following.name === "video_profile" || allScreensizes.length === 1 && groupOf(screenSizeMatch) === groupOf(following)) {
|
|
5375
|
+
toRemove.push(...conflicts);
|
|
5376
|
+
hasNeighbor = true;
|
|
5377
|
+
}
|
|
5132
5378
|
}
|
|
5133
5379
|
const previous = matches.previous(screenSizeMatch, (m) => ["date", "source", "other", "streaming_service"].includes(m.name ?? ""), 0);
|
|
5134
5380
|
if (previous && matches.holes(previous.end, screenSizeMatch.start, { predicate: (h) => !!(h.value && String(h.value).replace(new RegExp(`[${sepsPattern}]`, "g"), "")) }).length === 0) {
|
|
@@ -5144,47 +5390,12 @@ const _ResolveScreenSizeConflicts = class _ResolveScreenSizeConflicts extends Ru
|
|
|
5144
5390
|
};
|
|
5145
5391
|
_ResolveScreenSizeConflicts.consequence = RemoveMatch;
|
|
5146
5392
|
let ResolveScreenSizeConflicts = _ResolveScreenSizeConflicts;
|
|
5147
|
-
const DEFAULT_TLDS = [
|
|
5148
|
-
"com",
|
|
5149
|
-
"org",
|
|
5150
|
-
"net",
|
|
5151
|
-
"edu",
|
|
5152
|
-
"gov",
|
|
5153
|
-
"mil",
|
|
5154
|
-
"int",
|
|
5155
|
-
"co",
|
|
5156
|
-
"uk",
|
|
5157
|
-
"ca",
|
|
5158
|
-
"de",
|
|
5159
|
-
"fr",
|
|
5160
|
-
"it",
|
|
5161
|
-
"es",
|
|
5162
|
-
"nl",
|
|
5163
|
-
"be",
|
|
5164
|
-
"ch",
|
|
5165
|
-
"se",
|
|
5166
|
-
"no",
|
|
5167
|
-
"dk",
|
|
5168
|
-
"fi",
|
|
5169
|
-
"pl",
|
|
5170
|
-
"ru",
|
|
5171
|
-
"cn",
|
|
5172
|
-
"jp",
|
|
5173
|
-
"au",
|
|
5174
|
-
"nz",
|
|
5175
|
-
"in",
|
|
5176
|
-
"br",
|
|
5177
|
-
"mx",
|
|
5178
|
-
"za",
|
|
5179
|
-
"kr",
|
|
5180
|
-
"tw",
|
|
5181
|
-
"hk"
|
|
5182
|
-
];
|
|
5393
|
+
const TLDS = ["aarp", "abb", "abbott", "abbvie", "abc", "able", "abogado", "abudhabi", "ac", "academy", "accenture", "accountant", "accountants", "aco", "actor", "ad", "ads", "adult", "ae", "aeg", "aero", "aetna", "af", "afl", "africa", "ag", "agakhan", "agency", "ai", "aig", "airbus", "airforce", "airtel", "akdn", "al", "alibaba", "alipay", "allfinanz", "allstate", "ally", "alsace", "alstom", "am", "amazon", "americanexpress", "americanfamily", "amex", "amfam", "amica", "amsterdam", "analytics", "android", "anquan", "anz", "ao", "aol", "apartments", "app", "apple", "aq", "aquarelle", "ar", "arab", "aramco", "archi", "army", "arpa", "art", "arte", "as", "asda", "asia", "associates", "at", "athleta", "attorney", "au", "auction", "audi", "audible", "audio", "auspost", "author", "auto", "autos", "aw", "aws", "ax", "axa", "az", "azure", "ba", "baby", "baidu", "banamex", "band", "bank", "bar", "barcelona", "barclaycard", "barclays", "barefoot", "bargains", "baseball", "basketball", "bauhaus", "bayern", "bb", "bbc", "bbt", "bbva", "bcg", "bcn", "bd", "be", "beats", "beauty", "beer", "berlin", "best", "bestbuy", "bet", "bf", "bg", "bh", "bharti", "bi", "bible", "bid", "bike", "bing", "bingo", "bio", "biz", "bj", "black", "blackfriday", "blockbuster", "blog", "bloomberg", "blue", "bm", "bms", "bmw", "bn", "bnpparibas", "bo", "boats", "boehringer", "bofa", "bom", "bond", "boo", "book", "booking", "bosch", "bostik", "boston", "bot", "boutique", "box", "br", "bradesco", "bridgestone", "broadway", "broker", "brother", "brussels", "bs", "bt", "build", "builders", "business", "buy", "buzz", "bv", "bw", "by", "bz", "bzh", "ca", "cab", "cafe", "cal", "call", "calvinklein", "cam", "camera", "camp", "canon", "capetown", "capital", "capitalone", "car", "caravan", "cards", "care", "career", "careers", "cars", "casa", "case", "cash", "casino", "cat", "catering", "catholic", "cba", "cbn", "cbre", "cc", "cd", "center", "ceo", "cern", "cf", "cfa", "cfd", "cg", "ch", "chanel", "channel", "charity", "chase", "chat", "cheap", "chintai", "christmas", "chrome", "church", "ci", "cipriani", "circle", "cisco", "citadel", "citi", "citic", "city", "ck", "cl", "claims", "cleaning", "click", "clinic", "clinique", "clothing", "cloud", "club", "clubmed", "cm", "cn", "co", "coach", "codes", "coffee", "college", "cologne", "com", "commbank", "community", "company", "compare", "computer", "comsec", "condos", "construction", "consulting", "contact", "contractors", "cooking", "cool", "coop", "corsica", "country", "coupon", "coupons", "courses", "cpa", "cr", "credit", "creditcard", "creditunion", "cricket", "crown", "crs", "cruise", "cruises", "cu", "cuisinella", "cv", "cw", "cx", "cy", "cymru", "cyou", "cz", "dad", "dance", "data", "date", "dating", "datsun", "day", "dclk", "dds", "de", "deal", "dealer", "deals", "degree", "delivery", "dell", "deloitte", "delta", "democrat", "dental", "dentist", "desi", "design", "dev", "dhl", "diamonds", "diet", "digital", "direct", "directory", "discount", "discover", "dish", "diy", "dj", "dk", "dm", "dnp", "do", "docs", "doctor", "dog", "domains", "dot", "download", "drive", "dtv", "dubai", "dupont", "durban", "dvag", "dvr", "dz", "earth", "eat", "ec", "eco", "edeka", "edu", "education", "ee", "eg", "email", "emerck", "energy", "engineer", "engineering", "enterprises", "epson", "equipment", "er", "ericsson", "erni", "es", "esq", "estate", "et", "eu", "eurovision", "eus", "events", "exchange", "expert", "exposed", "express", "extraspace", "fage", "fail", "fairwinds", "faith", "family", "fan", "fans", "farm", "farmers", "fashion", "fast", "fedex", "feedback", "ferrari", "ferrero", "fi", "fidelity", "fido", "film", "final", "finance", "financial", "fire", "firestone", "firmdale", "fish", "fishing", "fit", "fitness", "fj", "fk", "flickr", "flights", "flir", "florist", "flowers", "fly", "fm", "fo", "foo", "food", "football", "ford", "forex", "forsale", "forum", "foundation", "fox", "fr", "free", "fresenius", "frl", "frogans", "frontier", "ftr", "fujitsu", "fun", "fund", "furniture", "futbol", "fyi", "ga", "gal", "gallery", "gallo", "gallup", "game", "games", "gap", "garden", "gay", "gb", "gbiz", "gd", "gdn", "ge", "gea", "gent", "genting", "george", "gf", "gg", "ggee", "gh", "gi", "gift", "gifts", "gives", "giving", "gl", "glass", "gle", "global", "globo", "gm", "gmail", "gmbh", "gmo", "gmx", "gn", "godaddy", "gold", "goldpoint", "golf", "goodyear", "goog", "google", "gop", "got", "gov", "gp", "gq", "gr", "grainger", "graphics", "gratis", "green", "gripe", "grocery", "group", "gs", "gt", "gu", "gucci", "guge", "guide", "guitars", "guru", "gw", "gy", "hair", "hamburg", "hangout", "haus", "hbo", "hdfc", "hdfcbank", "health", "healthcare", "help", "helsinki", "here", "hermes", "hiphop", "hisamitsu", "hitachi", "hiv", "hk", "hkt", "hm", "hn", "hockey", "holdings", "holiday", "homedepot", "homegoods", "homes", "homesense", "honda", "horse", "hospital", "host", "hosting", "hot", "hotels", "hotmail", "house", "how", "hr", "hsbc", "ht", "hu", "hughes", "hyatt", "hyundai", "ibm", "icbc", "ice", "icu", "id", "ie", "ieee", "ifm", "ikano", "il", "im", "imamat", "imdb", "immo", "immobilien", "in", "inc", "industries", "infiniti", "info", "ing", "ink", "institute", "insurance", "insure", "int", "international", "intuit", "investments", "io", "ipiranga", "iq", "ir", "irish", "is", "ismaili", "ist", "istanbul", "it", "itau", "itv", "jaguar", "java", "jcb", "je", "jeep", "jetzt", "jewelry", "jio", "jll", "jm", "jmp", "jnj", "jo", "jobs", "joburg", "jot", "joy", "jp", "jpmorgan", "jprs", "juegos", "juniper", "kaufen", "kddi", "ke", "kerryhotels", "kerryproperties", "kfh", "kg", "kh", "ki", "kia", "kids", "kim", "kindle", "kitchen", "kiwi", "km", "kn", "koeln", "komatsu", "kosher", "kp", "kpmg", "kpn", "kr", "krd", "kred", "kuokgroup", "kw", "ky", "kyoto", "kz", "la", "lacaixa", "lamborghini", "lamer", "land", "landrover", "lanxess", "lasalle", "lat", "latino", "latrobe", "law", "lawyer", "lb", "lc", "lds", "lease", "leclerc", "lefrak", "legal", "lego", "lexus", "lgbt", "li", "lidl", "life", "lifeinsurance", "lifestyle", "lighting", "like", "lilly", "limited", "limo", "lincoln", "link", "live", "living", "lk", "llc", "llp", "loan", "loans", "locker", "locus", "lol", "london", "lotte", "lotto", "love", "lpl", "lplfinancial", "lr", "ls", "lt", "ltd", "ltda", "lu", "lundbeck", "luxe", "luxury", "lv", "ly", "ma", "madrid", "maif", "maison", "makeup", "man", "management", "mango", "map", "market", "marketing", "markets", "marriott", "marshalls", "mattel", "mba", "mc", "mckinsey", "md", "me", "med", "media", "meet", "melbourne", "meme", "memorial", "men", "menu", "merck", "merckmsd", "mg", "mh", "miami", "microsoft", "mil", "mini", "mint", "mit", "mitsubishi", "mk", "ml", "mlb", "mls", "mm", "mma", "mn", "mo", "mobi", "mobile", "moda", "moe", "moi", "mom", "monash", "money", "monster", "mormon", "mortgage", "moscow", "moto", "motorcycles", "mov", "movie", "mp", "mq", "mr", "ms", "msd", "mt", "mtn", "mtr", "mu", "museum", "music", "mv", "mw", "mx", "my", "mz", "na", "nab", "nagoya", "name", "navy", "nba", "nc", "ne", "nec", "net", "netbank", "netflix", "network", "neustar", "new", "news", "next", "nextdirect", "nexus", "nf", "nfl", "ng", "ngo", "nhk", "ni", "nico", "nike", "nikon", "ninja", "nissan", "nissay", "nl", "no", "nokia", "norton", "now", "nowruz", "nowtv", "np", "nr", "nra", "nrw", "ntt", "nu", "nyc", "nz", "obi", "observer", "office", "okinawa", "olayan", "olayangroup", "ollo", "om", "omega", "one", "ong", "onl", "online", "ooo", "open", "oracle", "orange", "org", "organic", "origins", "osaka", "otsuka", "ott", "ovh", "pa", "page", "panasonic", "paris", "pars", "partners", "parts", "party", "pay", "pccw", "pe", "pet", "pf", "pfizer", "pg", "ph", "pharmacy", "phd", "philips", "phone", "photo", "photography", "photos", "physio", "pics", "pictet", "pictures", "pid", "pin", "ping", "pink", "pioneer", "pizza", "pk", "pl", "place", "play", "playstation", "plumbing", "plus", "pm", "pn", "pnc", "pohl", "poker", "politie", "porn", "post", "pr", "praxi", "press", "prime", "pro", "prod", "productions", "prof", "progressive", "promo", "properties", "property", "protection", "pru", "prudential", "ps", "pt", "pub", "pw", "pwc", "py", "qa", "qpon", "quebec", "quest", "racing", "radio", "re", "read", "realestate", "realtor", "realty", "recipes", "red", "redumbrella", "rehab", "reise", "reisen", "reit", "reliance", "ren", "rent", "rentals", "repair", "report", "republican", "rest", "restaurant", "review", "reviews", "rexroth", "rich", "richardli", "ricoh", "ril", "rio", "rip", "ro", "rocks", "rodeo", "rogers", "room", "rs", "rsvp", "ru", "rugby", "ruhr", "run", "rw", "rwe", "ryukyu", "sa", "saarland", "safe", "safety", "sakura", "sale", "salon", "samsclub", "samsung", "sandvik", "sandvikcoromant", "sanofi", "sap", "sarl", "sas", "save", "saxo", "sb", "sbi", "sbs", "sc", "scb", "schaeffler", "schmidt", "scholarships", "school", "schule", "schwarz", "science", "scot", "sd", "se", "search", "seat", "secure", "security", "seek", "select", "sener", "services", "seven", "sew", "sex", "sexy", "sfr", "sg", "sh", "shangrila", "sharp", "shell", "shia", "shiksha", "shoes", "shop", "shopping", "shouji", "show", "si", "silk", "sina", "singles", "site", "sj", "sk", "ski", "skin", "sky", "skype", "sl", "sling", "sm", "smart", "smile", "sn", "sncf", "so", "soccer", "social", "softbank", "software", "sohu", "solar", "solutions", "song", "sony", "soy", "spa", "space", "sport", "spot", "sr", "srl", "ss", "st", "stada", "staples", "star", "statebank", "statefarm", "stc", "stcgroup", "stockholm", "storage", "store", "stream", "studio", "study", "style", "su", "sucks", "supplies", "supply", "support", "surf", "surgery", "suzuki", "sv", "swatch", "swiss", "sx", "sy", "sydney", "systems", "sz", "tab", "taipei", "talk", "taobao", "target", "tatamotors", "tatar", "tattoo", "tax", "taxi", "tc", "tci", "td", "tdk", "team", "tech", "technology", "tel", "temasek", "tennis", "teva", "tf", "tg", "th", "thd", "theater", "theatre", "tiaa", "tickets", "tienda", "tips", "tires", "tirol", "tj", "tjmaxx", "tjx", "tk", "tkmaxx", "tl", "tm", "tmall", "tn", "to", "today", "tokyo", "tools", "top", "toray", "toshiba", "total", "tours", "town", "toyota", "toys", "tr", "trade", "trading", "training", "travel", "travelers", "travelersinsurance", "trust", "trv", "tt", "tube", "tui", "tunes", "tushu", "tv", "tvs", "tw", "tz", "ua", "ubank", "ubs", "ug", "uk", "unicom", "university", "uno", "uol", "ups", "us", "uy", "uz", "va", "vacations", "vana", "vanguard", "vc", "ve", "vegas", "ventures", "verisign", "versicherung", "vet", "vg", "vi", "viajes", "video", "vig", "viking", "villas", "vin", "vip", "virgin", "visa", "vision", "viva", "vivo", "vlaanderen", "vn", "vodka", "volvo", "vote", "voting", "voto", "voyage", "vu", "wales", "walmart", "walter", "wang", "wanggou", "watch", "watches", "weather", "weatherchannel", "webcam", "weber", "website", "wed", "wedding", "weibo", "weir", "wf", "whoswho", "wien", "wiki", "williamhill", "win", "windows", "wine", "winners", "wme", "woodside", "work", "works", "world", "wow", "ws", "wtc", "wtf", "xbox", "xerox", "xihuan", "xin", "xxx", "xyz", "yachts", "yahoo", "yamaxun", "yandex", "ye", "yodobashi", "yoga", "yokohama", "you", "youtube", "yt", "yun", "za", "zappos", "zara", "zero", "zip", "zm", "zone", "zuerich", "zw"];
|
|
5183
5394
|
function website(config) {
|
|
5184
5395
|
const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "website") });
|
|
5185
5396
|
rebulk.regexDefaults({ flags: "i" }).stringDefaults({ ignoreCase: true });
|
|
5186
5397
|
rebulk.defaults({ name: "website" });
|
|
5187
|
-
const tlds = config["tlds"] ||
|
|
5398
|
+
const tlds = config["tlds"] || TLDS;
|
|
5188
5399
|
const safeTlds = config["safe_tlds"] || ["com", "org", "net"];
|
|
5189
5400
|
const safeSubdomains = config["safe_subdomains"] || ["www"];
|
|
5190
5401
|
const safePrefix = config["safe_prefixes"] || [];
|
|
@@ -5207,10 +5418,10 @@ function website(config) {
|
|
|
5207
5418
|
tags: ["website.prefix"]
|
|
5208
5419
|
});
|
|
5209
5420
|
class PreferTitleOverWebsiteWithConfig extends Rule {
|
|
5210
|
-
constructor(
|
|
5421
|
+
constructor(safeSubdomainsArg, safePrefixArg) {
|
|
5211
5422
|
super();
|
|
5212
5423
|
this.consequence = RemoveMatch;
|
|
5213
|
-
this.
|
|
5424
|
+
this.safeSubdomains = safeSubdomainsArg;
|
|
5214
5425
|
this.safePrefix = safePrefixArg;
|
|
5215
5426
|
}
|
|
5216
5427
|
validFollowers(match) {
|
|
@@ -5220,7 +5431,7 @@ function website(config) {
|
|
|
5220
5431
|
const toRemove = [];
|
|
5221
5432
|
for (const websiteMatch of matches.named("website")) {
|
|
5222
5433
|
let safe = false;
|
|
5223
|
-
for (const safeStart of [...this.
|
|
5434
|
+
for (const safeStart of [...this.safeSubdomains, ...this.safePrefix]) {
|
|
5224
5435
|
if (String(websiteMatch.value ?? "").toLowerCase().startsWith(safeStart)) {
|
|
5225
5436
|
safe = true;
|
|
5226
5437
|
break;
|
|
@@ -5251,7 +5462,7 @@ function website(config) {
|
|
|
5251
5462
|
return toRemove;
|
|
5252
5463
|
}
|
|
5253
5464
|
}
|
|
5254
|
-
rebulk.rules(new PreferTitleOverWebsiteWithConfig(
|
|
5465
|
+
rebulk.rules(new PreferTitleOverWebsiteWithConfig(safeSubdomains, safePrefix), ValidateWebsitePrefix);
|
|
5255
5466
|
return rebulk;
|
|
5256
5467
|
}
|
|
5257
5468
|
const _ValidateWebsitePrefix = class _ValidateWebsitePrefix extends Rule {
|
|
@@ -5559,9 +5770,46 @@ function date(config) {
|
|
|
5559
5770
|
disabled: (context) => isDisabled(context, "date"),
|
|
5560
5771
|
conflictSolver: (match, other2) => other2.name === "episode" || other2.name === "season" || other2.name === "crc32" ? other2 : "__default__"
|
|
5561
5772
|
});
|
|
5562
|
-
rebulk.rules(KeepMarkedYearInFilepart, RemoveGroupedYearWithSxxExx);
|
|
5773
|
+
rebulk.rules(KeepMarkedYearInFilepart, RemoveGroupedYearWithSxxExx, new AbsorbWeekdayPrefix(config["weekday_words"] ?? []));
|
|
5563
5774
|
return rebulk;
|
|
5564
5775
|
}
|
|
5776
|
+
class AbsorbWeekdayPrefix extends Rule {
|
|
5777
|
+
constructor(weekdayWords) {
|
|
5778
|
+
super();
|
|
5779
|
+
this.consequence = RemoveMatch;
|
|
5780
|
+
const sepsClass = "[" + seps.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "]";
|
|
5781
|
+
this.weekdayRe = new RegExp(
|
|
5782
|
+
"(?:^|" + sepsClass + ")(" + buildOrPattern(weekdayWords.length ? weekdayWords : ["\\bnever\\b"]) + ")" + sepsClass + "*$",
|
|
5783
|
+
"i"
|
|
5784
|
+
);
|
|
5785
|
+
}
|
|
5786
|
+
enabled(context) {
|
|
5787
|
+
return !isDisabled(context, "date");
|
|
5788
|
+
}
|
|
5789
|
+
when(matches, _context) {
|
|
5790
|
+
const input = matches.inputString ?? "";
|
|
5791
|
+
const ret = [];
|
|
5792
|
+
for (const dateMatch of matches.named("date") ?? []) {
|
|
5793
|
+
const filepart = matches.markers.atMatch(dateMatch, (m) => m.name === "path", 0);
|
|
5794
|
+
const lower = filepart ? filepart.start : 0;
|
|
5795
|
+
const segment = input.slice(lower, dateMatch.start);
|
|
5796
|
+
const weekday = this.weekdayRe.exec(segment);
|
|
5797
|
+
if (!weekday) continue;
|
|
5798
|
+
const groupStart = lower + weekday.index + weekday[0].indexOf(weekday[1]);
|
|
5799
|
+
const claimed = matches.range(groupStart, dateMatch.start, (m) => !m.private);
|
|
5800
|
+
if ((Array.isArray(claimed) ? claimed.length : claimed ? 1 : 0) > 0) continue;
|
|
5801
|
+
ret.push([dateMatch, groupStart]);
|
|
5802
|
+
}
|
|
5803
|
+
return ret.length ? ret : false;
|
|
5804
|
+
}
|
|
5805
|
+
then(matches, whenResponse, _context) {
|
|
5806
|
+
for (const [dateMatch, newStart] of whenResponse) {
|
|
5807
|
+
matches.remove(dateMatch);
|
|
5808
|
+
dateMatch.start = newStart;
|
|
5809
|
+
matches.append(dateMatch);
|
|
5810
|
+
}
|
|
5811
|
+
}
|
|
5812
|
+
}
|
|
5565
5813
|
function markerComparatorPredicate(m) {
|
|
5566
5814
|
return !m.private && m.name !== "proper_count" && m.name !== "title" && !(m.name === "container" && m.tags?.includes("extension")) && !(m.name === "other" && m.value === "Rip");
|
|
5567
5815
|
}
|
|
@@ -5573,10 +5821,11 @@ function markerWeight(matches, marker, predicate) {
|
|
|
5573
5821
|
}
|
|
5574
5822
|
function markerSorted(markers, matches, predicate = markerComparatorPredicate) {
|
|
5575
5823
|
const markersArr = [...markers];
|
|
5824
|
+
const originalIndex = new Map(markersArr.map((m, i) => [m, i]));
|
|
5576
5825
|
return markersArr.sort((a, b) => {
|
|
5577
5826
|
const weightDiff = markerWeight(matches, b, predicate) - markerWeight(matches, a, predicate);
|
|
5578
5827
|
if (weightDiff !== 0) return weightDiff;
|
|
5579
|
-
return
|
|
5828
|
+
return (originalIndex.get(b) ?? 0) - (originalIndex.get(a) ?? 0);
|
|
5580
5829
|
});
|
|
5581
5830
|
}
|
|
5582
5831
|
function buildExpectedFunction(optionName) {
|
|
@@ -5789,7 +6038,7 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
|
|
|
5789
6038
|
* Check and extract titles from a filepart.
|
|
5790
6039
|
* Mirrors Python's TitleBaseRule.check_titles_in_filepart().
|
|
5791
6040
|
*/
|
|
5792
|
-
checkTitlesInFilepart(filepart, matches) {
|
|
6041
|
+
checkTitlesInFilepart(filepart, matches, context) {
|
|
5793
6042
|
const toAppend = [];
|
|
5794
6043
|
const toRemove = [];
|
|
5795
6044
|
const firstYearInFilepart = matches.range(
|
|
@@ -5860,6 +6109,16 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
|
|
|
5860
6109
|
(m) => this.isIgnored(m)
|
|
5861
6110
|
);
|
|
5862
6111
|
const ignoredArray = Array.isArray(ignoredInHole) ? ignoredInHole : ignoredInHole ? [ignoredInHole] : [];
|
|
6112
|
+
if (ignoredArray.length > 0 && ignoredArray.every((m) => m.name === "language" || m.name === "country")) {
|
|
6113
|
+
const inpFull = matches.inputString ?? "";
|
|
6114
|
+
let rest = inpFull.slice(hole.start, hole.end);
|
|
6115
|
+
for (const m of ignoredArray) {
|
|
6116
|
+
const rel = m.start - hole.start;
|
|
6117
|
+
rest = rest.slice(0, rel) + " ".repeat(m.end - m.start) + rest.slice(m.end - hole.start);
|
|
6118
|
+
}
|
|
6119
|
+
const hasTitleText = [...rest].some((c) => !seps.includes(c) && c !== " ");
|
|
6120
|
+
if (!hasTitleText) continue;
|
|
6121
|
+
}
|
|
5863
6122
|
let trimmedHole = hole;
|
|
5864
6123
|
const inp = matches.inputString ?? "";
|
|
5865
6124
|
while (trimmedHole.start < trimmedHole.end && seps.includes(inp[trimmedHole.start])) {
|
|
@@ -5965,7 +6224,7 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
|
|
|
5965
6224
|
console.log(` result: hole=[${trimmedHole.start},${trimmedHole.end}) length=${trimmedHole.length} value="${trimmedHole.value}"`);
|
|
5966
6225
|
}
|
|
5967
6226
|
if (trimmedHole.length > 0 && !this.shouldRemove(trimmedHole) && trimmedHole.value) {
|
|
5968
|
-
const splitResult = this.splitTitleAlternative(trimmedHole, inp);
|
|
6227
|
+
const splitResult = this.alternativePropertyName && !isDisabled(context, this.alternativePropertyName) ? this.splitTitleAlternative(trimmedHole, inp) : null;
|
|
5969
6228
|
if (splitResult) {
|
|
5970
6229
|
splitResult.title.name = this.matchName;
|
|
5971
6230
|
toAppend.push(splitResult.title);
|
|
@@ -6091,7 +6350,7 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
|
|
|
6091
6350
|
for (const filepart of sortedFileparts) {
|
|
6092
6351
|
yearFileparts.delete(filepart);
|
|
6093
6352
|
if (!this.filepartFilter(filepart)) continue;
|
|
6094
|
-
const result = this.checkTitlesInFilepart(filepart, matches);
|
|
6353
|
+
const result = this.checkTitlesInFilepart(filepart, matches, context);
|
|
6095
6354
|
if (result.toAppend.length > 0 || result.toRemove.length > 0) {
|
|
6096
6355
|
if (serieNameMatch) {
|
|
6097
6356
|
const normTitle = (s) => foldDiacritics(s).replace(/[''`]/g, "").replace(/\.+$/, "").toLowerCase().trim();
|
|
@@ -6108,7 +6367,7 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
|
|
|
6108
6367
|
}
|
|
6109
6368
|
for (const filepart of yearFileparts) {
|
|
6110
6369
|
if (!this.filepartFilter(filepart)) continue;
|
|
6111
|
-
const result = this.checkTitlesInFilepart(filepart, matches);
|
|
6370
|
+
const result = this.checkTitlesInFilepart(filepart, matches, context);
|
|
6112
6371
|
const filteredAppend = [];
|
|
6113
6372
|
for (const newTitle of result.toAppend) {
|
|
6114
6373
|
if (newTitle.name !== this.matchName) {
|
|
@@ -6242,7 +6501,11 @@ const _ExtendLoneArticleTitle = class _ExtendLoneArticleTitle extends Rule {
|
|
|
6242
6501
|
const inp = matches.inputString || "";
|
|
6243
6502
|
const out = [];
|
|
6244
6503
|
const titles = matches.named("title");
|
|
6245
|
-
const
|
|
6504
|
+
const epTitles = matches.named("episode_title");
|
|
6505
|
+
const titleArr = [
|
|
6506
|
+
...Array.isArray(titles) ? titles : titles ? [titles] : [],
|
|
6507
|
+
...Array.isArray(epTitles) ? epTitles : epTitles ? [epTitles] : []
|
|
6508
|
+
];
|
|
6246
6509
|
for (const title2 of titleArr) {
|
|
6247
6510
|
if (!ARTICLES.has(String(title2.value ?? "").trim().toLowerCase())) continue;
|
|
6248
6511
|
const filepart = matches.markers.atMatch(title2, (m) => m.name === "path", 0);
|
|
@@ -6298,11 +6561,18 @@ const _CountryAtTitlePosition = class _CountryAtTitlePosition extends Rule {
|
|
|
6298
6561
|
const filepart = matches.markers.atMatch(c, (m) => m.name === "path", 0);
|
|
6299
6562
|
if (!filepart) continue;
|
|
6300
6563
|
if (![...inp.slice(filepart.start, c.start)].every((ch) => seps.includes(ch))) continue;
|
|
6301
|
-
|
|
6302
|
-
if (
|
|
6303
|
-
const
|
|
6304
|
-
|
|
6305
|
-
|
|
6564
|
+
if (["release-group-prefix", "streaming_service.prefix", "streaming_service.suffix"].some((t) => c.tags?.includes(t))) continue;
|
|
6565
|
+
if (matches.markers.atMatch(c, (m) => m.name === "group", 0)) continue;
|
|
6566
|
+
const anchor = matches.range(
|
|
6567
|
+
c.end,
|
|
6568
|
+
filepart.end,
|
|
6569
|
+
(m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
|
|
6570
|
+
0
|
|
6571
|
+
);
|
|
6572
|
+
if (!anchor) continue;
|
|
6573
|
+
if (![...inp.slice(c.end, anchor.start)].every((ch) => seps.includes(ch))) {
|
|
6574
|
+
if (matches.range(c.end, anchor.start, (m) => !m.private && m.value != null, 0)) continue;
|
|
6575
|
+
}
|
|
6306
6576
|
out.push(c);
|
|
6307
6577
|
}
|
|
6308
6578
|
return out.length ? out : false;
|
|
@@ -6310,6 +6580,76 @@ const _CountryAtTitlePosition = class _CountryAtTitlePosition extends Rule {
|
|
|
6310
6580
|
};
|
|
6311
6581
|
_CountryAtTitlePosition.priority = 64;
|
|
6312
6582
|
let CountryAtTitlePosition = _CountryAtTitlePosition;
|
|
6583
|
+
const _TitleWordAtTitlePosition = class _TitleWordAtTitlePosition extends Rule {
|
|
6584
|
+
constructor() {
|
|
6585
|
+
super(...arguments);
|
|
6586
|
+
this.priority = 64;
|
|
6587
|
+
this.consequence = RemoveMatch;
|
|
6588
|
+
}
|
|
6589
|
+
when(matches, _context) {
|
|
6590
|
+
const toRemove = [];
|
|
6591
|
+
const tagged = matches.tagged("title-word") ?? [];
|
|
6592
|
+
for (const candidate of Array.isArray(tagged) ? tagged : [tagged]) {
|
|
6593
|
+
if (!candidate || candidate.private) continue;
|
|
6594
|
+
const filepart = matches.markers.atMatch(candidate, (m) => m.name === "path", 0);
|
|
6595
|
+
if (!filepart) continue;
|
|
6596
|
+
const anchor = matches.range(
|
|
6597
|
+
filepart.start,
|
|
6598
|
+
filepart.end,
|
|
6599
|
+
(m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
|
|
6600
|
+
0
|
|
6601
|
+
);
|
|
6602
|
+
if (!anchor || candidate.start >= anchor.start) continue;
|
|
6603
|
+
toRemove.push(candidate);
|
|
6604
|
+
}
|
|
6605
|
+
return toRemove.length ? toRemove : false;
|
|
6606
|
+
}
|
|
6607
|
+
};
|
|
6608
|
+
_TitleWordAtTitlePosition.priority = 64;
|
|
6609
|
+
let TitleWordAtTitlePosition = _TitleWordAtTitlePosition;
|
|
6610
|
+
const NON_LATIN_SCRIPT_RE = /[\u0370-\u03FF\u0400-\u04FF\u0590-\u05FF\u0600-\u06FF\u0E00-\u0E7F\u3000-\u303F\u3040-\u30FF\u3400-\u4DBF\u4E00-\u9FFF\uAC00-\uD7AF\uFF00-\uFFEF]/;
|
|
6611
|
+
const _SplitOriginalScriptTitle = class _SplitOriginalScriptTitle extends Rule {
|
|
6612
|
+
constructor() {
|
|
6613
|
+
super(...arguments);
|
|
6614
|
+
this.priority = POST_PROCESS;
|
|
6615
|
+
this.consequence = [RemoveMatch, AppendMatch];
|
|
6616
|
+
}
|
|
6617
|
+
when(matches, context) {
|
|
6618
|
+
if (isDisabled(context, "alternative_title")) return false;
|
|
6619
|
+
const input = matches.inputString ?? "";
|
|
6620
|
+
const toRemove = [];
|
|
6621
|
+
const toAppend = [];
|
|
6622
|
+
for (const titleMatch of matches.named("title")) {
|
|
6623
|
+
if (titleMatch.tags?.includes("expected")) continue;
|
|
6624
|
+
const raw = input.slice(titleMatch.start, titleMatch.end);
|
|
6625
|
+
const latin = new RegExp("(?:^|[" + sepsPattern + "])([A-Za-z])").exec(raw);
|
|
6626
|
+
if (!latin) continue;
|
|
6627
|
+
const latinOffset = latin.index + latin[0].indexOf(latin[1]);
|
|
6628
|
+
const prefix = raw.slice(0, latinOffset);
|
|
6629
|
+
if (!NON_LATIN_SCRIPT_RE.test(prefix)) continue;
|
|
6630
|
+
let prefixTrim = prefix;
|
|
6631
|
+
while (prefixTrim.length && seps.includes(prefixTrim[prefixTrim.length - 1])) prefixTrim = prefixTrim.slice(0, -1);
|
|
6632
|
+
const prefixEnd = titleMatch.start + prefixTrim.length;
|
|
6633
|
+
const latinStart = titleMatch.start + latinOffset;
|
|
6634
|
+
if (prefixEnd <= titleMatch.start) continue;
|
|
6635
|
+
toRemove.push(titleMatch);
|
|
6636
|
+
toAppend.push(new Match(titleMatch.start, prefixEnd, {
|
|
6637
|
+
name: "alternative_title",
|
|
6638
|
+
value: cleanup(input.slice(titleMatch.start, prefixEnd)),
|
|
6639
|
+
inputString: input
|
|
6640
|
+
}));
|
|
6641
|
+
toAppend.push(new Match(latinStart, titleMatch.end, {
|
|
6642
|
+
name: "title",
|
|
6643
|
+
tags: ["title"],
|
|
6644
|
+
value: cleanup(input.slice(latinStart, titleMatch.end)),
|
|
6645
|
+
inputString: input
|
|
6646
|
+
}));
|
|
6647
|
+
}
|
|
6648
|
+
return toRemove.length || toAppend.length ? [toRemove, toAppend] : false;
|
|
6649
|
+
}
|
|
6650
|
+
};
|
|
6651
|
+
_SplitOriginalScriptTitle.priority = POST_PROCESS;
|
|
6652
|
+
let SplitOriginalScriptTitle = _SplitOriginalScriptTitle;
|
|
6313
6653
|
const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle extends Rule {
|
|
6314
6654
|
constructor() {
|
|
6315
6655
|
super(...arguments);
|
|
@@ -6330,6 +6670,7 @@ const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle ex
|
|
|
6330
6670
|
const lead = matches.range(filepart.start, filepart.end, (m) => !m.private && !!m.value, 0);
|
|
6331
6671
|
if (!lead || !["other", "country", "edition"].includes(lead.name ?? "")) continue;
|
|
6332
6672
|
if (lead.start >= anchor.start) continue;
|
|
6673
|
+
if ((lead.raw ?? "") === String(lead.value ?? "")) continue;
|
|
6333
6674
|
if (![...inp.slice(filepart.start, lead.start)].every((c) => seps.includes(c))) continue;
|
|
6334
6675
|
out.push(lead);
|
|
6335
6676
|
}
|
|
@@ -6456,7 +6797,7 @@ function title(config) {
|
|
|
6456
6797
|
const rebulk = new Rebulk({
|
|
6457
6798
|
disabled: (context) => isDisabled(context, "title")
|
|
6458
6799
|
});
|
|
6459
|
-
rebulk.rules(CountryAtTitlePosition, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle);
|
|
6800
|
+
rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle);
|
|
6460
6801
|
const expectedTitle = buildExpectedFunction("expected_title");
|
|
6461
6802
|
rebulk.functional(expectedTitle, {
|
|
6462
6803
|
name: "title",
|
|
@@ -7246,7 +7587,9 @@ class Filepart2EpisodeTitle extends Rule {
|
|
|
7246
7587
|
);
|
|
7247
7588
|
if (episodeNumber) {
|
|
7248
7589
|
const season = matches.range(directory.start, directory.end, (m) => m.name === "season", 0) || matches.range(filename.start, filename.end, (m) => m.name === "season", 0);
|
|
7249
|
-
|
|
7590
|
+
const anySeason = matches.named("season");
|
|
7591
|
+
const hasAnySeason = Array.isArray(anySeason) ? anySeason.length > 0 : !!anySeason;
|
|
7592
|
+
if (season || !hasAnySeason) {
|
|
7250
7593
|
const hole = parentTitleHole(matches, directory.start, directory.end);
|
|
7251
7594
|
if (hole) {
|
|
7252
7595
|
const groupMarkers = matches.markers.named("group");
|
|
@@ -8445,14 +8788,6 @@ class DashSeparatedReleaseGroup extends Rule {
|
|
|
8445
8788
|
if (matches.range(candidate.start, candidate.end, (m) => m.name === "episode", 0)) {
|
|
8446
8789
|
return false;
|
|
8447
8790
|
}
|
|
8448
|
-
if (candidate.start === start && matches.range(
|
|
8449
|
-
candidate.end,
|
|
8450
|
-
end,
|
|
8451
|
-
(m) => ["season", "episode", "date"].includes(m.name ?? "") && !m.private,
|
|
8452
|
-
0
|
|
8453
|
-
)) {
|
|
8454
|
-
return false;
|
|
8455
|
-
}
|
|
8456
8791
|
const firstHole = matches.holes(
|
|
8457
8792
|
candidate.end,
|
|
8458
8793
|
end,
|
|
@@ -8461,6 +8796,16 @@ class DashSeparatedReleaseGroup extends Rule {
|
|
|
8461
8796
|
if (!firstHole) {
|
|
8462
8797
|
return false;
|
|
8463
8798
|
}
|
|
8799
|
+
const holeRaw = String(firstHole.raw ?? "");
|
|
8800
|
+
const holeCore = holeRaw.replace(new RegExp("^[" + sepsPattern + "]+|[" + sepsPattern + "]+$", "g"), "");
|
|
8801
|
+
if (candidate.start === start && !holeCore.includes(".") && !holeCore.includes(" ") && matches.range(
|
|
8802
|
+
candidate.end,
|
|
8803
|
+
end,
|
|
8804
|
+
(m) => ["season", "episode", "date"].includes(m.name ?? "") && !m.private,
|
|
8805
|
+
0
|
|
8806
|
+
)) {
|
|
8807
|
+
return false;
|
|
8808
|
+
}
|
|
8464
8809
|
const rawValue = firstHole.raw;
|
|
8465
8810
|
return rawValue[0] === "-" && !rawValue.slice(1).includes("-") && rawValue.includes(".") && !rawValue.includes(" ");
|
|
8466
8811
|
}
|
|
@@ -8629,6 +8974,32 @@ const _SceneReleaseGroup = class _SceneReleaseGroup extends Rule {
|
|
|
8629
8974
|
}
|
|
8630
8975
|
);
|
|
8631
8976
|
if (lastHole) {
|
|
8977
|
+
const holeGroup = matches.markers.atMatch(lastHole, (m) => m.name === "group", 0);
|
|
8978
|
+
if (holeGroup && String(holeGroup.raw ?? "").startsWith("(")) {
|
|
8979
|
+
const hasEpisodeish = (matches.range(
|
|
8980
|
+
start,
|
|
8981
|
+
end,
|
|
8982
|
+
(m) => m.name === "episode" || m.name === "season"
|
|
8983
|
+
) ?? []).length > 0;
|
|
8984
|
+
if (hasEpisodeish) {
|
|
8985
|
+
const firstGroup = matches.markers.range(
|
|
8986
|
+
start,
|
|
8987
|
+
end,
|
|
8988
|
+
(m) => m.name === "group" && m.start === start,
|
|
8989
|
+
0
|
|
8990
|
+
);
|
|
8991
|
+
if (firstGroup) {
|
|
8992
|
+
const inner = matches.range(
|
|
8993
|
+
firstGroup.start,
|
|
8994
|
+
firstGroup.end,
|
|
8995
|
+
(mm) => !mm.tags.includes("weak-language")
|
|
8996
|
+
) ?? [];
|
|
8997
|
+
const core = String(firstGroup.value ?? "").replace(new RegExp(`[${sepsPattern}]`, "g"), "");
|
|
8998
|
+
const emptyish = inner.length === 0 || inner.every((mm) => mm.name === "container" && mm.tags?.includes("subtitle"));
|
|
8999
|
+
if (emptyish && core && !intCoercable(core)) continue;
|
|
9000
|
+
}
|
|
9001
|
+
}
|
|
9002
|
+
}
|
|
8632
9003
|
const previousMatchFilter = (match) => {
|
|
8633
9004
|
if (match.start < filepart.start) {
|
|
8634
9005
|
return false;
|
|
@@ -8692,7 +9063,6 @@ const _AnimeReleaseGroup = class _AnimeReleaseGroup extends Rule {
|
|
|
8692
9063
|
(mm) => !mm.tags.includes("weak-language")
|
|
8693
9064
|
);
|
|
8694
9065
|
if (innerMatches.length === 0) return true;
|
|
8695
|
-
if (innerMatches.every((mm) => mm.name === "other")) return true;
|
|
8696
9066
|
if (m.start === filepart.start && innerMatches.every((mm) => mm.name === "container" && mm.tags?.includes("subtitle"))) {
|
|
8697
9067
|
return true;
|
|
8698
9068
|
}
|
|
@@ -8861,7 +9231,11 @@ function other(config) {
|
|
|
8861
9231
|
rebulk.regexDefaults({ flags: "i", abbreviations: [dash] }).stringDefaults({ ignoreCase: true });
|
|
8862
9232
|
rebulk.defaults({ name: "other", validator: sepsSurround });
|
|
8863
9233
|
loadConfigPatterns(rebulk, config["other"]);
|
|
9234
|
+
openingEndingCredits(rebulk);
|
|
8864
9235
|
rebulk.rules(
|
|
9236
|
+
AppendCreditless,
|
|
9237
|
+
AppendOpedEndingCredits,
|
|
9238
|
+
ValidateStereoVRContext,
|
|
8865
9239
|
RenameAnotherToOther,
|
|
8866
9240
|
ValidateHasNeighbor,
|
|
8867
9241
|
ValidateHasNeighborAfter,
|
|
@@ -8926,9 +9300,132 @@ const _ImageArtKeywordToOther = class _ImageArtKeywordToOther extends Rule {
|
|
|
8926
9300
|
};
|
|
8927
9301
|
_ImageArtKeywordToOther.priority = POST_PROCESS;
|
|
8928
9302
|
let ImageArtKeywordToOther = _ImageArtKeywordToOther;
|
|
8929
|
-
|
|
8930
|
-
|
|
8931
|
-
|
|
9303
|
+
const CREDITS_NUMBER = `(?P<credits_number>\\d+(?:(?![vV]\\d)[^\\W\\d_])?)?`;
|
|
9304
|
+
const CREDITS_VERSION = `(?:-?[vV](?P<version>\\d+))?`;
|
|
9305
|
+
const CREDITS_SUFFIX = CREDITS_NUMBER + CREDITS_VERSION;
|
|
9306
|
+
function formatCreditsNumber(value) {
|
|
9307
|
+
const m = /^(\d+)(\w?)$/.exec(value);
|
|
9308
|
+
if (!m) return value;
|
|
9309
|
+
return String(parseInt(m[1], 10)) + m[2].toLowerCase();
|
|
9310
|
+
}
|
|
9311
|
+
function openingEndingCredits(rebulk) {
|
|
9312
|
+
const add = (pattern, value, ignoreCase) => {
|
|
9313
|
+
rebulk.regex(
|
|
9314
|
+
`(?P<other>` + pattern + `)` + CREDITS_SUFFIX,
|
|
9315
|
+
{
|
|
9316
|
+
flags: ignoreCase ? "i" : "",
|
|
9317
|
+
name: "other",
|
|
9318
|
+
children: true,
|
|
9319
|
+
privateParent: true,
|
|
9320
|
+
validateAll: true,
|
|
9321
|
+
validator: { __parent__: sepsSurround },
|
|
9322
|
+
formatter: {
|
|
9323
|
+
other: () => value,
|
|
9324
|
+
credits_number: formatCreditsNumber,
|
|
9325
|
+
version: (v) => parseInt(v, 10)
|
|
9326
|
+
},
|
|
9327
|
+
disabled: (context) => isDisabled(context, "other")
|
|
9328
|
+
}
|
|
9329
|
+
);
|
|
9330
|
+
};
|
|
9331
|
+
add(`NC-?OP|creditless-?op(?:ening)?`, "Opening Credits", true);
|
|
9332
|
+
add(`NC-?ED|creditless-?(?:ed|ending)`, "Ending Credits", true);
|
|
9333
|
+
add(`OPED|OP`, "Opening Credits", false);
|
|
9334
|
+
add(`ED`, "Ending Credits", false);
|
|
9335
|
+
}
|
|
9336
|
+
const _AppendCreditless = class _AppendCreditless extends Rule {
|
|
9337
|
+
constructor() {
|
|
9338
|
+
super(...arguments);
|
|
9339
|
+
this.priority = POST_PROCESS;
|
|
9340
|
+
this.consequence = AppendMatch;
|
|
9341
|
+
}
|
|
9342
|
+
when(matches, _context) {
|
|
9343
|
+
const toAppend = [];
|
|
9344
|
+
for (const match of matches.named("other", (m) => m.value === "Opening Credits" || m.value === "Ending Credits") ?? []) {
|
|
9345
|
+
const raw = (match.raw ?? "").toLowerCase().replace(/[\s._-]+/g, "");
|
|
9346
|
+
if (raw.startsWith("nc") || raw.includes("creditless")) {
|
|
9347
|
+
toAppend.push(new Match(match.start, match.end, {
|
|
9348
|
+
name: "other",
|
|
9349
|
+
value: "Creditless",
|
|
9350
|
+
inputString: matches.inputString
|
|
9351
|
+
}));
|
|
9352
|
+
}
|
|
9353
|
+
}
|
|
9354
|
+
return toAppend.length ? toAppend : false;
|
|
9355
|
+
}
|
|
9356
|
+
};
|
|
9357
|
+
_AppendCreditless.priority = POST_PROCESS;
|
|
9358
|
+
_AppendCreditless.properties = { other: ["Creditless"] };
|
|
9359
|
+
let AppendCreditless = _AppendCreditless;
|
|
9360
|
+
const _AppendOpedEndingCredits = class _AppendOpedEndingCredits extends Rule {
|
|
9361
|
+
constructor() {
|
|
9362
|
+
super(...arguments);
|
|
9363
|
+
this.priority = POST_PROCESS;
|
|
9364
|
+
this.consequence = AppendMatch;
|
|
9365
|
+
}
|
|
9366
|
+
when(matches, _context) {
|
|
9367
|
+
const toAppend = [];
|
|
9368
|
+
for (const match of matches.named("other", (m) => m.value === "Opening Credits") ?? []) {
|
|
9369
|
+
if ((match.raw ?? "").toLowerCase().replace(/[\s._-]+/g, "") === "oped") {
|
|
9370
|
+
toAppend.push(new Match(match.start, match.end, {
|
|
9371
|
+
name: "other",
|
|
9372
|
+
value: "Ending Credits",
|
|
9373
|
+
inputString: matches.inputString
|
|
9374
|
+
}));
|
|
9375
|
+
}
|
|
9376
|
+
}
|
|
9377
|
+
return toAppend.length ? toAppend : false;
|
|
9378
|
+
}
|
|
9379
|
+
};
|
|
9380
|
+
_AppendOpedEndingCredits.priority = POST_PROCESS;
|
|
9381
|
+
_AppendOpedEndingCredits.properties = { other: ["Ending Credits"] };
|
|
9382
|
+
let AppendOpedEndingCredits = _AppendOpedEndingCredits;
|
|
9383
|
+
const STEREO_VR_CONTEXT_TAG = "stereo-vr-context";
|
|
9384
|
+
const VR_CONTEXT_VALUES = /* @__PURE__ */ new Set(["Virtual Reality", "3D"]);
|
|
9385
|
+
const _ValidateStereoVRContext = class _ValidateStereoVRContext extends Rule {
|
|
9386
|
+
constructor() {
|
|
9387
|
+
super(...arguments);
|
|
9388
|
+
this.priority = 64;
|
|
9389
|
+
this.consequence = RemoveMatch;
|
|
9390
|
+
}
|
|
9391
|
+
when(matches, _context) {
|
|
9392
|
+
const toRemove = [];
|
|
9393
|
+
const fileparts = matches.markers.named("path");
|
|
9394
|
+
for (const filepart of Array.isArray(fileparts) ? fileparts : fileparts ? [fileparts] : []) {
|
|
9395
|
+
const gated = matches.range(
|
|
9396
|
+
filepart.start,
|
|
9397
|
+
filepart.end,
|
|
9398
|
+
(m) => m.name === "other" && m.tags.includes(STEREO_VR_CONTEXT_TAG)
|
|
9399
|
+
);
|
|
9400
|
+
if (!gated?.length) continue;
|
|
9401
|
+
const hasVrContext = matches.range(
|
|
9402
|
+
filepart.start,
|
|
9403
|
+
filepart.end,
|
|
9404
|
+
(m) => m.name === "other" && VR_CONTEXT_VALUES.has(String(m.value))
|
|
9405
|
+
)?.length > 0;
|
|
9406
|
+
if (hasVrContext) {
|
|
9407
|
+
for (const stereo of gated) {
|
|
9408
|
+
toRemove.push(...matches.range(
|
|
9409
|
+
stereo.start,
|
|
9410
|
+
stereo.end,
|
|
9411
|
+
(m) => m.name === "streaming_service"
|
|
9412
|
+
) ?? []);
|
|
9413
|
+
}
|
|
9414
|
+
} else {
|
|
9415
|
+
toRemove.push(...gated);
|
|
9416
|
+
}
|
|
9417
|
+
}
|
|
9418
|
+
return toRemove.length ? toRemove : false;
|
|
9419
|
+
}
|
|
9420
|
+
};
|
|
9421
|
+
_ValidateStereoVRContext.priority = 64;
|
|
9422
|
+
let ValidateStereoVRContext = _ValidateStereoVRContext;
|
|
9423
|
+
const TOKEN_START = `(?<![^\\W_])`;
|
|
9424
|
+
function completeWords(rebulk, opts) {
|
|
9425
|
+
const completeMarkerPattern = buildOrPattern(opts.completeMarkerWords);
|
|
9426
|
+
const seasonWordsPattern = buildOrPattern(opts.seasonWords);
|
|
9427
|
+
const completeArticleWordsPattern = buildOrPattern(opts.completeArticleWords);
|
|
9428
|
+
const seasonNumbersPattern = `(?:-+(?:\\d+|` + buildOrPattern(opts.seasonNumberSeparators, void 0, true) + `))+-+`;
|
|
8932
9429
|
function validateComplete(match) {
|
|
8933
9430
|
const children = match.children;
|
|
8934
9431
|
if (!children.named("completeWordsBefore") && !children.named("completeWordsAfter")) {
|
|
@@ -8937,7 +9434,7 @@ function completeWords(rebulk, seasonWords, completeArticleWords) {
|
|
|
8937
9434
|
return true;
|
|
8938
9435
|
}
|
|
8939
9436
|
rebulk.regex(
|
|
8940
|
-
`(?P<completeArticle>${completeArticleWordsPattern}-)?(?P<completeWordsBefore>${seasonWordsPattern}-)
|
|
9437
|
+
TOKEN_START + `(?P<completeArticle>${completeArticleWordsPattern}-)?(?P<completeWordsBefore>${seasonWordsPattern}-)?` + completeMarkerPattern + `(?P<completeWordsAfter>-${seasonWordsPattern})?`,
|
|
8941
9438
|
{
|
|
8942
9439
|
privateNames: ["completeArticle", "completeWordsBefore", "completeWordsAfter"],
|
|
8943
9440
|
value: { other: "Complete" },
|
|
@@ -8947,6 +9444,26 @@ function completeWords(rebulk, seasonWords, completeArticleWords) {
|
|
|
8947
9444
|
}
|
|
8948
9445
|
}
|
|
8949
9446
|
);
|
|
9447
|
+
rebulk.regex(
|
|
9448
|
+
seasonWordsPattern + seasonNumbersPattern + `(?P<other>` + completeMarkerPattern + `)`,
|
|
9449
|
+
{
|
|
9450
|
+
children: true,
|
|
9451
|
+
privateParent: true,
|
|
9452
|
+
validateAll: true,
|
|
9453
|
+
value: { other: "Complete" },
|
|
9454
|
+
tags: ["release-group-prefix"],
|
|
9455
|
+
validator: { __parent__: sepsSurround }
|
|
9456
|
+
}
|
|
9457
|
+
);
|
|
9458
|
+
rebulk.regex(
|
|
9459
|
+
TOKEN_START + `(?P<completePrefix>` + buildOrPattern(opts.completePrefixWords) + `-?)` + completeMarkerPattern,
|
|
9460
|
+
{
|
|
9461
|
+
privateNames: ["completePrefix"],
|
|
9462
|
+
value: { other: "Complete" },
|
|
9463
|
+
tags: ["release-group-prefix"],
|
|
9464
|
+
validator: { __parent__: sepsSurround }
|
|
9465
|
+
}
|
|
9466
|
+
);
|
|
8950
9467
|
}
|
|
8951
9468
|
const _ProperCountRule = class _ProperCountRule extends Rule {
|
|
8952
9469
|
when(matches, context) {
|
|
@@ -9240,10 +9757,20 @@ const _RemoveTitleCaseAmbiguous = class _RemoveTitleCaseAmbiguous extends Rule {
|
|
|
9240
9757
|
// lowercase scene spellings are unaffected; only the Title-Case word is removed.
|
|
9241
9758
|
when(matches) {
|
|
9242
9759
|
const TITLE_WORDS = /* @__PURE__ */ new Set(["Real", "Cam", "Convert"]);
|
|
9760
|
+
const RELEASE_META = /* @__PURE__ */ new Set(["screen_size", "video_codec", "audio_codec", "video_profile", "release_group"]);
|
|
9243
9761
|
const ret = [];
|
|
9244
9762
|
for (const m of matches.range(0, matches.inputString?.length ?? 0)) {
|
|
9245
9763
|
if (m.name !== "other" && m.name !== "source") continue;
|
|
9246
|
-
if (TITLE_WORDS.has(m.raw ?? ""))
|
|
9764
|
+
if (!TITLE_WORDS.has(m.raw ?? "")) continue;
|
|
9765
|
+
const filepart = matches.markers.atMatch(m, (marker) => marker.name === "path", 0);
|
|
9766
|
+
const searchEnd = filepart?.end ?? (matches.inputString?.length ?? m.end);
|
|
9767
|
+
const metaAfter = matches.range(
|
|
9768
|
+
m.end,
|
|
9769
|
+
searchEnd,
|
|
9770
|
+
(o) => !o.private && RELEASE_META.has(o.name ?? "")
|
|
9771
|
+
) ?? [];
|
|
9772
|
+
if (metaAfter.length > 0) continue;
|
|
9773
|
+
ret.push(m);
|
|
9247
9774
|
}
|
|
9248
9775
|
return ret.length ? ret : false;
|
|
9249
9776
|
}
|
|
@@ -9578,9 +10105,35 @@ function film(config) {
|
|
|
9578
10105
|
rebulk.regexDefaults({ flags: "i", abbreviations: [dash] }).stringDefaults({ ignoreCase: true });
|
|
9579
10106
|
rebulk.defaults({ name: "film", validator: sepsSurround });
|
|
9580
10107
|
loadConfigPatterns(rebulk, config["film"]);
|
|
9581
|
-
rebulk.rules(FilmTitleRule);
|
|
10108
|
+
rebulk.rules(LeadingFilmNumberRule, FilmTitleRule);
|
|
9582
10109
|
return rebulk;
|
|
9583
10110
|
}
|
|
10111
|
+
const _LeadingFilmNumberRule = class _LeadingFilmNumberRule extends Rule {
|
|
10112
|
+
constructor() {
|
|
10113
|
+
super(...arguments);
|
|
10114
|
+
this.consequence = RemoveMatch;
|
|
10115
|
+
}
|
|
10116
|
+
when(matches, _context) {
|
|
10117
|
+
const toRemove = [];
|
|
10118
|
+
const films = matches.named("film", (m) => !m.private) ?? [];
|
|
10119
|
+
for (const filmMatch of Array.isArray(films) ? films : [films]) {
|
|
10120
|
+
const filepath = matches.markers.atMatch(filmMatch, (m) => m.name === "path", 0);
|
|
10121
|
+
if (!filepath) continue;
|
|
10122
|
+
const hole = matches.holes(
|
|
10123
|
+
filepath.start,
|
|
10124
|
+
filmMatch.start + 1,
|
|
10125
|
+
{ formatter: cleanup, index: 0 }
|
|
10126
|
+
);
|
|
10127
|
+
if (!(hole && hole.value)) {
|
|
10128
|
+
toRemove.push(filmMatch);
|
|
10129
|
+
if (filmMatch.parent) toRemove.push(filmMatch.parent);
|
|
10130
|
+
}
|
|
10131
|
+
}
|
|
10132
|
+
return toRemove.length ? toRemove : false;
|
|
10133
|
+
}
|
|
10134
|
+
};
|
|
10135
|
+
_LeadingFilmNumberRule.consequence = RemoveMatch;
|
|
10136
|
+
let LeadingFilmNumberRule = _LeadingFilmNumberRule;
|
|
9584
10137
|
const _FilmTitleRule = class _FilmTitleRule extends Rule {
|
|
9585
10138
|
enabled(context) {
|
|
9586
10139
|
return !isDisabled(context, "film_title");
|
|
@@ -9906,6 +10459,13 @@ const _TypeProcessor = class _TypeProcessor extends Rule {
|
|
|
9906
10459
|
return "episode";
|
|
9907
10460
|
}
|
|
9908
10461
|
}
|
|
10462
|
+
const completeSeries = matches.named(
|
|
10463
|
+
"other",
|
|
10464
|
+
(m) => m.value === "Complete" && !!(m.children?.named?.("completeWordsBefore")?.length || m.children?.named?.("completeWordsAfter")?.length)
|
|
10465
|
+
);
|
|
10466
|
+
if (completeSeries && (Array.isArray(completeSeries) ? completeSeries.length > 0 : true)) {
|
|
10467
|
+
return "episode";
|
|
10468
|
+
}
|
|
9909
10469
|
const film2 = matches.named("film");
|
|
9910
10470
|
if (film2 && (Array.isArray(film2) ? film2.length > 0 : true)) {
|
|
9911
10471
|
return "movie";
|
|
@@ -9930,6 +10490,10 @@ const _TypeProcessor = class _TypeProcessor extends Rule {
|
|
|
9930
10490
|
if (crc32 && (Array.isArray(crc32) ? crc32.length > 0 : true) && animeReleaseGroup && (Array.isArray(animeReleaseGroup) ? animeReleaseGroup.length > 0 : true)) {
|
|
9931
10491
|
return "episode";
|
|
9932
10492
|
}
|
|
10493
|
+
const complete = matches.named("other", (m) => m.value === "Complete");
|
|
10494
|
+
if (complete && (Array.isArray(complete) ? complete.length > 0 : true) && (!year || (Array.isArray(year) ? year.length === 0 : false))) {
|
|
10495
|
+
return "episode";
|
|
10496
|
+
}
|
|
9933
10497
|
return "movie";
|
|
9934
10498
|
}
|
|
9935
10499
|
then(matches, whenResponse, _context) {
|
|
@@ -10134,17 +10698,40 @@ const _RemoveAmbiguous = class _RemoveAmbiguous extends Rule {
|
|
|
10134
10698
|
_RemoveAmbiguous.priority = POST_PROCESS;
|
|
10135
10699
|
_RemoveAmbiguous.consequence = RemoveMatch;
|
|
10136
10700
|
let RemoveAmbiguous = _RemoveAmbiguous;
|
|
10701
|
+
const sxxExxWeightPredicate = (m) => (m.name === "season" || m.name === "episode") && m.tags.includes("SxxExx");
|
|
10137
10702
|
class RemoveLessSpecificSeasonEpisode extends RemoveAmbiguous {
|
|
10138
10703
|
constructor(name) {
|
|
10139
10704
|
super(
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
),
|
|
10705
|
+
// Sort fileparts most-valuable-first: a SxxExx-tagged season/episode outweighs a
|
|
10706
|
+
// weaker one, so the filename's S44E03 beats a season-only or weak-number parent
|
|
10707
|
+
// directory (upstream #797/#772).
|
|
10708
|
+
(markers, matches) => markerSorted(markers, matches, sxxExxWeightPredicate),
|
|
10145
10709
|
(m) => m.name === name
|
|
10146
10710
|
);
|
|
10147
10711
|
}
|
|
10712
|
+
when(matches, context) {
|
|
10713
|
+
const markers = matches.markers.named("path");
|
|
10714
|
+
const markerArr = Array.isArray(markers) ? markers : markers ? [markers] : [];
|
|
10715
|
+
if (markerArr.length > 1) {
|
|
10716
|
+
const weights = markerArr.map((marker) => {
|
|
10717
|
+
const inRange = matches.range(marker.start, marker.end, sxxExxWeightPredicate);
|
|
10718
|
+
return new Set((Array.isArray(inRange) ? inRange : []).map((m) => m.name)).size;
|
|
10719
|
+
});
|
|
10720
|
+
const top = Math.max(...weights);
|
|
10721
|
+
if (weights.filter((w) => w === top).length > 1) return [];
|
|
10722
|
+
}
|
|
10723
|
+
return super.when(matches, context);
|
|
10724
|
+
}
|
|
10725
|
+
}
|
|
10726
|
+
class RemoveLessSpecificSeason extends RemoveLessSpecificSeasonEpisode {
|
|
10727
|
+
constructor() {
|
|
10728
|
+
super("season");
|
|
10729
|
+
}
|
|
10730
|
+
}
|
|
10731
|
+
class RemoveLessSpecificEpisode extends RemoveLessSpecificSeasonEpisode {
|
|
10732
|
+
constructor() {
|
|
10733
|
+
super("episode");
|
|
10734
|
+
}
|
|
10148
10735
|
}
|
|
10149
10736
|
const _SeasonYear = class _SeasonYear extends Rule {
|
|
10150
10737
|
when(matches, _context) {
|
|
@@ -10237,8 +10824,8 @@ function processors(_config) {
|
|
|
10237
10824
|
return new Rebulk().rules(
|
|
10238
10825
|
EnlargeGroupMatches,
|
|
10239
10826
|
EquivalentHoles,
|
|
10240
|
-
|
|
10241
|
-
|
|
10827
|
+
RemoveLessSpecificSeason,
|
|
10828
|
+
RemoveLessSpecificEpisode,
|
|
10242
10829
|
RemoveAmbiguous,
|
|
10243
10830
|
SeasonYear,
|
|
10244
10831
|
YearSeason,
|
|
@@ -10271,9 +10858,13 @@ function rebulkBuilder(config) {
|
|
|
10271
10858
|
rebulk.rebulk(streamingService(cfg("streaming_service")));
|
|
10272
10859
|
const otherRebulk = other(cfg("other"));
|
|
10273
10860
|
cfg("episodes");
|
|
10274
|
-
|
|
10275
|
-
|
|
10276
|
-
|
|
10861
|
+
completeWords(otherRebulk, {
|
|
10862
|
+
completeMarkerWords: ["Complete", "Int[ée]grale"],
|
|
10863
|
+
seasonWords: ["seasons?", "mini-?series?", "series?"],
|
|
10864
|
+
completeArticleWords: ["The"],
|
|
10865
|
+
completePrefixWords: ["L['’]?", "Coffret"],
|
|
10866
|
+
seasonNumberSeparators: ["&", "and"]
|
|
10867
|
+
});
|
|
10277
10868
|
rebulk.rebulk(otherRebulk);
|
|
10278
10869
|
rebulk.rebulk(size(cfg("size")));
|
|
10279
10870
|
rebulk.rebulk(bitRate(cfg("bit_rate")));
|
|
@@ -10412,7 +11003,10 @@ const advanced_config = {
|
|
|
10412
11003
|
"True-?HD"
|
|
10413
11004
|
]
|
|
10414
11005
|
},
|
|
10415
|
-
Opus:
|
|
11006
|
+
Opus: {
|
|
11007
|
+
string: "Opus",
|
|
11008
|
+
tags: "title-word"
|
|
11009
|
+
},
|
|
10416
11010
|
Vorbis: "Vorbis",
|
|
10417
11011
|
PCM: "PCM",
|
|
10418
11012
|
LPCM: "LPCM"
|
|
@@ -10916,27 +11510,104 @@ const advanced_config = {
|
|
|
10916
11510
|
"saisons",
|
|
10917
11511
|
"tem",
|
|
10918
11512
|
"temp",
|
|
10919
|
-
|
|
10920
|
-
|
|
10921
|
-
|
|
11513
|
+
{
|
|
11514
|
+
value: "temporada",
|
|
11515
|
+
numfirst: true
|
|
11516
|
+
},
|
|
11517
|
+
{
|
|
11518
|
+
value: "temporadas",
|
|
11519
|
+
numfirst: true
|
|
11520
|
+
},
|
|
11521
|
+
"stagione",
|
|
11522
|
+
{
|
|
11523
|
+
value: "сезон",
|
|
11524
|
+
numfirst: true
|
|
11525
|
+
},
|
|
11526
|
+
{
|
|
11527
|
+
value: "sezon",
|
|
11528
|
+
numfirst: true
|
|
11529
|
+
},
|
|
11530
|
+
{
|
|
11531
|
+
value: "staffel",
|
|
11532
|
+
numfirst: true
|
|
11533
|
+
},
|
|
11534
|
+
"sezonul",
|
|
11535
|
+
"säsong",
|
|
11536
|
+
"sesong",
|
|
11537
|
+
"sæson",
|
|
11538
|
+
{
|
|
11539
|
+
value: "évad",
|
|
11540
|
+
numfirst: true
|
|
11541
|
+
}
|
|
10922
11542
|
],
|
|
10923
11543
|
episode_words: [
|
|
10924
11544
|
"episode",
|
|
10925
11545
|
"episodes",
|
|
11546
|
+
"épisode",
|
|
11547
|
+
"épisodes",
|
|
10926
11548
|
"eps",
|
|
10927
11549
|
"ep",
|
|
10928
11550
|
"episodio",
|
|
10929
11551
|
"episodios",
|
|
10930
11552
|
"capitulo",
|
|
10931
|
-
"capitulos"
|
|
11553
|
+
"capitulos",
|
|
11554
|
+
{
|
|
11555
|
+
value: "серия",
|
|
11556
|
+
numfirst: true
|
|
11557
|
+
},
|
|
11558
|
+
{
|
|
11559
|
+
value: "серии",
|
|
11560
|
+
numfirst: true
|
|
11561
|
+
},
|
|
11562
|
+
{
|
|
11563
|
+
value: "эпизод",
|
|
11564
|
+
numfirst: true
|
|
11565
|
+
},
|
|
11566
|
+
{
|
|
11567
|
+
value: "seria",
|
|
11568
|
+
numfirst: true
|
|
11569
|
+
},
|
|
11570
|
+
{
|
|
11571
|
+
value: "serii",
|
|
11572
|
+
numfirst: true
|
|
11573
|
+
},
|
|
11574
|
+
{
|
|
11575
|
+
value: "serija",
|
|
11576
|
+
numfirst: true
|
|
11577
|
+
},
|
|
11578
|
+
{
|
|
11579
|
+
value: "bölüm",
|
|
11580
|
+
numfirst: true
|
|
11581
|
+
},
|
|
11582
|
+
{
|
|
11583
|
+
value: "bolum",
|
|
11584
|
+
numfirst: true
|
|
11585
|
+
},
|
|
11586
|
+
"aflevering",
|
|
11587
|
+
"afl",
|
|
11588
|
+
"folge",
|
|
11589
|
+
"odcinek",
|
|
11590
|
+
"episodul",
|
|
11591
|
+
"avsnitt",
|
|
11592
|
+
{
|
|
11593
|
+
value: "rész",
|
|
11594
|
+
numfirst: true
|
|
11595
|
+
}
|
|
10932
11596
|
],
|
|
10933
11597
|
of_words: [
|
|
10934
11598
|
"of",
|
|
10935
|
-
"sur"
|
|
11599
|
+
"sur",
|
|
11600
|
+
"de",
|
|
11601
|
+
"di",
|
|
11602
|
+
"von",
|
|
11603
|
+
"van",
|
|
11604
|
+
"din",
|
|
11605
|
+
"из"
|
|
10936
11606
|
],
|
|
10937
11607
|
all_words: [
|
|
10938
11608
|
"All"
|
|
10939
|
-
]
|
|
11609
|
+
],
|
|
11610
|
+
ordinal_suffix: "(?:ª|º|°|a|o|-?(?:й|я|е|го|ая|ый|ое))?"
|
|
10940
11611
|
},
|
|
10941
11612
|
film: {
|
|
10942
11613
|
film: {
|
|
@@ -11243,52 +11914,14 @@ const advanced_config = {
|
|
|
11243
11914
|
},
|
|
11244
11915
|
"Virtual Reality": {
|
|
11245
11916
|
string: [
|
|
11246
|
-
"VR"
|
|
11917
|
+
"VR",
|
|
11918
|
+
"EAC360"
|
|
11247
11919
|
],
|
|
11248
11920
|
regex: [
|
|
11249
11921
|
"VR180",
|
|
11250
|
-
"VR360"
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
},
|
|
11254
|
-
"Opening Credits": {
|
|
11255
|
-
string: [
|
|
11256
|
-
"NCOP",
|
|
11257
|
-
"OPED"
|
|
11258
|
-
],
|
|
11259
|
-
regex: [
|
|
11260
|
-
"NC-?OP",
|
|
11261
|
-
"creditless-?opening"
|
|
11262
|
-
],
|
|
11263
|
-
tags: "has-neighbor"
|
|
11264
|
-
},
|
|
11265
|
-
"Ending Credits": {
|
|
11266
|
-
string: [
|
|
11267
|
-
"NCED"
|
|
11268
|
-
],
|
|
11269
|
-
regex: [
|
|
11270
|
-
"NC-?ED",
|
|
11271
|
-
"creditless-?ending"
|
|
11272
|
-
],
|
|
11273
|
-
tags: "has-neighbor"
|
|
11274
|
-
},
|
|
11275
|
-
"Half SBS": {
|
|
11276
|
-
string: [
|
|
11277
|
-
"HSBS"
|
|
11278
|
-
],
|
|
11279
|
-
regex: [
|
|
11280
|
-
"Half-?SBS"
|
|
11281
|
-
],
|
|
11282
|
-
tags: "has-neighbor"
|
|
11283
|
-
},
|
|
11284
|
-
"Half OU": {
|
|
11285
|
-
string: [
|
|
11286
|
-
"HOU",
|
|
11287
|
-
"HTAB"
|
|
11288
|
-
],
|
|
11289
|
-
regex: [
|
|
11290
|
-
"Half-?OU",
|
|
11291
|
-
"Half-?TAB"
|
|
11922
|
+
"VR360",
|
|
11923
|
+
"VR-180",
|
|
11924
|
+
"VR-360"
|
|
11292
11925
|
],
|
|
11293
11926
|
tags: "has-neighbor"
|
|
11294
11927
|
},
|
|
@@ -11478,7 +12111,7 @@ const advanced_config = {
|
|
|
11478
12111
|
tags: "uhdbluray-neighbor"
|
|
11479
12112
|
},
|
|
11480
12113
|
"Dolby Vision": {
|
|
11481
|
-
regex: "(?:Dolby-?Vision|DV)",
|
|
12114
|
+
regex: "(?:Dolby-?Vision|DoVi|DV)",
|
|
11482
12115
|
tags: "uhdbluray-neighbor"
|
|
11483
12116
|
},
|
|
11484
12117
|
"BT.2020": {
|
|
@@ -11535,6 +12168,48 @@ const advanced_config = {
|
|
|
11535
12168
|
complete_article_words: [
|
|
11536
12169
|
"The"
|
|
11537
12170
|
]
|
|
12171
|
+
},
|
|
12172
|
+
"Side By Side": {
|
|
12173
|
+
string: [
|
|
12174
|
+
"SBS",
|
|
12175
|
+
"LR"
|
|
12176
|
+
],
|
|
12177
|
+
tags: [
|
|
12178
|
+
"has-neighbor",
|
|
12179
|
+
"stereo-vr-context"
|
|
12180
|
+
]
|
|
12181
|
+
},
|
|
12182
|
+
"Over Under": {
|
|
12183
|
+
string: [
|
|
12184
|
+
"TB",
|
|
12185
|
+
"OU"
|
|
12186
|
+
],
|
|
12187
|
+
tags: [
|
|
12188
|
+
"has-neighbor",
|
|
12189
|
+
"stereo-vr-context"
|
|
12190
|
+
]
|
|
12191
|
+
},
|
|
12192
|
+
"Half Side By Side": {
|
|
12193
|
+
string: [
|
|
12194
|
+
"HSBS"
|
|
12195
|
+
],
|
|
12196
|
+
regex: [
|
|
12197
|
+
"h-?sbs",
|
|
12198
|
+
"half-?sbs"
|
|
12199
|
+
],
|
|
12200
|
+
tags: "has-neighbor"
|
|
12201
|
+
},
|
|
12202
|
+
"Half Over Under": {
|
|
12203
|
+
string: [
|
|
12204
|
+
"HOU",
|
|
12205
|
+
"HTAB"
|
|
12206
|
+
],
|
|
12207
|
+
regex: [
|
|
12208
|
+
"h-?ou",
|
|
12209
|
+
"half-?ou",
|
|
12210
|
+
"half-?tab"
|
|
12211
|
+
],
|
|
12212
|
+
tags: "has-neighbor"
|
|
11538
12213
|
}
|
|
11539
12214
|
}
|
|
11540
12215
|
},
|
|
@@ -11863,6 +12538,26 @@ const advanced_config = {
|
|
|
11863
12538
|
date: {
|
|
11864
12539
|
week_words: [
|
|
11865
12540
|
"week"
|
|
12541
|
+
],
|
|
12542
|
+
weekday_words: [
|
|
12543
|
+
"monday",
|
|
12544
|
+
"tuesday",
|
|
12545
|
+
"wednesday",
|
|
12546
|
+
"thursday",
|
|
12547
|
+
"friday",
|
|
12548
|
+
"saturday",
|
|
12549
|
+
"sunday",
|
|
12550
|
+
"mon",
|
|
12551
|
+
"tue",
|
|
12552
|
+
"tues",
|
|
12553
|
+
"wed",
|
|
12554
|
+
"weds",
|
|
12555
|
+
"thu",
|
|
12556
|
+
"thur",
|
|
12557
|
+
"thurs",
|
|
12558
|
+
"fri",
|
|
12559
|
+
"sat",
|
|
12560
|
+
"sun"
|
|
11866
12561
|
]
|
|
11867
12562
|
}
|
|
11868
12563
|
};
|
|
@@ -12339,7 +13034,6 @@ const GUESSIT_SCHEMA = {
|
|
|
12339
13034
|
"Dual",
|
|
12340
13035
|
"Dual Audio",
|
|
12341
13036
|
"East Coast Feed",
|
|
12342
|
-
"Ending Credits",
|
|
12343
13037
|
"Extras",
|
|
12344
13038
|
"Fan Subtitled",
|
|
12345
13039
|
"Fanart",
|
|
@@ -12350,8 +13044,8 @@ const GUESSIT_SCHEMA = {
|
|
|
12350
13044
|
"Fix",
|
|
12351
13045
|
"Fixed",
|
|
12352
13046
|
"Full HD",
|
|
12353
|
-
"Half
|
|
12354
|
-
"Half
|
|
13047
|
+
"Half Over Under",
|
|
13048
|
+
"Half Side By Side",
|
|
12355
13049
|
"Hardcoded Subtitles",
|
|
12356
13050
|
"HC",
|
|
12357
13051
|
"HD",
|
|
@@ -12386,7 +13080,6 @@ const GUESSIT_SCHEMA = {
|
|
|
12386
13080
|
"Obfuscated",
|
|
12387
13081
|
"Ona",
|
|
12388
13082
|
"Open Matte",
|
|
12389
|
-
"Opening Credits",
|
|
12390
13083
|
"Original Animated Video",
|
|
12391
13084
|
"Original Animation DVD",
|
|
12392
13085
|
"Original Aspect Ratio",
|
|
@@ -12394,6 +13087,7 @@ const GUESSIT_SCHEMA = {
|
|
|
12394
13087
|
"Original Video",
|
|
12395
13088
|
"OV",
|
|
12396
13089
|
"Ova",
|
|
13090
|
+
"Over Under",
|
|
12397
13091
|
"PAL",
|
|
12398
13092
|
"postbot",
|
|
12399
13093
|
"Poster",
|
|
@@ -12418,6 +13112,7 @@ const GUESSIT_SCHEMA = {
|
|
|
12418
13112
|
"Screener",
|
|
12419
13113
|
"SDR",
|
|
12420
13114
|
"SECAM",
|
|
13115
|
+
"Side By Side",
|
|
12421
13116
|
"Standard Dynamic Range",
|
|
12422
13117
|
"Straight to Video",
|
|
12423
13118
|
"STV",
|
|
@@ -12523,6 +13218,7 @@ const GUESSIT_SCHEMA = {
|
|
|
12523
13218
|
"HD Telesync",
|
|
12524
13219
|
"HD-DVD",
|
|
12525
13220
|
"HDTV",
|
|
13221
|
+
"Laserdisc",
|
|
12526
13222
|
"Pay-per-view",
|
|
12527
13223
|
"Satellite",
|
|
12528
13224
|
"Telecine",
|