guessit-js 4.0.1 → 4.1.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.
@@ -3233,6 +3233,43 @@ function isDisabled(context, name) {
3233
3233
  if (includes && includes.length > 0 && !includes.includes(name)) return true;
3234
3234
  return false;
3235
3235
  }
3236
+ const CJK_DIGITS = {
3237
+ "零": 0,
3238
+ "一": 1,
3239
+ "二": 2,
3240
+ "两": 2,
3241
+ "三": 3,
3242
+ "四": 4,
3243
+ "五": 5,
3244
+ "六": 6,
3245
+ "七": 7,
3246
+ "八": 8,
3247
+ "九": 9
3248
+ };
3249
+ const CJK_NUMBER = "(?:\\d{1,4}|[一二两三四五六七八九]?十[一二两三四五六七八九]?|[零一二两三四五六七八九])";
3250
+ function parseCjkNumber(value) {
3251
+ if (/^\d+$/.test(value)) return parseInt(value, 10);
3252
+ if (value.includes("十")) {
3253
+ const [tens, ones] = value.split("十");
3254
+ const tensValue = tens ? CJK_DIGITS[tens] : 1;
3255
+ const onesValue = ones ? CJK_DIGITS[ones] : 0;
3256
+ return tensValue * 10 + onesValue;
3257
+ }
3258
+ return CJK_DIGITS[value];
3259
+ }
3260
+ function splitWords(entries) {
3261
+ const words = [];
3262
+ const numfirst = [];
3263
+ for (const entry of entries) {
3264
+ if (typeof entry === "object") {
3265
+ if (entry.numfirst) numfirst.push(entry.value);
3266
+ words.push(entry.value);
3267
+ } else {
3268
+ words.push(entry);
3269
+ }
3270
+ }
3271
+ return { words, numfirst };
3272
+ }
3236
3273
  function episodesSeasonChainBreaker(matches, config) {
3237
3274
  const episodes2 = matches.named("episode") || [];
3238
3275
  if (episodes2.length > 1 && Math.abs(episodes2[episodes2.length - 1].value - episodes2[episodes2.length - 2].value) > config.episode_max_range) {
@@ -3271,6 +3308,37 @@ function seasonEpisodeConflictSolver(match, other2) {
3271
3308
  }
3272
3309
  }
3273
3310
  if (["season", "episode"].includes(match.name) && ["season", "episode"].includes(other2.name) && match.initiator !== other2.initiator) {
3311
+ const isWeak = (m) => !!(m.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(m.initiator?.name));
3312
+ const matchNumfirst = !!match.tags?.includes("numfirst");
3313
+ const otherNumfirst = !!other2.tags?.includes("numfirst");
3314
+ if (matchNumfirst !== otherNumfirst && !isWeak(match) && !isWeak(other2) && match.start < other2.end && other2.start < match.end) {
3315
+ const nf = matchNumfirst ? match : other2;
3316
+ const wf = matchNumfirst ? other2 : match;
3317
+ const input = match.inputString ?? "";
3318
+ const digitToken = (from, dir) => {
3319
+ let i = from;
3320
+ while (i >= 0 && i < input.length && seps.includes(input[i])) i += dir;
3321
+ let tok = "";
3322
+ while (i >= 0 && i < input.length && /\d/.test(input[i])) {
3323
+ tok = dir === 1 ? tok + input[i] : input[i] + tok;
3324
+ i += dir;
3325
+ }
3326
+ return tok;
3327
+ };
3328
+ const isYearLike = (t) => t.length === 4 && +t >= 1900 && +t <= 2100;
3329
+ const nfInit = nf.initiator ?? nf;
3330
+ const wfInit = wf.initiator ?? wf;
3331
+ const nfDangling = (() => {
3332
+ const t = digitToken(nfInit.end, 1);
3333
+ return t.length >= 1 && t.length <= 4 && !isYearLike(t);
3334
+ })();
3335
+ const wfDangling = (() => {
3336
+ const t = digitToken(wfInit.start - 1, -1);
3337
+ return t.length >= 1 && t.length <= 3 && !isYearLike(t);
3338
+ })();
3339
+ if (wfDangling && !nfDangling) return wf;
3340
+ return nf;
3341
+ }
3274
3342
  const matchIsWeak = !!(match.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(match.initiator?.name));
3275
3343
  const otherIsWeak = !!(other2.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(other2.initiator?.name));
3276
3344
  if (matchIsWeak && otherIsWeak) {
@@ -3374,15 +3442,16 @@ function episodes(config) {
3374
3442
  }
3375
3443
  const rebulk = new Rebulk().regexDefaults({ flags: "i" }).stringDefaults({ ignoreCase: true }).defaults({
3376
3444
  privateNames: ["episodeSeparator", "seasonSeparator", "episodeMarker", "seasonMarker"],
3377
- formatter: { season: (v) => parseInt(v, 10), episode: (v) => parseInt(v, 10), version: (v) => parseInt(v, 10) },
3445
+ formatter: { season: (v) => parseInt(v, 10), episode: (v) => parseInt(v, 10), version: (v) => parseInt(v, 10), count: (v) => parseInt(v, 10) },
3378
3446
  children: true,
3379
3447
  privateParent: true,
3380
3448
  conflictSolver: seasonEpisodeConflictSolver,
3381
3449
  abbreviations: [altDash]
3382
3450
  });
3383
- rebulk.regex("第(?<episode>\\d{1,4})話", { tags: ["SxxExx"] });
3384
- rebulk.regex("(?:シーズン|シリーズ)(?<season>\\d{1,2})", { tags: ["SxxExx"] });
3385
- rebulk.regex("(?<season>\\d{1,2})期", {});
3451
+ rebulk.regex(`第(?<episode>${CJK_NUMBER})[話话集]`, { tags: ["SxxExx"], formatter: { episode: parseCjkNumber } });
3452
+ rebulk.regex(`第(?<season>${CJK_NUMBER})季`, { tags: ["SxxExx"], formatter: { season: parseCjkNumber } });
3453
+ rebulk.regex("(?:シーズン|シリーズ)(?<season>\\d{1,2})(?!\\d)", { tags: ["SxxExx"] });
3454
+ rebulk.regex("(?<!\\d)(?<season>\\d{1,2})期", {});
3386
3455
  const seasonMarkerPattern = buildOrPattern(config.season_markers, "seasonMarker");
3387
3456
  const episodeMarkerPattern = buildOrPattern(
3388
3457
  [...config.episode_markers, ...config.disc_markers],
@@ -3407,6 +3476,7 @@ function episodes(config) {
3407
3476
  allSeparatorsPattern + `@?(?<episode>\\d+)`
3408
3477
  ).repeater("*");
3409
3478
  const seasonEpMarkerPattern = buildOrPattern(config.season_ep_markers, "episodeMarker");
3479
+ const asymmetricSeasonEpMarker = `(?!@` + buildOrPattern(config.season_ep_markers) + `\\d)`;
3410
3480
  rebulk.chain({
3411
3481
  tags: ["SxxExx"],
3412
3482
  validateAll: true,
@@ -3415,7 +3485,7 @@ function episodes(config) {
3415
3485
  },
3416
3486
  disabled: isSeasonEpisodeDisabled
3417
3487
  }).defaults({ tags: ["SxxExx"] }).regex(
3418
- `(?<season>\\d+)@?` + seasonEpMarkerPattern + `@?(?<episode>\\d+)`
3488
+ `(?<season>\\d+)` + asymmetricSeasonEpMarker + `@?` + seasonEpMarkerPattern + `@?(?<episode>\\d+)`
3419
3489
  ).repeater("+");
3420
3490
  rebulk.chain({
3421
3491
  tags: ["SxxExx"],
@@ -3424,13 +3494,17 @@ function episodes(config) {
3424
3494
  __parent__: and_(sepsSurround, orderingValidator)
3425
3495
  },
3426
3496
  disabled: isSeasonEpisodeDisabled
3427
- }).defaults({ tags: ["SxxExx"] }).regex(`(?<season>\\d+)@?` + seasonEpMarkerPattern + `@?(?<episode>\\d+)`).regex(
3497
+ }).defaults({ tags: ["SxxExx"] }).regex(`(?<season>\\d+)` + asymmetricSeasonEpMarker + `@?` + seasonEpMarkerPattern + `@?(?<episode>\\d+)`).regex(
3428
3498
  buildOrPattern(
3429
3499
  [...config.season_ep_markers, ...discreteSeparators, ...config.range_separators],
3430
3500
  "episodeSeparator",
3431
3501
  true
3432
3502
  ) + `(?<episode>\\d+)`
3433
3503
  ).repeater("*");
3504
+ rebulk.regex(
3505
+ `t(?<season>\\d{1,2})@?` + buildOrPattern(config.episode_markers, "episodeMarker") + `@?(?<episode>\\d{1,4})`,
3506
+ { tags: ["SxxExx"], disabled: isSeasonEpisodeDisabled }
3507
+ );
3434
3508
  const seasonOnlySepPattern = buildOrPattern(
3435
3509
  [...config.season_markers, ...discreteSeparators, ...config.range_separators],
3436
3510
  "seasonSeparator",
@@ -3453,7 +3527,9 @@ function episodes(config) {
3453
3527
  disabled: (context) => isDisabled(context, "episode_details")
3454
3528
  });
3455
3529
  }
3456
- const seasonWordPattern = buildOrPattern(config.season_words, "seasonMarker");
3530
+ const { words: seasonWords, numfirst: seasonWordsNumfirst } = splitWords(config.season_words);
3531
+ const { words: episodeWords, numfirst: episodeWordsNumfirst } = splitWords(config.episode_words);
3532
+ const seasonWordPattern = buildOrPattern(seasonWords, "seasonMarker");
3457
3533
  const ofWordPattern = buildOrPattern(config.of_words);
3458
3534
  rebulk.chain({
3459
3535
  validateAll: true,
@@ -3477,7 +3553,28 @@ function episodes(config) {
3477
3553
  true
3478
3554
  ) + `@?(?P<season>\\d+)`
3479
3555
  ).repeater("*");
3480
- const episodeWordPattern = buildOrPattern(config.episode_words, "episodeMarker");
3556
+ const ofCountPattern = `(?:@?` + ofWordPattern + `@?(?<count>\\d+))?`;
3557
+ if (seasonWordsNumfirst.length > 0) {
3558
+ rebulk.regex(
3559
+ `(?<season>\\d{1,2})` + config.ordinal_suffix + `@?@?` + buildOrPattern(seasonWordsNumfirst, "seasonMarker") + `(?![^\\W\\d_])` + ofCountPattern,
3560
+ {
3561
+ tags: ["SxxExx", "numfirst"],
3562
+ formatter: { season: parseNumber, count: (v) => parseInt(v, 10) },
3563
+ disabled: isSeasonEpisodeDisabled
3564
+ }
3565
+ );
3566
+ }
3567
+ if (episodeWordsNumfirst.length > 0) {
3568
+ rebulk.regex(
3569
+ `(?<episode>\\d{1,3})` + config.ordinal_suffix + `@?@?` + buildOrPattern(episodeWordsNumfirst, "episodeMarker") + `(?![^\\W\\d_])` + ofCountPattern,
3570
+ {
3571
+ tags: ["SxxExx", "numfirst"],
3572
+ formatter: { episode: parseNumber, count: (v) => parseInt(v, 10) },
3573
+ disabled: (context) => isDisabled(context, "episode")
3574
+ }
3575
+ );
3576
+ }
3577
+ const episodeWordPattern = buildOrPattern(episodeWords, "episodeMarker");
3481
3578
  rebulk.regex(
3482
3579
  `(?<![a-zA-Z\\d])` + episodeWordPattern + `@?(?<episode>\\d+)(?:v(?<version>\\d+))?(?:@?` + ofWordPattern + `@?(?<count>\\d+))?`,
3483
3580
  {
@@ -3563,9 +3660,11 @@ function episodes(config) {
3563
3660
  disabled: (context) => isDisabled(context, "version")
3564
3661
  });
3565
3662
  rebulk.regex(
3566
- `(?<episode>\\d+)@?` + ofWordPattern + `@?(?<episode_count>\\d+)@?` + episodeWordPattern + "?",
3663
+ // The lookbehind keeps this off token tails: "AC3-de[42]" is not "episode 3 of 42"
3664
+ // ('de' is also a Spanish of-word — codec suffixes must stay intact).
3665
+ `(?<![^\\W_])(?<episode>\\d+)@?` + ofWordPattern + `@?(?<count>\\d+)@?` + episodeWordPattern + "?",
3567
3666
  {
3568
- formatter: { episode: (v) => parseInt(v, 10), episode_count: (v) => parseInt(v, 10) },
3667
+ formatter: { episode: (v) => parseInt(v, 10), count: (v) => parseInt(v, 10) },
3569
3668
  preMatchProcessor: (match) => {
3570
3669
  match.value = cleanup(match.value);
3571
3670
  return match;
@@ -3581,6 +3680,8 @@ function episodes(config) {
3581
3680
  disabled: (context) => isDisabled(context, "episode_format")
3582
3681
  });
3583
3682
  rebulk.rules(
3683
+ RemoveNumfirstMarkerCollision,
3684
+ CountValidator,
3584
3685
  new DiscMarkerRule(config),
3585
3686
  FixCorruptedGroupBoundaryValues,
3586
3687
  new RangeExpansionRule(config),
@@ -3594,6 +3695,67 @@ function episodes(config) {
3594
3695
  );
3595
3696
  return rebulk;
3596
3697
  }
3698
+ const _RemoveNumfirstMarkerCollision = class _RemoveNumfirstMarkerCollision extends Rule {
3699
+ constructor() {
3700
+ super(...arguments);
3701
+ this.priority = 70;
3702
+ this.consequence = RemoveMatch;
3703
+ }
3704
+ when(matches, _context) {
3705
+ const toRemove = [];
3706
+ const isWeak = (m) => !!(m.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(m.initiator?.name));
3707
+ const numfirsts = (matches.matches ?? []).filter((m) => (m.name === "season" || m.name === "episode") && m.tags?.includes("numfirst"));
3708
+ for (const nf of numfirsts) {
3709
+ const nfInit = nf.initiator ?? nf;
3710
+ const collides = (matches.matches ?? []).some((w) => {
3711
+ if (w.name !== "season" && w.name !== "episode") return false;
3712
+ if (w.tags?.includes("numfirst") || isWeak(w)) return false;
3713
+ const wInit = w.initiator ?? w;
3714
+ if (wInit === nfInit) return false;
3715
+ return wInit.start < nfInit.end && nfInit.start < wInit.end;
3716
+ });
3717
+ if (collides) {
3718
+ toRemove.push(nf);
3719
+ for (const child of nfInit.children ?? []) {
3720
+ if (child !== nf && !toRemove.includes(child)) toRemove.push(child);
3721
+ }
3722
+ }
3723
+ }
3724
+ return toRemove.length ? toRemove : false;
3725
+ }
3726
+ };
3727
+ _RemoveNumfirstMarkerCollision.priority = 70;
3728
+ let RemoveNumfirstMarkerCollision = _RemoveNumfirstMarkerCollision;
3729
+ const _CountValidator = class _CountValidator extends Rule {
3730
+ constructor() {
3731
+ super(...arguments);
3732
+ this.priority = 64;
3733
+ this.consequence = [RemoveMatch, new RenameMatch("episode_count"), new RenameMatch("season_count")];
3734
+ }
3735
+ when(matches, _context) {
3736
+ const toRemove = [];
3737
+ const episodeCount = [];
3738
+ const seasonCount = [];
3739
+ for (const count of matches.named("count") ?? []) {
3740
+ const numbers = matches.range(
3741
+ count.initiator.start,
3742
+ count.start,
3743
+ (m) => m.name === "episode" || m.name === "season"
3744
+ );
3745
+ const numbered = numbers.length ? numbers[numbers.length - 1] : void 0;
3746
+ if (!numbered) toRemove.push(count);
3747
+ else if (numbered.name === "episode") episodeCount.push(count);
3748
+ else seasonCount.push(count);
3749
+ }
3750
+ if (toRemove.length || episodeCount.length || seasonCount.length) {
3751
+ return [toRemove, episodeCount, seasonCount];
3752
+ }
3753
+ return false;
3754
+ }
3755
+ };
3756
+ _CountValidator.priority = 64;
3757
+ _CountValidator.consequence = [RemoveMatch, new RenameMatch("episode_count"), new RenameMatch("season_count")];
3758
+ let CountValidator = _CountValidator;
3597
3759
  const _DiscMarkerRule = class _DiscMarkerRule extends Rule {
3598
3760
  constructor(config) {
3599
3761
  super();
@@ -4199,6 +4361,14 @@ function source(config) {
4199
4361
  ...buildSourcePattern(["DVD"], "", optional(ripSuffix)),
4200
4362
  { value: { source: "DVD", other: "Rip" } }
4201
4363
  );
4364
+ rebulk.regex(
4365
+ ...buildSourcePattern(["LD"], "", ripSuffix),
4366
+ { value: { source: "Laserdisc", other: "Rip" } }
4367
+ );
4368
+ rebulk.regex(
4369
+ ...buildSourcePattern(["LASERDISC"], "", optional(ripSuffix)),
4370
+ { value: { source: "Laserdisc", other: "Rip" } }
4371
+ );
4202
4372
  rebulk.regex(
4203
4373
  ...buildSourcePattern(["DM"], "", optional(ripSuffix)),
4204
4374
  { value: { source: "Digital Master", other: "Rip" } }
@@ -5019,7 +5189,8 @@ function screenSize(config) {
5019
5189
  const frameRatePattern = buildOrPattern(frameRates, "frame_rate");
5020
5190
  const interlacedPattern = buildOrPattern([...interlaced], "height");
5021
5191
  const progressivePattern = buildOrPattern([...progressive], "height");
5022
- const resPattern = `(?:(?<width>\\d{3,4})(?:x|\\*))?`;
5192
+ const resSeparator = `(?:x|\\*|×)`;
5193
+ const resPattern = `(?:(?<width>\\d{3,4})${resSeparator})?`;
5023
5194
  rebulk.regex(resPattern + interlacedPattern + `(?<scan_type>i)` + frameRatePattern + `?`);
5024
5195
  rebulk.regex(resPattern + progressivePattern + `(?<scan_type>p)` + frameRatePattern + `?`);
5025
5196
  rebulk.regex(resPattern + progressivePattern + `(?<scan_type>p)?(?:hd)`);
@@ -5028,7 +5199,7 @@ function screenSize(config) {
5028
5199
  value: "2160p",
5029
5200
  conflictSolver: (match, other2) => other2.name === "screen_size" ? "__default__" : match
5030
5201
  });
5031
- rebulk.regex(`(?<width>\\d{3,4})-?(?:x|\\*)-?(?<height>\\d{3,4})`, {
5202
+ rebulk.regex(`(?<width>\\d{3,4})(?:${resSeparator}|-${resSeparator}-)(?<height>\\d{3,4})(?:up)?`, {
5032
5203
  conflictSolver: (match, other2) => other2.name === "screen_size" ? "__default__" : other2
5033
5204
  });
5034
5205
  rebulk.regex(frameRatePattern + `-?(?:p|fps)`, {
@@ -5062,7 +5233,7 @@ const _PostProcessScreenSize = class _PostProcessScreenSize extends Rule {
5062
5233
  let values = match.children.toDict();
5063
5234
  if (!("height" in values)) {
5064
5235
  const raw = String(match.raw ?? "");
5065
- const rxWxH = /^(\d{3,4})\s*[xX*]\s*(\d{3,4})$/i;
5236
+ const rxWxH = /^(\d{3,4})\s*[xX*×]\s*(\d{3,4})(?:up)?$/i;
5066
5237
  const mWxH = rxWxH.exec(raw);
5067
5238
  if (mWxH) {
5068
5239
  values = { width: mWxH[1], height: mWxH[2], scan_type: void 0 };
@@ -5127,10 +5298,19 @@ const _ResolveScreenSizeConflicts = class _ResolveScreenSizeConflicts extends Ru
5127
5298
  const conflicts = matches.conflicting(screenSizeMatch, (m) => ["season", "episode"].includes(m.name ?? "")) ?? [];
5128
5299
  if (conflicts.length === 0) continue;
5129
5300
  let hasNeighbor = false;
5130
- const videoProfile = matches.range(screenSizeMatch.end, filepart.end, (m) => m.name === "video_profile", 0);
5131
- if (videoProfile && matches.holes(screenSizeMatch.end, videoProfile.start, { predicate: (h) => !!(h.value && String(h.value).replace(new RegExp(`[${sepsPattern}]`, "g"), "")) }).length === 0) {
5132
- toRemove.push(...conflicts);
5133
- hasNeighbor = true;
5301
+ const allScreensizes = matches.range(filepart.start, filepart.end, (m) => m.name === "screen_size") ?? [];
5302
+ const groupOf = (m) => matches.markers.atMatch(m, (marker) => marker.name === "group", 0);
5303
+ const following = matches.range(
5304
+ screenSizeMatch.end,
5305
+ filepart.end,
5306
+ (m) => m.name === "video_profile" || m.name === "video_codec",
5307
+ 0
5308
+ );
5309
+ if (following && matches.holes(screenSizeMatch.end, following.start, { predicate: (h) => !!(h.value && String(h.value).replace(new RegExp(`[${sepsPattern}]`, "g"), "")) }).length === 0) {
5310
+ if (following.name === "video_profile" || allScreensizes.length === 1 && groupOf(screenSizeMatch) === groupOf(following)) {
5311
+ toRemove.push(...conflicts);
5312
+ hasNeighbor = true;
5313
+ }
5134
5314
  }
5135
5315
  const previous = matches.previous(screenSizeMatch, (m) => ["date", "source", "other", "streaming_service"].includes(m.name ?? ""), 0);
5136
5316
  if (previous && matches.holes(previous.end, screenSizeMatch.start, { predicate: (h) => !!(h.value && String(h.value).replace(new RegExp(`[${sepsPattern}]`, "g"), "")) }).length === 0) {
@@ -5146,47 +5326,12 @@ const _ResolveScreenSizeConflicts = class _ResolveScreenSizeConflicts extends Ru
5146
5326
  };
5147
5327
  _ResolveScreenSizeConflicts.consequence = RemoveMatch;
5148
5328
  let ResolveScreenSizeConflicts = _ResolveScreenSizeConflicts;
5149
- const DEFAULT_TLDS = [
5150
- "com",
5151
- "org",
5152
- "net",
5153
- "edu",
5154
- "gov",
5155
- "mil",
5156
- "int",
5157
- "co",
5158
- "uk",
5159
- "ca",
5160
- "de",
5161
- "fr",
5162
- "it",
5163
- "es",
5164
- "nl",
5165
- "be",
5166
- "ch",
5167
- "se",
5168
- "no",
5169
- "dk",
5170
- "fi",
5171
- "pl",
5172
- "ru",
5173
- "cn",
5174
- "jp",
5175
- "au",
5176
- "nz",
5177
- "in",
5178
- "br",
5179
- "mx",
5180
- "za",
5181
- "kr",
5182
- "tw",
5183
- "hk"
5184
- ];
5329
+ 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"];
5185
5330
  function website(config) {
5186
5331
  const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "website") });
5187
5332
  rebulk.regexDefaults({ flags: "i" }).stringDefaults({ ignoreCase: true });
5188
5333
  rebulk.defaults({ name: "website" });
5189
- const tlds = config["tlds"] || DEFAULT_TLDS;
5334
+ const tlds = config["tlds"] || TLDS;
5190
5335
  const safeTlds = config["safe_tlds"] || ["com", "org", "net"];
5191
5336
  const safeSubdomains = config["safe_subdomains"] || ["www"];
5192
5337
  const safePrefix = config["safe_prefixes"] || [];
@@ -5209,10 +5354,10 @@ function website(config) {
5209
5354
  tags: ["website.prefix"]
5210
5355
  });
5211
5356
  class PreferTitleOverWebsiteWithConfig extends Rule {
5212
- constructor(safeTldsArg, safePrefixArg) {
5357
+ constructor(safeSubdomainsArg, safePrefixArg) {
5213
5358
  super();
5214
5359
  this.consequence = RemoveMatch;
5215
- this.safeTlds = safeTldsArg;
5360
+ this.safeSubdomains = safeSubdomainsArg;
5216
5361
  this.safePrefix = safePrefixArg;
5217
5362
  }
5218
5363
  validFollowers(match) {
@@ -5222,7 +5367,7 @@ function website(config) {
5222
5367
  const toRemove = [];
5223
5368
  for (const websiteMatch of matches.named("website")) {
5224
5369
  let safe = false;
5225
- for (const safeStart of [...this.safeTlds, ...this.safePrefix]) {
5370
+ for (const safeStart of [...this.safeSubdomains, ...this.safePrefix]) {
5226
5371
  if (String(websiteMatch.value ?? "").toLowerCase().startsWith(safeStart)) {
5227
5372
  safe = true;
5228
5373
  break;
@@ -5253,7 +5398,7 @@ function website(config) {
5253
5398
  return toRemove;
5254
5399
  }
5255
5400
  }
5256
- rebulk.rules(new PreferTitleOverWebsiteWithConfig(safeTlds, safePrefix), ValidateWebsitePrefix);
5401
+ rebulk.rules(new PreferTitleOverWebsiteWithConfig(safeSubdomains, safePrefix), ValidateWebsitePrefix);
5257
5402
  return rebulk;
5258
5403
  }
5259
5404
  const _ValidateWebsitePrefix = class _ValidateWebsitePrefix extends Rule {
@@ -6300,11 +6445,18 @@ const _CountryAtTitlePosition = class _CountryAtTitlePosition extends Rule {
6300
6445
  const filepart = matches.markers.atMatch(c, (m) => m.name === "path", 0);
6301
6446
  if (!filepart) continue;
6302
6447
  if (![...inp.slice(filepart.start, c.start)].every((ch) => seps.includes(ch))) continue;
6303
- const year = matches.range(c.end, filepart.end, (m) => !m.private && m.name === "year", 0);
6304
- if (!year) continue;
6305
- const se = matches.range(c.end, year.start, (m) => !m.private && ["season", "episode", "date"].includes(m.name ?? ""), 0);
6306
- if (se) continue;
6307
- if (![...inp.slice(c.end, year.start)].every((ch) => seps.includes(ch))) continue;
6448
+ if (["release-group-prefix", "streaming_service.prefix", "streaming_service.suffix"].some((t) => c.tags?.includes(t))) continue;
6449
+ if (matches.markers.atMatch(c, (m) => m.name === "group", 0)) continue;
6450
+ const anchor = matches.range(
6451
+ c.end,
6452
+ filepart.end,
6453
+ (m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
6454
+ 0
6455
+ );
6456
+ if (!anchor) continue;
6457
+ if (![...inp.slice(c.end, anchor.start)].every((ch) => seps.includes(ch))) {
6458
+ if (matches.range(c.end, anchor.start, (m) => !m.private && m.value != null, 0)) continue;
6459
+ }
6308
6460
  out.push(c);
6309
6461
  }
6310
6462
  return out.length ? out : false;
@@ -6312,6 +6464,33 @@ const _CountryAtTitlePosition = class _CountryAtTitlePosition extends Rule {
6312
6464
  };
6313
6465
  _CountryAtTitlePosition.priority = 64;
6314
6466
  let CountryAtTitlePosition = _CountryAtTitlePosition;
6467
+ const _TitleWordAtTitlePosition = class _TitleWordAtTitlePosition extends Rule {
6468
+ constructor() {
6469
+ super(...arguments);
6470
+ this.priority = 64;
6471
+ this.consequence = RemoveMatch;
6472
+ }
6473
+ when(matches, _context) {
6474
+ const toRemove = [];
6475
+ const tagged = matches.tagged("title-word") ?? [];
6476
+ for (const candidate of Array.isArray(tagged) ? tagged : [tagged]) {
6477
+ if (!candidate || candidate.private) continue;
6478
+ const filepart = matches.markers.atMatch(candidate, (m) => m.name === "path", 0);
6479
+ if (!filepart) continue;
6480
+ const anchor = matches.range(
6481
+ filepart.start,
6482
+ filepart.end,
6483
+ (m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
6484
+ 0
6485
+ );
6486
+ if (!anchor || candidate.start >= anchor.start) continue;
6487
+ toRemove.push(candidate);
6488
+ }
6489
+ return toRemove.length ? toRemove : false;
6490
+ }
6491
+ };
6492
+ _TitleWordAtTitlePosition.priority = 64;
6493
+ let TitleWordAtTitlePosition = _TitleWordAtTitlePosition;
6315
6494
  const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle extends Rule {
6316
6495
  constructor() {
6317
6496
  super(...arguments);
@@ -6332,6 +6511,7 @@ const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle ex
6332
6511
  const lead = matches.range(filepart.start, filepart.end, (m) => !m.private && !!m.value, 0);
6333
6512
  if (!lead || !["other", "country", "edition"].includes(lead.name ?? "")) continue;
6334
6513
  if (lead.start >= anchor.start) continue;
6514
+ if ((lead.raw ?? "") === String(lead.value ?? "")) continue;
6335
6515
  if (![...inp.slice(filepart.start, lead.start)].every((c) => seps.includes(c))) continue;
6336
6516
  out.push(lead);
6337
6517
  }
@@ -6458,7 +6638,7 @@ function title(config) {
6458
6638
  const rebulk = new Rebulk({
6459
6639
  disabled: (context) => isDisabled(context, "title")
6460
6640
  });
6461
- rebulk.rules(CountryAtTitlePosition, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle);
6641
+ rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle);
6462
6642
  const expectedTitle = buildExpectedFunction("expected_title");
6463
6643
  rebulk.functional(expectedTitle, {
6464
6644
  name: "title",
@@ -7160,6 +7340,32 @@ const _TrimLanguageFromEpisodeTitle = class _TrimLanguageFromEpisodeTitle extend
7160
7340
  };
7161
7341
  _TrimLanguageFromEpisodeTitle.dependency = ["EpisodeTitleFromPosition", "AlternativeTitleReplace"];
7162
7342
  let TrimLanguageFromEpisodeTitle = _TrimLanguageFromEpisodeTitle;
7343
+ function parentTitleHole(matches, start, end) {
7344
+ const holesResult = matches.holes(start, end, {
7345
+ ignore: or_(
7346
+ (m) => !!m.tags?.includes("weak-episode"),
7347
+ (m) => m.name === "language" || m.name === "country" || m.name === "episode_details"
7348
+ ),
7349
+ formatter: cleanup,
7350
+ seps: titleSeps,
7351
+ predicate: (m) => !!m.value
7352
+ });
7353
+ const holes = Array.isArray(holesResult) ? holesResult : holesResult ? [holesResult] : [];
7354
+ if (holes.length === 0) return void 0;
7355
+ const hole = holes[0];
7356
+ const inputString = hole.inputString ?? "";
7357
+ for (const nextHole of holes.slice(1)) {
7358
+ const separator = inputString.slice(hole.end, nextHole.start);
7359
+ const holeRaw = hole.raw;
7360
+ const nextRaw = nextHole.raw;
7361
+ if (separator === "-" && holeRaw && !seps.includes(holeRaw[holeRaw.length - 1]) && nextRaw && !seps.includes(nextRaw[0])) {
7362
+ hole.end = nextHole.end;
7363
+ } else {
7364
+ break;
7365
+ }
7366
+ }
7367
+ return hole;
7368
+ }
7163
7369
  class Filepart3EpisodeTitle extends Rule {
7164
7370
  constructor() {
7165
7371
  super(...arguments);
@@ -7190,16 +7396,7 @@ class Filepart3EpisodeTitle extends Rule {
7190
7396
  0
7191
7397
  );
7192
7398
  if (season) {
7193
- const hole = matches.holes(subdirectory.start, subdirectory.end, {
7194
- ignore: or_(
7195
- (m) => !!m.tags?.includes("weak-episode"),
7196
- (m) => m.name === "language" || m.name === "country" || m.name === "episode_details"
7197
- ),
7198
- formatter: cleanup,
7199
- seps: titleSeps,
7200
- predicate: (m) => !!m.value,
7201
- index: 0
7202
- });
7399
+ const hole = parentTitleHole(matches, subdirectory.start, subdirectory.end);
7203
7400
  if (hole) {
7204
7401
  return hole;
7205
7402
  }
@@ -7232,16 +7429,7 @@ class Filepart2EpisodeTitle extends Rule {
7232
7429
  if (episodeNumber) {
7233
7430
  const season = matches.range(directory.start, directory.end, (m) => m.name === "season", 0) || matches.range(filename.start, filename.end, (m) => m.name === "season", 0);
7234
7431
  if (season) {
7235
- const hole = matches.holes(directory.start, directory.end, {
7236
- ignore: or_(
7237
- (m) => !!m.tags?.includes("weak-episode"),
7238
- (m) => m.name === "language" || m.name === "country" || m.name === "episode_details"
7239
- ),
7240
- formatter: cleanup,
7241
- seps: titleSeps,
7242
- predicate: (m) => !!m.value,
7243
- index: 0
7244
- });
7432
+ const hole = parentTitleHole(matches, directory.start, directory.end);
7245
7433
  if (hole) {
7246
7434
  const groupMarkers = matches.markers.named("group");
7247
7435
  const groupArray = Array.isArray(groupMarkers) ? groupMarkers : groupMarkers ? [groupMarkers] : [];
@@ -8855,7 +9043,11 @@ function other(config) {
8855
9043
  rebulk.regexDefaults({ flags: "i", abbreviations: [dash] }).stringDefaults({ ignoreCase: true });
8856
9044
  rebulk.defaults({ name: "other", validator: sepsSurround });
8857
9045
  loadConfigPatterns(rebulk, config["other"]);
9046
+ openingEndingCredits(rebulk);
8858
9047
  rebulk.rules(
9048
+ AppendCreditless,
9049
+ AppendOpedEndingCredits,
9050
+ ValidateStereoVRContext,
8859
9051
  RenameAnotherToOther,
8860
9052
  ValidateHasNeighbor,
8861
9053
  ValidateHasNeighborAfter,
@@ -8920,9 +9112,132 @@ const _ImageArtKeywordToOther = class _ImageArtKeywordToOther extends Rule {
8920
9112
  };
8921
9113
  _ImageArtKeywordToOther.priority = POST_PROCESS;
8922
9114
  let ImageArtKeywordToOther = _ImageArtKeywordToOther;
8923
- function completeWords(rebulk, seasonWords, completeArticleWords) {
8924
- const seasonWordsPattern = buildOrPattern(seasonWords);
8925
- const completeArticleWordsPattern = buildOrPattern(completeArticleWords);
9115
+ const CREDITS_NUMBER = `(?P<credits_number>\\d+(?:(?![vV]\\d)[^\\W\\d_])?)?`;
9116
+ const CREDITS_VERSION = `(?:-?[vV](?P<version>\\d+))?`;
9117
+ const CREDITS_SUFFIX = CREDITS_NUMBER + CREDITS_VERSION;
9118
+ function formatCreditsNumber(value) {
9119
+ const m = /^(\d+)(\w?)$/.exec(value);
9120
+ if (!m) return value;
9121
+ return String(parseInt(m[1], 10)) + m[2].toLowerCase();
9122
+ }
9123
+ function openingEndingCredits(rebulk) {
9124
+ const add = (pattern, value, ignoreCase) => {
9125
+ rebulk.regex(
9126
+ `(?P<other>` + pattern + `)` + CREDITS_SUFFIX,
9127
+ {
9128
+ flags: ignoreCase ? "i" : "",
9129
+ name: "other",
9130
+ children: true,
9131
+ privateParent: true,
9132
+ validateAll: true,
9133
+ validator: { __parent__: sepsSurround },
9134
+ formatter: {
9135
+ other: () => value,
9136
+ credits_number: formatCreditsNumber,
9137
+ version: (v) => parseInt(v, 10)
9138
+ },
9139
+ disabled: (context) => isDisabled(context, "other")
9140
+ }
9141
+ );
9142
+ };
9143
+ add(`NC-?OP|creditless-?op(?:ening)?`, "Opening Credits", true);
9144
+ add(`NC-?ED|creditless-?(?:ed|ending)`, "Ending Credits", true);
9145
+ add(`OPED|OP`, "Opening Credits", false);
9146
+ add(`ED`, "Ending Credits", false);
9147
+ }
9148
+ const _AppendCreditless = class _AppendCreditless extends Rule {
9149
+ constructor() {
9150
+ super(...arguments);
9151
+ this.priority = POST_PROCESS;
9152
+ this.consequence = AppendMatch;
9153
+ }
9154
+ when(matches, _context) {
9155
+ const toAppend = [];
9156
+ for (const match of matches.named("other", (m) => m.value === "Opening Credits" || m.value === "Ending Credits") ?? []) {
9157
+ const raw = (match.raw ?? "").toLowerCase().replace(/[\s._-]+/g, "");
9158
+ if (raw.startsWith("nc") || raw.includes("creditless")) {
9159
+ toAppend.push(new Match(match.start, match.end, {
9160
+ name: "other",
9161
+ value: "Creditless",
9162
+ inputString: matches.inputString
9163
+ }));
9164
+ }
9165
+ }
9166
+ return toAppend.length ? toAppend : false;
9167
+ }
9168
+ };
9169
+ _AppendCreditless.priority = POST_PROCESS;
9170
+ _AppendCreditless.properties = { other: ["Creditless"] };
9171
+ let AppendCreditless = _AppendCreditless;
9172
+ const _AppendOpedEndingCredits = class _AppendOpedEndingCredits extends Rule {
9173
+ constructor() {
9174
+ super(...arguments);
9175
+ this.priority = POST_PROCESS;
9176
+ this.consequence = AppendMatch;
9177
+ }
9178
+ when(matches, _context) {
9179
+ const toAppend = [];
9180
+ for (const match of matches.named("other", (m) => m.value === "Opening Credits") ?? []) {
9181
+ if ((match.raw ?? "").toLowerCase().replace(/[\s._-]+/g, "") === "oped") {
9182
+ toAppend.push(new Match(match.start, match.end, {
9183
+ name: "other",
9184
+ value: "Ending Credits",
9185
+ inputString: matches.inputString
9186
+ }));
9187
+ }
9188
+ }
9189
+ return toAppend.length ? toAppend : false;
9190
+ }
9191
+ };
9192
+ _AppendOpedEndingCredits.priority = POST_PROCESS;
9193
+ _AppendOpedEndingCredits.properties = { other: ["Ending Credits"] };
9194
+ let AppendOpedEndingCredits = _AppendOpedEndingCredits;
9195
+ const STEREO_VR_CONTEXT_TAG = "stereo-vr-context";
9196
+ const VR_CONTEXT_VALUES = /* @__PURE__ */ new Set(["Virtual Reality", "3D"]);
9197
+ const _ValidateStereoVRContext = class _ValidateStereoVRContext extends Rule {
9198
+ constructor() {
9199
+ super(...arguments);
9200
+ this.priority = 64;
9201
+ this.consequence = RemoveMatch;
9202
+ }
9203
+ when(matches, _context) {
9204
+ const toRemove = [];
9205
+ const fileparts = matches.markers.named("path");
9206
+ for (const filepart of Array.isArray(fileparts) ? fileparts : fileparts ? [fileparts] : []) {
9207
+ const gated = matches.range(
9208
+ filepart.start,
9209
+ filepart.end,
9210
+ (m) => m.name === "other" && m.tags.includes(STEREO_VR_CONTEXT_TAG)
9211
+ );
9212
+ if (!gated?.length) continue;
9213
+ const hasVrContext = matches.range(
9214
+ filepart.start,
9215
+ filepart.end,
9216
+ (m) => m.name === "other" && VR_CONTEXT_VALUES.has(String(m.value))
9217
+ )?.length > 0;
9218
+ if (hasVrContext) {
9219
+ for (const stereo of gated) {
9220
+ toRemove.push(...matches.range(
9221
+ stereo.start,
9222
+ stereo.end,
9223
+ (m) => m.name === "streaming_service"
9224
+ ) ?? []);
9225
+ }
9226
+ } else {
9227
+ toRemove.push(...gated);
9228
+ }
9229
+ }
9230
+ return toRemove.length ? toRemove : false;
9231
+ }
9232
+ };
9233
+ _ValidateStereoVRContext.priority = 64;
9234
+ let ValidateStereoVRContext = _ValidateStereoVRContext;
9235
+ const TOKEN_START = `(?<![^\\W_])`;
9236
+ function completeWords(rebulk, opts) {
9237
+ const completeMarkerPattern = buildOrPattern(opts.completeMarkerWords);
9238
+ const seasonWordsPattern = buildOrPattern(opts.seasonWords);
9239
+ const completeArticleWordsPattern = buildOrPattern(opts.completeArticleWords);
9240
+ const seasonNumbersPattern = `(?:-+(?:\\d+|` + buildOrPattern(opts.seasonNumberSeparators, void 0, true) + `))+-+`;
8926
9241
  function validateComplete(match) {
8927
9242
  const children = match.children;
8928
9243
  if (!children.named("completeWordsBefore") && !children.named("completeWordsAfter")) {
@@ -8931,7 +9246,7 @@ function completeWords(rebulk, seasonWords, completeArticleWords) {
8931
9246
  return true;
8932
9247
  }
8933
9248
  rebulk.regex(
8934
- `(?P<completeArticle>${completeArticleWordsPattern}-)?(?P<completeWordsBefore>${seasonWordsPattern}-)?Complete(?P<completeWordsAfter>-${seasonWordsPattern})?`,
9249
+ TOKEN_START + `(?P<completeArticle>${completeArticleWordsPattern}-)?(?P<completeWordsBefore>${seasonWordsPattern}-)?` + completeMarkerPattern + `(?P<completeWordsAfter>-${seasonWordsPattern})?`,
8935
9250
  {
8936
9251
  privateNames: ["completeArticle", "completeWordsBefore", "completeWordsAfter"],
8937
9252
  value: { other: "Complete" },
@@ -8941,6 +9256,26 @@ function completeWords(rebulk, seasonWords, completeArticleWords) {
8941
9256
  }
8942
9257
  }
8943
9258
  );
9259
+ rebulk.regex(
9260
+ seasonWordsPattern + seasonNumbersPattern + `(?P<other>` + completeMarkerPattern + `)`,
9261
+ {
9262
+ children: true,
9263
+ privateParent: true,
9264
+ validateAll: true,
9265
+ value: { other: "Complete" },
9266
+ tags: ["release-group-prefix"],
9267
+ validator: { __parent__: sepsSurround }
9268
+ }
9269
+ );
9270
+ rebulk.regex(
9271
+ TOKEN_START + `(?P<completePrefix>` + buildOrPattern(opts.completePrefixWords) + `-?)` + completeMarkerPattern,
9272
+ {
9273
+ privateNames: ["completePrefix"],
9274
+ value: { other: "Complete" },
9275
+ tags: ["release-group-prefix"],
9276
+ validator: { __parent__: sepsSurround }
9277
+ }
9278
+ );
8944
9279
  }
8945
9280
  const _ProperCountRule = class _ProperCountRule extends Rule {
8946
9281
  when(matches, context) {
@@ -9234,10 +9569,20 @@ const _RemoveTitleCaseAmbiguous = class _RemoveTitleCaseAmbiguous extends Rule {
9234
9569
  // lowercase scene spellings are unaffected; only the Title-Case word is removed.
9235
9570
  when(matches) {
9236
9571
  const TITLE_WORDS = /* @__PURE__ */ new Set(["Real", "Cam", "Convert"]);
9572
+ const RELEASE_META = /* @__PURE__ */ new Set(["screen_size", "video_codec", "audio_codec", "video_profile", "release_group"]);
9237
9573
  const ret = [];
9238
9574
  for (const m of matches.range(0, matches.inputString?.length ?? 0)) {
9239
9575
  if (m.name !== "other" && m.name !== "source") continue;
9240
- if (TITLE_WORDS.has(m.raw ?? "")) ret.push(m);
9576
+ if (!TITLE_WORDS.has(m.raw ?? "")) continue;
9577
+ const filepart = matches.markers.atMatch(m, (marker) => marker.name === "path", 0);
9578
+ const searchEnd = filepart?.end ?? (matches.inputString?.length ?? m.end);
9579
+ const metaAfter = matches.range(
9580
+ m.end,
9581
+ searchEnd,
9582
+ (o) => !o.private && RELEASE_META.has(o.name ?? "")
9583
+ ) ?? [];
9584
+ if (metaAfter.length > 0) continue;
9585
+ ret.push(m);
9241
9586
  }
9242
9587
  return ret.length ? ret : false;
9243
9588
  }
@@ -9900,6 +10245,13 @@ const _TypeProcessor = class _TypeProcessor extends Rule {
9900
10245
  return "episode";
9901
10246
  }
9902
10247
  }
10248
+ const completeSeries = matches.named(
10249
+ "other",
10250
+ (m) => m.value === "Complete" && !!(m.children?.named?.("completeWordsBefore")?.length || m.children?.named?.("completeWordsAfter")?.length)
10251
+ );
10252
+ if (completeSeries && (Array.isArray(completeSeries) ? completeSeries.length > 0 : true)) {
10253
+ return "episode";
10254
+ }
9903
10255
  const film2 = matches.named("film");
9904
10256
  if (film2 && (Array.isArray(film2) ? film2.length > 0 : true)) {
9905
10257
  return "movie";
@@ -9924,6 +10276,10 @@ const _TypeProcessor = class _TypeProcessor extends Rule {
9924
10276
  if (crc32 && (Array.isArray(crc32) ? crc32.length > 0 : true) && animeReleaseGroup && (Array.isArray(animeReleaseGroup) ? animeReleaseGroup.length > 0 : true)) {
9925
10277
  return "episode";
9926
10278
  }
10279
+ const complete = matches.named("other", (m) => m.value === "Complete");
10280
+ if (complete && (Array.isArray(complete) ? complete.length > 0 : true) && (!year || (Array.isArray(year) ? year.length === 0 : false))) {
10281
+ return "episode";
10282
+ }
9927
10283
  return "movie";
9928
10284
  }
9929
10285
  then(matches, whenResponse, _context) {
@@ -10265,9 +10621,13 @@ function rebulkBuilder(config) {
10265
10621
  rebulk.rebulk(streamingService(cfg("streaming_service")));
10266
10622
  const otherRebulk = other(cfg("other"));
10267
10623
  cfg("episodes");
10268
- const completeSeasonWords = ["seasons?", "series?"];
10269
- const completeArticleWords = ["The"];
10270
- completeWords(otherRebulk, completeSeasonWords, completeArticleWords);
10624
+ completeWords(otherRebulk, {
10625
+ completeMarkerWords: ["Complete", "Int[ée]grale"],
10626
+ seasonWords: ["seasons?", "mini-?series?", "series?"],
10627
+ completeArticleWords: ["The"],
10628
+ completePrefixWords: ["L['’]?", "Coffret"],
10629
+ seasonNumberSeparators: ["&", "and"]
10630
+ });
10271
10631
  rebulk.rebulk(otherRebulk);
10272
10632
  rebulk.rebulk(size(cfg("size")));
10273
10633
  rebulk.rebulk(bitRate(cfg("bit_rate")));
@@ -10406,7 +10766,10 @@ const advanced_config = {
10406
10766
  "True-?HD"
10407
10767
  ]
10408
10768
  },
10409
- Opus: "Opus",
10769
+ Opus: {
10770
+ string: "Opus",
10771
+ tags: "title-word"
10772
+ },
10410
10773
  Vorbis: "Vorbis",
10411
10774
  PCM: "PCM",
10412
10775
  LPCM: "LPCM"
@@ -10910,27 +11273,104 @@ const advanced_config = {
10910
11273
  "saisons",
10911
11274
  "tem",
10912
11275
  "temp",
10913
- "temporada",
10914
- "temporadas",
10915
- "stagione"
11276
+ {
11277
+ value: "temporada",
11278
+ numfirst: true
11279
+ },
11280
+ {
11281
+ value: "temporadas",
11282
+ numfirst: true
11283
+ },
11284
+ "stagione",
11285
+ {
11286
+ value: "сезон",
11287
+ numfirst: true
11288
+ },
11289
+ {
11290
+ value: "sezon",
11291
+ numfirst: true
11292
+ },
11293
+ {
11294
+ value: "staffel",
11295
+ numfirst: true
11296
+ },
11297
+ "sezonul",
11298
+ "säsong",
11299
+ "sesong",
11300
+ "sæson",
11301
+ {
11302
+ value: "évad",
11303
+ numfirst: true
11304
+ }
10916
11305
  ],
10917
11306
  episode_words: [
10918
11307
  "episode",
10919
11308
  "episodes",
11309
+ "épisode",
11310
+ "épisodes",
10920
11311
  "eps",
10921
11312
  "ep",
10922
11313
  "episodio",
10923
11314
  "episodios",
10924
11315
  "capitulo",
10925
- "capitulos"
11316
+ "capitulos",
11317
+ {
11318
+ value: "серия",
11319
+ numfirst: true
11320
+ },
11321
+ {
11322
+ value: "серии",
11323
+ numfirst: true
11324
+ },
11325
+ {
11326
+ value: "эпизод",
11327
+ numfirst: true
11328
+ },
11329
+ {
11330
+ value: "seria",
11331
+ numfirst: true
11332
+ },
11333
+ {
11334
+ value: "serii",
11335
+ numfirst: true
11336
+ },
11337
+ {
11338
+ value: "serija",
11339
+ numfirst: true
11340
+ },
11341
+ {
11342
+ value: "bölüm",
11343
+ numfirst: true
11344
+ },
11345
+ {
11346
+ value: "bolum",
11347
+ numfirst: true
11348
+ },
11349
+ "aflevering",
11350
+ "afl",
11351
+ "folge",
11352
+ "odcinek",
11353
+ "episodul",
11354
+ "avsnitt",
11355
+ {
11356
+ value: "rész",
11357
+ numfirst: true
11358
+ }
10926
11359
  ],
10927
11360
  of_words: [
10928
11361
  "of",
10929
- "sur"
11362
+ "sur",
11363
+ "de",
11364
+ "di",
11365
+ "von",
11366
+ "van",
11367
+ "din",
11368
+ "из"
10930
11369
  ],
10931
11370
  all_words: [
10932
11371
  "All"
10933
- ]
11372
+ ],
11373
+ ordinal_suffix: "(?:ª|º|°|a|o|-?(?:й|я|е|го|ая|ый|ое))?"
10934
11374
  },
10935
11375
  film: {
10936
11376
  film: {
@@ -11237,52 +11677,14 @@ const advanced_config = {
11237
11677
  },
11238
11678
  "Virtual Reality": {
11239
11679
  string: [
11240
- "VR"
11680
+ "VR",
11681
+ "EAC360"
11241
11682
  ],
11242
11683
  regex: [
11243
11684
  "VR180",
11244
- "VR360"
11245
- ],
11246
- tags: "has-neighbor"
11247
- },
11248
- "Opening Credits": {
11249
- string: [
11250
- "NCOP",
11251
- "OPED"
11252
- ],
11253
- regex: [
11254
- "NC-?OP",
11255
- "creditless-?opening"
11256
- ],
11257
- tags: "has-neighbor"
11258
- },
11259
- "Ending Credits": {
11260
- string: [
11261
- "NCED"
11262
- ],
11263
- regex: [
11264
- "NC-?ED",
11265
- "creditless-?ending"
11266
- ],
11267
- tags: "has-neighbor"
11268
- },
11269
- "Half SBS": {
11270
- string: [
11271
- "HSBS"
11272
- ],
11273
- regex: [
11274
- "Half-?SBS"
11275
- ],
11276
- tags: "has-neighbor"
11277
- },
11278
- "Half OU": {
11279
- string: [
11280
- "HOU",
11281
- "HTAB"
11282
- ],
11283
- regex: [
11284
- "Half-?OU",
11285
- "Half-?TAB"
11685
+ "VR360",
11686
+ "VR-180",
11687
+ "VR-360"
11286
11688
  ],
11287
11689
  tags: "has-neighbor"
11288
11690
  },
@@ -11472,7 +11874,7 @@ const advanced_config = {
11472
11874
  tags: "uhdbluray-neighbor"
11473
11875
  },
11474
11876
  "Dolby Vision": {
11475
- regex: "(?:Dolby-?Vision|DV)",
11877
+ regex: "(?:Dolby-?Vision|DoVi|DV)",
11476
11878
  tags: "uhdbluray-neighbor"
11477
11879
  },
11478
11880
  "BT.2020": {
@@ -11529,6 +11931,48 @@ const advanced_config = {
11529
11931
  complete_article_words: [
11530
11932
  "The"
11531
11933
  ]
11934
+ },
11935
+ "Side By Side": {
11936
+ string: [
11937
+ "SBS",
11938
+ "LR"
11939
+ ],
11940
+ tags: [
11941
+ "has-neighbor",
11942
+ "stereo-vr-context"
11943
+ ]
11944
+ },
11945
+ "Over Under": {
11946
+ string: [
11947
+ "TB",
11948
+ "OU"
11949
+ ],
11950
+ tags: [
11951
+ "has-neighbor",
11952
+ "stereo-vr-context"
11953
+ ]
11954
+ },
11955
+ "Half Side By Side": {
11956
+ string: [
11957
+ "HSBS"
11958
+ ],
11959
+ regex: [
11960
+ "h-?sbs",
11961
+ "half-?sbs"
11962
+ ],
11963
+ tags: "has-neighbor"
11964
+ },
11965
+ "Half Over Under": {
11966
+ string: [
11967
+ "HOU",
11968
+ "HTAB"
11969
+ ],
11970
+ regex: [
11971
+ "h-?ou",
11972
+ "half-?ou",
11973
+ "half-?tab"
11974
+ ],
11975
+ tags: "has-neighbor"
11532
11976
  }
11533
11977
  }
11534
11978
  },
@@ -12333,7 +12777,6 @@ const GUESSIT_SCHEMA = {
12333
12777
  "Dual",
12334
12778
  "Dual Audio",
12335
12779
  "East Coast Feed",
12336
- "Ending Credits",
12337
12780
  "Extras",
12338
12781
  "Fan Subtitled",
12339
12782
  "Fanart",
@@ -12344,8 +12787,8 @@ const GUESSIT_SCHEMA = {
12344
12787
  "Fix",
12345
12788
  "Fixed",
12346
12789
  "Full HD",
12347
- "Half OU",
12348
- "Half SBS",
12790
+ "Half Over Under",
12791
+ "Half Side By Side",
12349
12792
  "Hardcoded Subtitles",
12350
12793
  "HC",
12351
12794
  "HD",
@@ -12380,7 +12823,6 @@ const GUESSIT_SCHEMA = {
12380
12823
  "Obfuscated",
12381
12824
  "Ona",
12382
12825
  "Open Matte",
12383
- "Opening Credits",
12384
12826
  "Original Animated Video",
12385
12827
  "Original Animation DVD",
12386
12828
  "Original Aspect Ratio",
@@ -12388,6 +12830,7 @@ const GUESSIT_SCHEMA = {
12388
12830
  "Original Video",
12389
12831
  "OV",
12390
12832
  "Ova",
12833
+ "Over Under",
12391
12834
  "PAL",
12392
12835
  "postbot",
12393
12836
  "Poster",
@@ -12412,6 +12855,7 @@ const GUESSIT_SCHEMA = {
12412
12855
  "Screener",
12413
12856
  "SDR",
12414
12857
  "SECAM",
12858
+ "Side By Side",
12415
12859
  "Standard Dynamic Range",
12416
12860
  "Straight to Video",
12417
12861
  "STV",
@@ -12517,6 +12961,7 @@ const GUESSIT_SCHEMA = {
12517
12961
  "HD Telesync",
12518
12962
  "HD-DVD",
12519
12963
  "HDTV",
12964
+ "Laserdisc",
12520
12965
  "Pay-per-view",
12521
12966
  "Satellite",
12522
12967
  "Telecine",