guessit-js 4.0.2 → 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.
@@ -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) {
@@ -3269,6 +3306,37 @@ function seasonEpisodeConflictSolver(match, other2) {
3269
3306
  }
3270
3307
  }
3271
3308
  if (["season", "episode"].includes(match.name) && ["season", "episode"].includes(other2.name) && match.initiator !== other2.initiator) {
3309
+ const isWeak = (m) => !!(m.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(m.initiator?.name));
3310
+ const matchNumfirst = !!match.tags?.includes("numfirst");
3311
+ const otherNumfirst = !!other2.tags?.includes("numfirst");
3312
+ if (matchNumfirst !== otherNumfirst && !isWeak(match) && !isWeak(other2) && match.start < other2.end && other2.start < match.end) {
3313
+ const nf = matchNumfirst ? match : other2;
3314
+ const wf = matchNumfirst ? other2 : match;
3315
+ const input = match.inputString ?? "";
3316
+ const digitToken = (from, dir) => {
3317
+ let i = from;
3318
+ while (i >= 0 && i < input.length && seps.includes(input[i])) i += dir;
3319
+ let tok = "";
3320
+ while (i >= 0 && i < input.length && /\d/.test(input[i])) {
3321
+ tok = dir === 1 ? tok + input[i] : input[i] + tok;
3322
+ i += dir;
3323
+ }
3324
+ return tok;
3325
+ };
3326
+ const isYearLike = (t) => t.length === 4 && +t >= 1900 && +t <= 2100;
3327
+ const nfInit = nf.initiator ?? nf;
3328
+ const wfInit = wf.initiator ?? wf;
3329
+ const nfDangling = (() => {
3330
+ const t = digitToken(nfInit.end, 1);
3331
+ return t.length >= 1 && t.length <= 4 && !isYearLike(t);
3332
+ })();
3333
+ const wfDangling = (() => {
3334
+ const t = digitToken(wfInit.start - 1, -1);
3335
+ return t.length >= 1 && t.length <= 3 && !isYearLike(t);
3336
+ })();
3337
+ if (wfDangling && !nfDangling) return wf;
3338
+ return nf;
3339
+ }
3272
3340
  const matchIsWeak = !!(match.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(match.initiator?.name));
3273
3341
  const otherIsWeak = !!(other2.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(other2.initiator?.name));
3274
3342
  if (matchIsWeak && otherIsWeak) {
@@ -3372,15 +3440,16 @@ function episodes(config) {
3372
3440
  }
3373
3441
  const rebulk = new Rebulk().regexDefaults({ flags: "i" }).stringDefaults({ ignoreCase: true }).defaults({
3374
3442
  privateNames: ["episodeSeparator", "seasonSeparator", "episodeMarker", "seasonMarker"],
3375
- formatter: { season: (v) => parseInt(v, 10), episode: (v) => parseInt(v, 10), version: (v) => parseInt(v, 10) },
3443
+ formatter: { season: (v) => parseInt(v, 10), episode: (v) => parseInt(v, 10), version: (v) => parseInt(v, 10), count: (v) => parseInt(v, 10) },
3376
3444
  children: true,
3377
3445
  privateParent: true,
3378
3446
  conflictSolver: seasonEpisodeConflictSolver,
3379
3447
  abbreviations: [altDash]
3380
3448
  });
3381
- rebulk.regex("第(?<episode>\\d{1,4})話", { tags: ["SxxExx"] });
3382
- rebulk.regex("(?:シーズン|シリーズ)(?<season>\\d{1,2})", { tags: ["SxxExx"] });
3383
- rebulk.regex("(?<season>\\d{1,2})期", {});
3449
+ rebulk.regex(`第(?<episode>${CJK_NUMBER})[話话集]`, { tags: ["SxxExx"], formatter: { episode: parseCjkNumber } });
3450
+ rebulk.regex(`第(?<season>${CJK_NUMBER})季`, { tags: ["SxxExx"], formatter: { season: parseCjkNumber } });
3451
+ rebulk.regex("(?:シーズン|シリーズ)(?<season>\\d{1,2})(?!\\d)", { tags: ["SxxExx"] });
3452
+ rebulk.regex("(?<!\\d)(?<season>\\d{1,2})期", {});
3384
3453
  const seasonMarkerPattern = buildOrPattern(config.season_markers, "seasonMarker");
3385
3454
  const episodeMarkerPattern = buildOrPattern(
3386
3455
  [...config.episode_markers, ...config.disc_markers],
@@ -3405,6 +3474,7 @@ function episodes(config) {
3405
3474
  allSeparatorsPattern + `@?(?<episode>\\d+)`
3406
3475
  ).repeater("*");
3407
3476
  const seasonEpMarkerPattern = buildOrPattern(config.season_ep_markers, "episodeMarker");
3477
+ const asymmetricSeasonEpMarker = `(?!@` + buildOrPattern(config.season_ep_markers) + `\\d)`;
3408
3478
  rebulk.chain({
3409
3479
  tags: ["SxxExx"],
3410
3480
  validateAll: true,
@@ -3413,7 +3483,7 @@ function episodes(config) {
3413
3483
  },
3414
3484
  disabled: isSeasonEpisodeDisabled
3415
3485
  }).defaults({ tags: ["SxxExx"] }).regex(
3416
- `(?<season>\\d+)@?` + seasonEpMarkerPattern + `@?(?<episode>\\d+)`
3486
+ `(?<season>\\d+)` + asymmetricSeasonEpMarker + `@?` + seasonEpMarkerPattern + `@?(?<episode>\\d+)`
3417
3487
  ).repeater("+");
3418
3488
  rebulk.chain({
3419
3489
  tags: ["SxxExx"],
@@ -3422,13 +3492,17 @@ function episodes(config) {
3422
3492
  __parent__: and_(sepsSurround, orderingValidator)
3423
3493
  },
3424
3494
  disabled: isSeasonEpisodeDisabled
3425
- }).defaults({ tags: ["SxxExx"] }).regex(`(?<season>\\d+)@?` + seasonEpMarkerPattern + `@?(?<episode>\\d+)`).regex(
3495
+ }).defaults({ tags: ["SxxExx"] }).regex(`(?<season>\\d+)` + asymmetricSeasonEpMarker + `@?` + seasonEpMarkerPattern + `@?(?<episode>\\d+)`).regex(
3426
3496
  buildOrPattern(
3427
3497
  [...config.season_ep_markers, ...discreteSeparators, ...config.range_separators],
3428
3498
  "episodeSeparator",
3429
3499
  true
3430
3500
  ) + `(?<episode>\\d+)`
3431
3501
  ).repeater("*");
3502
+ rebulk.regex(
3503
+ `t(?<season>\\d{1,2})@?` + buildOrPattern(config.episode_markers, "episodeMarker") + `@?(?<episode>\\d{1,4})`,
3504
+ { tags: ["SxxExx"], disabled: isSeasonEpisodeDisabled }
3505
+ );
3432
3506
  const seasonOnlySepPattern = buildOrPattern(
3433
3507
  [...config.season_markers, ...discreteSeparators, ...config.range_separators],
3434
3508
  "seasonSeparator",
@@ -3451,7 +3525,9 @@ function episodes(config) {
3451
3525
  disabled: (context) => isDisabled(context, "episode_details")
3452
3526
  });
3453
3527
  }
3454
- const seasonWordPattern = buildOrPattern(config.season_words, "seasonMarker");
3528
+ const { words: seasonWords, numfirst: seasonWordsNumfirst } = splitWords(config.season_words);
3529
+ const { words: episodeWords, numfirst: episodeWordsNumfirst } = splitWords(config.episode_words);
3530
+ const seasonWordPattern = buildOrPattern(seasonWords, "seasonMarker");
3455
3531
  const ofWordPattern = buildOrPattern(config.of_words);
3456
3532
  rebulk.chain({
3457
3533
  validateAll: true,
@@ -3475,7 +3551,28 @@ function episodes(config) {
3475
3551
  true
3476
3552
  ) + `@?(?P<season>\\d+)`
3477
3553
  ).repeater("*");
3478
- const episodeWordPattern = buildOrPattern(config.episode_words, "episodeMarker");
3554
+ const ofCountPattern = `(?:@?` + ofWordPattern + `@?(?<count>\\d+))?`;
3555
+ if (seasonWordsNumfirst.length > 0) {
3556
+ rebulk.regex(
3557
+ `(?<season>\\d{1,2})` + config.ordinal_suffix + `@?@?` + buildOrPattern(seasonWordsNumfirst, "seasonMarker") + `(?![^\\W\\d_])` + ofCountPattern,
3558
+ {
3559
+ tags: ["SxxExx", "numfirst"],
3560
+ formatter: { season: parseNumber, count: (v) => parseInt(v, 10) },
3561
+ disabled: isSeasonEpisodeDisabled
3562
+ }
3563
+ );
3564
+ }
3565
+ if (episodeWordsNumfirst.length > 0) {
3566
+ rebulk.regex(
3567
+ `(?<episode>\\d{1,3})` + config.ordinal_suffix + `@?@?` + buildOrPattern(episodeWordsNumfirst, "episodeMarker") + `(?![^\\W\\d_])` + ofCountPattern,
3568
+ {
3569
+ tags: ["SxxExx", "numfirst"],
3570
+ formatter: { episode: parseNumber, count: (v) => parseInt(v, 10) },
3571
+ disabled: (context) => isDisabled(context, "episode")
3572
+ }
3573
+ );
3574
+ }
3575
+ const episodeWordPattern = buildOrPattern(episodeWords, "episodeMarker");
3479
3576
  rebulk.regex(
3480
3577
  `(?<![a-zA-Z\\d])` + episodeWordPattern + `@?(?<episode>\\d+)(?:v(?<version>\\d+))?(?:@?` + ofWordPattern + `@?(?<count>\\d+))?`,
3481
3578
  {
@@ -3561,9 +3658,11 @@ function episodes(config) {
3561
3658
  disabled: (context) => isDisabled(context, "version")
3562
3659
  });
3563
3660
  rebulk.regex(
3564
- `(?<episode>\\d+)@?` + ofWordPattern + `@?(?<episode_count>\\d+)@?` + episodeWordPattern + "?",
3661
+ // The lookbehind keeps this off token tails: "AC3-de[42]" is not "episode 3 of 42"
3662
+ // ('de' is also a Spanish of-word — codec suffixes must stay intact).
3663
+ `(?<![^\\W_])(?<episode>\\d+)@?` + ofWordPattern + `@?(?<count>\\d+)@?` + episodeWordPattern + "?",
3565
3664
  {
3566
- formatter: { episode: (v) => parseInt(v, 10), episode_count: (v) => parseInt(v, 10) },
3665
+ formatter: { episode: (v) => parseInt(v, 10), count: (v) => parseInt(v, 10) },
3567
3666
  preMatchProcessor: (match) => {
3568
3667
  match.value = cleanup(match.value);
3569
3668
  return match;
@@ -3579,6 +3678,8 @@ function episodes(config) {
3579
3678
  disabled: (context) => isDisabled(context, "episode_format")
3580
3679
  });
3581
3680
  rebulk.rules(
3681
+ RemoveNumfirstMarkerCollision,
3682
+ CountValidator,
3582
3683
  new DiscMarkerRule(config),
3583
3684
  FixCorruptedGroupBoundaryValues,
3584
3685
  new RangeExpansionRule(config),
@@ -3592,6 +3693,67 @@ function episodes(config) {
3592
3693
  );
3593
3694
  return rebulk;
3594
3695
  }
3696
+ const _RemoveNumfirstMarkerCollision = class _RemoveNumfirstMarkerCollision extends Rule {
3697
+ constructor() {
3698
+ super(...arguments);
3699
+ this.priority = 70;
3700
+ this.consequence = RemoveMatch;
3701
+ }
3702
+ when(matches, _context) {
3703
+ const toRemove = [];
3704
+ const isWeak = (m) => !!(m.tags?.includes("weak-episode") || ["weak_episode", "weak_duplicate"].includes(m.initiator?.name));
3705
+ const numfirsts = (matches.matches ?? []).filter((m) => (m.name === "season" || m.name === "episode") && m.tags?.includes("numfirst"));
3706
+ for (const nf of numfirsts) {
3707
+ const nfInit = nf.initiator ?? nf;
3708
+ const collides = (matches.matches ?? []).some((w) => {
3709
+ if (w.name !== "season" && w.name !== "episode") return false;
3710
+ if (w.tags?.includes("numfirst") || isWeak(w)) return false;
3711
+ const wInit = w.initiator ?? w;
3712
+ if (wInit === nfInit) return false;
3713
+ return wInit.start < nfInit.end && nfInit.start < wInit.end;
3714
+ });
3715
+ if (collides) {
3716
+ toRemove.push(nf);
3717
+ for (const child of nfInit.children ?? []) {
3718
+ if (child !== nf && !toRemove.includes(child)) toRemove.push(child);
3719
+ }
3720
+ }
3721
+ }
3722
+ return toRemove.length ? toRemove : false;
3723
+ }
3724
+ };
3725
+ _RemoveNumfirstMarkerCollision.priority = 70;
3726
+ let RemoveNumfirstMarkerCollision = _RemoveNumfirstMarkerCollision;
3727
+ const _CountValidator = class _CountValidator extends Rule {
3728
+ constructor() {
3729
+ super(...arguments);
3730
+ this.priority = 64;
3731
+ this.consequence = [RemoveMatch, new RenameMatch("episode_count"), new RenameMatch("season_count")];
3732
+ }
3733
+ when(matches, _context) {
3734
+ const toRemove = [];
3735
+ const episodeCount = [];
3736
+ const seasonCount = [];
3737
+ for (const count of matches.named("count") ?? []) {
3738
+ const numbers = matches.range(
3739
+ count.initiator.start,
3740
+ count.start,
3741
+ (m) => m.name === "episode" || m.name === "season"
3742
+ );
3743
+ const numbered = numbers.length ? numbers[numbers.length - 1] : void 0;
3744
+ if (!numbered) toRemove.push(count);
3745
+ else if (numbered.name === "episode") episodeCount.push(count);
3746
+ else seasonCount.push(count);
3747
+ }
3748
+ if (toRemove.length || episodeCount.length || seasonCount.length) {
3749
+ return [toRemove, episodeCount, seasonCount];
3750
+ }
3751
+ return false;
3752
+ }
3753
+ };
3754
+ _CountValidator.priority = 64;
3755
+ _CountValidator.consequence = [RemoveMatch, new RenameMatch("episode_count"), new RenameMatch("season_count")];
3756
+ let CountValidator = _CountValidator;
3595
3757
  const _DiscMarkerRule = class _DiscMarkerRule extends Rule {
3596
3758
  constructor(config) {
3597
3759
  super();
@@ -4197,6 +4359,14 @@ function source(config) {
4197
4359
  ...buildSourcePattern(["DVD"], "", optional(ripSuffix)),
4198
4360
  { value: { source: "DVD", other: "Rip" } }
4199
4361
  );
4362
+ rebulk.regex(
4363
+ ...buildSourcePattern(["LD"], "", ripSuffix),
4364
+ { value: { source: "Laserdisc", other: "Rip" } }
4365
+ );
4366
+ rebulk.regex(
4367
+ ...buildSourcePattern(["LASERDISC"], "", optional(ripSuffix)),
4368
+ { value: { source: "Laserdisc", other: "Rip" } }
4369
+ );
4200
4370
  rebulk.regex(
4201
4371
  ...buildSourcePattern(["DM"], "", optional(ripSuffix)),
4202
4372
  { value: { source: "Digital Master", other: "Rip" } }
@@ -5017,7 +5187,8 @@ function screenSize(config) {
5017
5187
  const frameRatePattern = buildOrPattern(frameRates, "frame_rate");
5018
5188
  const interlacedPattern = buildOrPattern([...interlaced], "height");
5019
5189
  const progressivePattern = buildOrPattern([...progressive], "height");
5020
- const resPattern = `(?:(?<width>\\d{3,4})(?:x|\\*))?`;
5190
+ const resSeparator = `(?:x|\\*|×)`;
5191
+ const resPattern = `(?:(?<width>\\d{3,4})${resSeparator})?`;
5021
5192
  rebulk.regex(resPattern + interlacedPattern + `(?<scan_type>i)` + frameRatePattern + `?`);
5022
5193
  rebulk.regex(resPattern + progressivePattern + `(?<scan_type>p)` + frameRatePattern + `?`);
5023
5194
  rebulk.regex(resPattern + progressivePattern + `(?<scan_type>p)?(?:hd)`);
@@ -5026,7 +5197,7 @@ function screenSize(config) {
5026
5197
  value: "2160p",
5027
5198
  conflictSolver: (match, other2) => other2.name === "screen_size" ? "__default__" : match
5028
5199
  });
5029
- rebulk.regex(`(?<width>\\d{3,4})-?(?:x|\\*)-?(?<height>\\d{3,4})`, {
5200
+ rebulk.regex(`(?<width>\\d{3,4})(?:${resSeparator}|-${resSeparator}-)(?<height>\\d{3,4})(?:up)?`, {
5030
5201
  conflictSolver: (match, other2) => other2.name === "screen_size" ? "__default__" : other2
5031
5202
  });
5032
5203
  rebulk.regex(frameRatePattern + `-?(?:p|fps)`, {
@@ -5060,7 +5231,7 @@ const _PostProcessScreenSize = class _PostProcessScreenSize extends Rule {
5060
5231
  let values = match.children.toDict();
5061
5232
  if (!("height" in values)) {
5062
5233
  const raw = String(match.raw ?? "");
5063
- const rxWxH = /^(\d{3,4})\s*[xX*]\s*(\d{3,4})$/i;
5234
+ const rxWxH = /^(\d{3,4})\s*[xX*×]\s*(\d{3,4})(?:up)?$/i;
5064
5235
  const mWxH = rxWxH.exec(raw);
5065
5236
  if (mWxH) {
5066
5237
  values = { width: mWxH[1], height: mWxH[2], scan_type: void 0 };
@@ -5125,10 +5296,19 @@ const _ResolveScreenSizeConflicts = class _ResolveScreenSizeConflicts extends Ru
5125
5296
  const conflicts = matches.conflicting(screenSizeMatch, (m) => ["season", "episode"].includes(m.name ?? "")) ?? [];
5126
5297
  if (conflicts.length === 0) continue;
5127
5298
  let hasNeighbor = false;
5128
- const videoProfile = matches.range(screenSizeMatch.end, filepart.end, (m) => m.name === "video_profile", 0);
5129
- if (videoProfile && matches.holes(screenSizeMatch.end, videoProfile.start, { predicate: (h) => !!(h.value && String(h.value).replace(new RegExp(`[${sepsPattern}]`, "g"), "")) }).length === 0) {
5130
- toRemove.push(...conflicts);
5131
- hasNeighbor = true;
5299
+ const allScreensizes = matches.range(filepart.start, filepart.end, (m) => m.name === "screen_size") ?? [];
5300
+ const groupOf = (m) => matches.markers.atMatch(m, (marker) => marker.name === "group", 0);
5301
+ const following = matches.range(
5302
+ screenSizeMatch.end,
5303
+ filepart.end,
5304
+ (m) => m.name === "video_profile" || m.name === "video_codec",
5305
+ 0
5306
+ );
5307
+ if (following && matches.holes(screenSizeMatch.end, following.start, { predicate: (h) => !!(h.value && String(h.value).replace(new RegExp(`[${sepsPattern}]`, "g"), "")) }).length === 0) {
5308
+ if (following.name === "video_profile" || allScreensizes.length === 1 && groupOf(screenSizeMatch) === groupOf(following)) {
5309
+ toRemove.push(...conflicts);
5310
+ hasNeighbor = true;
5311
+ }
5132
5312
  }
5133
5313
  const previous = matches.previous(screenSizeMatch, (m) => ["date", "source", "other", "streaming_service"].includes(m.name ?? ""), 0);
5134
5314
  if (previous && matches.holes(previous.end, screenSizeMatch.start, { predicate: (h) => !!(h.value && String(h.value).replace(new RegExp(`[${sepsPattern}]`, "g"), "")) }).length === 0) {
@@ -5144,47 +5324,12 @@ const _ResolveScreenSizeConflicts = class _ResolveScreenSizeConflicts extends Ru
5144
5324
  };
5145
5325
  _ResolveScreenSizeConflicts.consequence = RemoveMatch;
5146
5326
  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
- ];
5327
+ 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
5328
  function website(config) {
5184
5329
  const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "website") });
5185
5330
  rebulk.regexDefaults({ flags: "i" }).stringDefaults({ ignoreCase: true });
5186
5331
  rebulk.defaults({ name: "website" });
5187
- const tlds = config["tlds"] || DEFAULT_TLDS;
5332
+ const tlds = config["tlds"] || TLDS;
5188
5333
  const safeTlds = config["safe_tlds"] || ["com", "org", "net"];
5189
5334
  const safeSubdomains = config["safe_subdomains"] || ["www"];
5190
5335
  const safePrefix = config["safe_prefixes"] || [];
@@ -5207,10 +5352,10 @@ function website(config) {
5207
5352
  tags: ["website.prefix"]
5208
5353
  });
5209
5354
  class PreferTitleOverWebsiteWithConfig extends Rule {
5210
- constructor(safeTldsArg, safePrefixArg) {
5355
+ constructor(safeSubdomainsArg, safePrefixArg) {
5211
5356
  super();
5212
5357
  this.consequence = RemoveMatch;
5213
- this.safeTlds = safeTldsArg;
5358
+ this.safeSubdomains = safeSubdomainsArg;
5214
5359
  this.safePrefix = safePrefixArg;
5215
5360
  }
5216
5361
  validFollowers(match) {
@@ -5220,7 +5365,7 @@ function website(config) {
5220
5365
  const toRemove = [];
5221
5366
  for (const websiteMatch of matches.named("website")) {
5222
5367
  let safe = false;
5223
- for (const safeStart of [...this.safeTlds, ...this.safePrefix]) {
5368
+ for (const safeStart of [...this.safeSubdomains, ...this.safePrefix]) {
5224
5369
  if (String(websiteMatch.value ?? "").toLowerCase().startsWith(safeStart)) {
5225
5370
  safe = true;
5226
5371
  break;
@@ -5251,7 +5396,7 @@ function website(config) {
5251
5396
  return toRemove;
5252
5397
  }
5253
5398
  }
5254
- rebulk.rules(new PreferTitleOverWebsiteWithConfig(safeTlds, safePrefix), ValidateWebsitePrefix);
5399
+ rebulk.rules(new PreferTitleOverWebsiteWithConfig(safeSubdomains, safePrefix), ValidateWebsitePrefix);
5255
5400
  return rebulk;
5256
5401
  }
5257
5402
  const _ValidateWebsitePrefix = class _ValidateWebsitePrefix extends Rule {
@@ -6298,11 +6443,18 @@ const _CountryAtTitlePosition = class _CountryAtTitlePosition extends Rule {
6298
6443
  const filepart = matches.markers.atMatch(c, (m) => m.name === "path", 0);
6299
6444
  if (!filepart) continue;
6300
6445
  if (![...inp.slice(filepart.start, c.start)].every((ch) => seps.includes(ch))) continue;
6301
- const year = matches.range(c.end, filepart.end, (m) => !m.private && m.name === "year", 0);
6302
- if (!year) continue;
6303
- const se = matches.range(c.end, year.start, (m) => !m.private && ["season", "episode", "date"].includes(m.name ?? ""), 0);
6304
- if (se) continue;
6305
- if (![...inp.slice(c.end, year.start)].every((ch) => seps.includes(ch))) continue;
6446
+ if (["release-group-prefix", "streaming_service.prefix", "streaming_service.suffix"].some((t) => c.tags?.includes(t))) continue;
6447
+ if (matches.markers.atMatch(c, (m) => m.name === "group", 0)) continue;
6448
+ const anchor = matches.range(
6449
+ c.end,
6450
+ filepart.end,
6451
+ (m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
6452
+ 0
6453
+ );
6454
+ if (!anchor) continue;
6455
+ if (![...inp.slice(c.end, anchor.start)].every((ch) => seps.includes(ch))) {
6456
+ if (matches.range(c.end, anchor.start, (m) => !m.private && m.value != null, 0)) continue;
6457
+ }
6306
6458
  out.push(c);
6307
6459
  }
6308
6460
  return out.length ? out : false;
@@ -6310,6 +6462,33 @@ const _CountryAtTitlePosition = class _CountryAtTitlePosition extends Rule {
6310
6462
  };
6311
6463
  _CountryAtTitlePosition.priority = 64;
6312
6464
  let CountryAtTitlePosition = _CountryAtTitlePosition;
6465
+ const _TitleWordAtTitlePosition = class _TitleWordAtTitlePosition extends Rule {
6466
+ constructor() {
6467
+ super(...arguments);
6468
+ this.priority = 64;
6469
+ this.consequence = RemoveMatch;
6470
+ }
6471
+ when(matches, _context) {
6472
+ const toRemove = [];
6473
+ const tagged = matches.tagged("title-word") ?? [];
6474
+ for (const candidate of Array.isArray(tagged) ? tagged : [tagged]) {
6475
+ if (!candidate || candidate.private) continue;
6476
+ const filepart = matches.markers.atMatch(candidate, (m) => m.name === "path", 0);
6477
+ if (!filepart) continue;
6478
+ const anchor = matches.range(
6479
+ filepart.start,
6480
+ filepart.end,
6481
+ (m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
6482
+ 0
6483
+ );
6484
+ if (!anchor || candidate.start >= anchor.start) continue;
6485
+ toRemove.push(candidate);
6486
+ }
6487
+ return toRemove.length ? toRemove : false;
6488
+ }
6489
+ };
6490
+ _TitleWordAtTitlePosition.priority = 64;
6491
+ let TitleWordAtTitlePosition = _TitleWordAtTitlePosition;
6313
6492
  const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle extends Rule {
6314
6493
  constructor() {
6315
6494
  super(...arguments);
@@ -6330,6 +6509,7 @@ const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle ex
6330
6509
  const lead = matches.range(filepart.start, filepart.end, (m) => !m.private && !!m.value, 0);
6331
6510
  if (!lead || !["other", "country", "edition"].includes(lead.name ?? "")) continue;
6332
6511
  if (lead.start >= anchor.start) continue;
6512
+ if ((lead.raw ?? "") === String(lead.value ?? "")) continue;
6333
6513
  if (![...inp.slice(filepart.start, lead.start)].every((c) => seps.includes(c))) continue;
6334
6514
  out.push(lead);
6335
6515
  }
@@ -6456,7 +6636,7 @@ function title(config) {
6456
6636
  const rebulk = new Rebulk({
6457
6637
  disabled: (context) => isDisabled(context, "title")
6458
6638
  });
6459
- rebulk.rules(CountryAtTitlePosition, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle);
6639
+ rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle);
6460
6640
  const expectedTitle = buildExpectedFunction("expected_title");
6461
6641
  rebulk.functional(expectedTitle, {
6462
6642
  name: "title",
@@ -8861,7 +9041,11 @@ function other(config) {
8861
9041
  rebulk.regexDefaults({ flags: "i", abbreviations: [dash] }).stringDefaults({ ignoreCase: true });
8862
9042
  rebulk.defaults({ name: "other", validator: sepsSurround });
8863
9043
  loadConfigPatterns(rebulk, config["other"]);
9044
+ openingEndingCredits(rebulk);
8864
9045
  rebulk.rules(
9046
+ AppendCreditless,
9047
+ AppendOpedEndingCredits,
9048
+ ValidateStereoVRContext,
8865
9049
  RenameAnotherToOther,
8866
9050
  ValidateHasNeighbor,
8867
9051
  ValidateHasNeighborAfter,
@@ -8926,9 +9110,132 @@ const _ImageArtKeywordToOther = class _ImageArtKeywordToOther extends Rule {
8926
9110
  };
8927
9111
  _ImageArtKeywordToOther.priority = POST_PROCESS;
8928
9112
  let ImageArtKeywordToOther = _ImageArtKeywordToOther;
8929
- function completeWords(rebulk, seasonWords, completeArticleWords) {
8930
- const seasonWordsPattern = buildOrPattern(seasonWords);
8931
- const completeArticleWordsPattern = buildOrPattern(completeArticleWords);
9113
+ const CREDITS_NUMBER = `(?P<credits_number>\\d+(?:(?![vV]\\d)[^\\W\\d_])?)?`;
9114
+ const CREDITS_VERSION = `(?:-?[vV](?P<version>\\d+))?`;
9115
+ const CREDITS_SUFFIX = CREDITS_NUMBER + CREDITS_VERSION;
9116
+ function formatCreditsNumber(value) {
9117
+ const m = /^(\d+)(\w?)$/.exec(value);
9118
+ if (!m) return value;
9119
+ return String(parseInt(m[1], 10)) + m[2].toLowerCase();
9120
+ }
9121
+ function openingEndingCredits(rebulk) {
9122
+ const add = (pattern, value, ignoreCase) => {
9123
+ rebulk.regex(
9124
+ `(?P<other>` + pattern + `)` + CREDITS_SUFFIX,
9125
+ {
9126
+ flags: ignoreCase ? "i" : "",
9127
+ name: "other",
9128
+ children: true,
9129
+ privateParent: true,
9130
+ validateAll: true,
9131
+ validator: { __parent__: sepsSurround },
9132
+ formatter: {
9133
+ other: () => value,
9134
+ credits_number: formatCreditsNumber,
9135
+ version: (v) => parseInt(v, 10)
9136
+ },
9137
+ disabled: (context) => isDisabled(context, "other")
9138
+ }
9139
+ );
9140
+ };
9141
+ add(`NC-?OP|creditless-?op(?:ening)?`, "Opening Credits", true);
9142
+ add(`NC-?ED|creditless-?(?:ed|ending)`, "Ending Credits", true);
9143
+ add(`OPED|OP`, "Opening Credits", false);
9144
+ add(`ED`, "Ending Credits", false);
9145
+ }
9146
+ const _AppendCreditless = class _AppendCreditless extends Rule {
9147
+ constructor() {
9148
+ super(...arguments);
9149
+ this.priority = POST_PROCESS;
9150
+ this.consequence = AppendMatch;
9151
+ }
9152
+ when(matches, _context) {
9153
+ const toAppend = [];
9154
+ for (const match of matches.named("other", (m) => m.value === "Opening Credits" || m.value === "Ending Credits") ?? []) {
9155
+ const raw = (match.raw ?? "").toLowerCase().replace(/[\s._-]+/g, "");
9156
+ if (raw.startsWith("nc") || raw.includes("creditless")) {
9157
+ toAppend.push(new Match(match.start, match.end, {
9158
+ name: "other",
9159
+ value: "Creditless",
9160
+ inputString: matches.inputString
9161
+ }));
9162
+ }
9163
+ }
9164
+ return toAppend.length ? toAppend : false;
9165
+ }
9166
+ };
9167
+ _AppendCreditless.priority = POST_PROCESS;
9168
+ _AppendCreditless.properties = { other: ["Creditless"] };
9169
+ let AppendCreditless = _AppendCreditless;
9170
+ const _AppendOpedEndingCredits = class _AppendOpedEndingCredits extends Rule {
9171
+ constructor() {
9172
+ super(...arguments);
9173
+ this.priority = POST_PROCESS;
9174
+ this.consequence = AppendMatch;
9175
+ }
9176
+ when(matches, _context) {
9177
+ const toAppend = [];
9178
+ for (const match of matches.named("other", (m) => m.value === "Opening Credits") ?? []) {
9179
+ if ((match.raw ?? "").toLowerCase().replace(/[\s._-]+/g, "") === "oped") {
9180
+ toAppend.push(new Match(match.start, match.end, {
9181
+ name: "other",
9182
+ value: "Ending Credits",
9183
+ inputString: matches.inputString
9184
+ }));
9185
+ }
9186
+ }
9187
+ return toAppend.length ? toAppend : false;
9188
+ }
9189
+ };
9190
+ _AppendOpedEndingCredits.priority = POST_PROCESS;
9191
+ _AppendOpedEndingCredits.properties = { other: ["Ending Credits"] };
9192
+ let AppendOpedEndingCredits = _AppendOpedEndingCredits;
9193
+ const STEREO_VR_CONTEXT_TAG = "stereo-vr-context";
9194
+ const VR_CONTEXT_VALUES = /* @__PURE__ */ new Set(["Virtual Reality", "3D"]);
9195
+ const _ValidateStereoVRContext = class _ValidateStereoVRContext extends Rule {
9196
+ constructor() {
9197
+ super(...arguments);
9198
+ this.priority = 64;
9199
+ this.consequence = RemoveMatch;
9200
+ }
9201
+ when(matches, _context) {
9202
+ const toRemove = [];
9203
+ const fileparts = matches.markers.named("path");
9204
+ for (const filepart of Array.isArray(fileparts) ? fileparts : fileparts ? [fileparts] : []) {
9205
+ const gated = matches.range(
9206
+ filepart.start,
9207
+ filepart.end,
9208
+ (m) => m.name === "other" && m.tags.includes(STEREO_VR_CONTEXT_TAG)
9209
+ );
9210
+ if (!gated?.length) continue;
9211
+ const hasVrContext = matches.range(
9212
+ filepart.start,
9213
+ filepart.end,
9214
+ (m) => m.name === "other" && VR_CONTEXT_VALUES.has(String(m.value))
9215
+ )?.length > 0;
9216
+ if (hasVrContext) {
9217
+ for (const stereo of gated) {
9218
+ toRemove.push(...matches.range(
9219
+ stereo.start,
9220
+ stereo.end,
9221
+ (m) => m.name === "streaming_service"
9222
+ ) ?? []);
9223
+ }
9224
+ } else {
9225
+ toRemove.push(...gated);
9226
+ }
9227
+ }
9228
+ return toRemove.length ? toRemove : false;
9229
+ }
9230
+ };
9231
+ _ValidateStereoVRContext.priority = 64;
9232
+ let ValidateStereoVRContext = _ValidateStereoVRContext;
9233
+ const TOKEN_START = `(?<![^\\W_])`;
9234
+ function completeWords(rebulk, opts) {
9235
+ const completeMarkerPattern = buildOrPattern(opts.completeMarkerWords);
9236
+ const seasonWordsPattern = buildOrPattern(opts.seasonWords);
9237
+ const completeArticleWordsPattern = buildOrPattern(opts.completeArticleWords);
9238
+ const seasonNumbersPattern = `(?:-+(?:\\d+|` + buildOrPattern(opts.seasonNumberSeparators, void 0, true) + `))+-+`;
8932
9239
  function validateComplete(match) {
8933
9240
  const children = match.children;
8934
9241
  if (!children.named("completeWordsBefore") && !children.named("completeWordsAfter")) {
@@ -8937,7 +9244,7 @@ function completeWords(rebulk, seasonWords, completeArticleWords) {
8937
9244
  return true;
8938
9245
  }
8939
9246
  rebulk.regex(
8940
- `(?P<completeArticle>${completeArticleWordsPattern}-)?(?P<completeWordsBefore>${seasonWordsPattern}-)?Complete(?P<completeWordsAfter>-${seasonWordsPattern})?`,
9247
+ TOKEN_START + `(?P<completeArticle>${completeArticleWordsPattern}-)?(?P<completeWordsBefore>${seasonWordsPattern}-)?` + completeMarkerPattern + `(?P<completeWordsAfter>-${seasonWordsPattern})?`,
8941
9248
  {
8942
9249
  privateNames: ["completeArticle", "completeWordsBefore", "completeWordsAfter"],
8943
9250
  value: { other: "Complete" },
@@ -8947,6 +9254,26 @@ function completeWords(rebulk, seasonWords, completeArticleWords) {
8947
9254
  }
8948
9255
  }
8949
9256
  );
9257
+ rebulk.regex(
9258
+ seasonWordsPattern + seasonNumbersPattern + `(?P<other>` + completeMarkerPattern + `)`,
9259
+ {
9260
+ children: true,
9261
+ privateParent: true,
9262
+ validateAll: true,
9263
+ value: { other: "Complete" },
9264
+ tags: ["release-group-prefix"],
9265
+ validator: { __parent__: sepsSurround }
9266
+ }
9267
+ );
9268
+ rebulk.regex(
9269
+ TOKEN_START + `(?P<completePrefix>` + buildOrPattern(opts.completePrefixWords) + `-?)` + completeMarkerPattern,
9270
+ {
9271
+ privateNames: ["completePrefix"],
9272
+ value: { other: "Complete" },
9273
+ tags: ["release-group-prefix"],
9274
+ validator: { __parent__: sepsSurround }
9275
+ }
9276
+ );
8950
9277
  }
8951
9278
  const _ProperCountRule = class _ProperCountRule extends Rule {
8952
9279
  when(matches, context) {
@@ -9240,10 +9567,20 @@ const _RemoveTitleCaseAmbiguous = class _RemoveTitleCaseAmbiguous extends Rule {
9240
9567
  // lowercase scene spellings are unaffected; only the Title-Case word is removed.
9241
9568
  when(matches) {
9242
9569
  const TITLE_WORDS = /* @__PURE__ */ new Set(["Real", "Cam", "Convert"]);
9570
+ const RELEASE_META = /* @__PURE__ */ new Set(["screen_size", "video_codec", "audio_codec", "video_profile", "release_group"]);
9243
9571
  const ret = [];
9244
9572
  for (const m of matches.range(0, matches.inputString?.length ?? 0)) {
9245
9573
  if (m.name !== "other" && m.name !== "source") continue;
9246
- if (TITLE_WORDS.has(m.raw ?? "")) ret.push(m);
9574
+ if (!TITLE_WORDS.has(m.raw ?? "")) continue;
9575
+ const filepart = matches.markers.atMatch(m, (marker) => marker.name === "path", 0);
9576
+ const searchEnd = filepart?.end ?? (matches.inputString?.length ?? m.end);
9577
+ const metaAfter = matches.range(
9578
+ m.end,
9579
+ searchEnd,
9580
+ (o) => !o.private && RELEASE_META.has(o.name ?? "")
9581
+ ) ?? [];
9582
+ if (metaAfter.length > 0) continue;
9583
+ ret.push(m);
9247
9584
  }
9248
9585
  return ret.length ? ret : false;
9249
9586
  }
@@ -9906,6 +10243,13 @@ const _TypeProcessor = class _TypeProcessor extends Rule {
9906
10243
  return "episode";
9907
10244
  }
9908
10245
  }
10246
+ const completeSeries = matches.named(
10247
+ "other",
10248
+ (m) => m.value === "Complete" && !!(m.children?.named?.("completeWordsBefore")?.length || m.children?.named?.("completeWordsAfter")?.length)
10249
+ );
10250
+ if (completeSeries && (Array.isArray(completeSeries) ? completeSeries.length > 0 : true)) {
10251
+ return "episode";
10252
+ }
9909
10253
  const film2 = matches.named("film");
9910
10254
  if (film2 && (Array.isArray(film2) ? film2.length > 0 : true)) {
9911
10255
  return "movie";
@@ -9930,6 +10274,10 @@ const _TypeProcessor = class _TypeProcessor extends Rule {
9930
10274
  if (crc32 && (Array.isArray(crc32) ? crc32.length > 0 : true) && animeReleaseGroup && (Array.isArray(animeReleaseGroup) ? animeReleaseGroup.length > 0 : true)) {
9931
10275
  return "episode";
9932
10276
  }
10277
+ const complete = matches.named("other", (m) => m.value === "Complete");
10278
+ if (complete && (Array.isArray(complete) ? complete.length > 0 : true) && (!year || (Array.isArray(year) ? year.length === 0 : false))) {
10279
+ return "episode";
10280
+ }
9933
10281
  return "movie";
9934
10282
  }
9935
10283
  then(matches, whenResponse, _context) {
@@ -10271,9 +10619,13 @@ function rebulkBuilder(config) {
10271
10619
  rebulk.rebulk(streamingService(cfg("streaming_service")));
10272
10620
  const otherRebulk = other(cfg("other"));
10273
10621
  cfg("episodes");
10274
- const completeSeasonWords = ["seasons?", "series?"];
10275
- const completeArticleWords = ["The"];
10276
- completeWords(otherRebulk, completeSeasonWords, completeArticleWords);
10622
+ completeWords(otherRebulk, {
10623
+ completeMarkerWords: ["Complete", "Int[ée]grale"],
10624
+ seasonWords: ["seasons?", "mini-?series?", "series?"],
10625
+ completeArticleWords: ["The"],
10626
+ completePrefixWords: ["L['’]?", "Coffret"],
10627
+ seasonNumberSeparators: ["&", "and"]
10628
+ });
10277
10629
  rebulk.rebulk(otherRebulk);
10278
10630
  rebulk.rebulk(size(cfg("size")));
10279
10631
  rebulk.rebulk(bitRate(cfg("bit_rate")));
@@ -10412,7 +10764,10 @@ const advanced_config = {
10412
10764
  "True-?HD"
10413
10765
  ]
10414
10766
  },
10415
- Opus: "Opus",
10767
+ Opus: {
10768
+ string: "Opus",
10769
+ tags: "title-word"
10770
+ },
10416
10771
  Vorbis: "Vorbis",
10417
10772
  PCM: "PCM",
10418
10773
  LPCM: "LPCM"
@@ -10916,27 +11271,104 @@ const advanced_config = {
10916
11271
  "saisons",
10917
11272
  "tem",
10918
11273
  "temp",
10919
- "temporada",
10920
- "temporadas",
10921
- "stagione"
11274
+ {
11275
+ value: "temporada",
11276
+ numfirst: true
11277
+ },
11278
+ {
11279
+ value: "temporadas",
11280
+ numfirst: true
11281
+ },
11282
+ "stagione",
11283
+ {
11284
+ value: "сезон",
11285
+ numfirst: true
11286
+ },
11287
+ {
11288
+ value: "sezon",
11289
+ numfirst: true
11290
+ },
11291
+ {
11292
+ value: "staffel",
11293
+ numfirst: true
11294
+ },
11295
+ "sezonul",
11296
+ "säsong",
11297
+ "sesong",
11298
+ "sæson",
11299
+ {
11300
+ value: "évad",
11301
+ numfirst: true
11302
+ }
10922
11303
  ],
10923
11304
  episode_words: [
10924
11305
  "episode",
10925
11306
  "episodes",
11307
+ "épisode",
11308
+ "épisodes",
10926
11309
  "eps",
10927
11310
  "ep",
10928
11311
  "episodio",
10929
11312
  "episodios",
10930
11313
  "capitulo",
10931
- "capitulos"
11314
+ "capitulos",
11315
+ {
11316
+ value: "серия",
11317
+ numfirst: true
11318
+ },
11319
+ {
11320
+ value: "серии",
11321
+ numfirst: true
11322
+ },
11323
+ {
11324
+ value: "эпизод",
11325
+ numfirst: true
11326
+ },
11327
+ {
11328
+ value: "seria",
11329
+ numfirst: true
11330
+ },
11331
+ {
11332
+ value: "serii",
11333
+ numfirst: true
11334
+ },
11335
+ {
11336
+ value: "serija",
11337
+ numfirst: true
11338
+ },
11339
+ {
11340
+ value: "bölüm",
11341
+ numfirst: true
11342
+ },
11343
+ {
11344
+ value: "bolum",
11345
+ numfirst: true
11346
+ },
11347
+ "aflevering",
11348
+ "afl",
11349
+ "folge",
11350
+ "odcinek",
11351
+ "episodul",
11352
+ "avsnitt",
11353
+ {
11354
+ value: "rész",
11355
+ numfirst: true
11356
+ }
10932
11357
  ],
10933
11358
  of_words: [
10934
11359
  "of",
10935
- "sur"
11360
+ "sur",
11361
+ "de",
11362
+ "di",
11363
+ "von",
11364
+ "van",
11365
+ "din",
11366
+ "из"
10936
11367
  ],
10937
11368
  all_words: [
10938
11369
  "All"
10939
- ]
11370
+ ],
11371
+ ordinal_suffix: "(?:ª|º|°|a|o|-?(?:й|я|е|го|ая|ый|ое))?"
10940
11372
  },
10941
11373
  film: {
10942
11374
  film: {
@@ -11243,52 +11675,14 @@ const advanced_config = {
11243
11675
  },
11244
11676
  "Virtual Reality": {
11245
11677
  string: [
11246
- "VR"
11678
+ "VR",
11679
+ "EAC360"
11247
11680
  ],
11248
11681
  regex: [
11249
11682
  "VR180",
11250
- "VR360"
11251
- ],
11252
- tags: "has-neighbor"
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"
11683
+ "VR360",
11684
+ "VR-180",
11685
+ "VR-360"
11292
11686
  ],
11293
11687
  tags: "has-neighbor"
11294
11688
  },
@@ -11478,7 +11872,7 @@ const advanced_config = {
11478
11872
  tags: "uhdbluray-neighbor"
11479
11873
  },
11480
11874
  "Dolby Vision": {
11481
- regex: "(?:Dolby-?Vision|DV)",
11875
+ regex: "(?:Dolby-?Vision|DoVi|DV)",
11482
11876
  tags: "uhdbluray-neighbor"
11483
11877
  },
11484
11878
  "BT.2020": {
@@ -11535,6 +11929,48 @@ const advanced_config = {
11535
11929
  complete_article_words: [
11536
11930
  "The"
11537
11931
  ]
11932
+ },
11933
+ "Side By Side": {
11934
+ string: [
11935
+ "SBS",
11936
+ "LR"
11937
+ ],
11938
+ tags: [
11939
+ "has-neighbor",
11940
+ "stereo-vr-context"
11941
+ ]
11942
+ },
11943
+ "Over Under": {
11944
+ string: [
11945
+ "TB",
11946
+ "OU"
11947
+ ],
11948
+ tags: [
11949
+ "has-neighbor",
11950
+ "stereo-vr-context"
11951
+ ]
11952
+ },
11953
+ "Half Side By Side": {
11954
+ string: [
11955
+ "HSBS"
11956
+ ],
11957
+ regex: [
11958
+ "h-?sbs",
11959
+ "half-?sbs"
11960
+ ],
11961
+ tags: "has-neighbor"
11962
+ },
11963
+ "Half Over Under": {
11964
+ string: [
11965
+ "HOU",
11966
+ "HTAB"
11967
+ ],
11968
+ regex: [
11969
+ "h-?ou",
11970
+ "half-?ou",
11971
+ "half-?tab"
11972
+ ],
11973
+ tags: "has-neighbor"
11538
11974
  }
11539
11975
  }
11540
11976
  },
@@ -12339,7 +12775,6 @@ const GUESSIT_SCHEMA = {
12339
12775
  "Dual",
12340
12776
  "Dual Audio",
12341
12777
  "East Coast Feed",
12342
- "Ending Credits",
12343
12778
  "Extras",
12344
12779
  "Fan Subtitled",
12345
12780
  "Fanart",
@@ -12350,8 +12785,8 @@ const GUESSIT_SCHEMA = {
12350
12785
  "Fix",
12351
12786
  "Fixed",
12352
12787
  "Full HD",
12353
- "Half OU",
12354
- "Half SBS",
12788
+ "Half Over Under",
12789
+ "Half Side By Side",
12355
12790
  "Hardcoded Subtitles",
12356
12791
  "HC",
12357
12792
  "HD",
@@ -12386,7 +12821,6 @@ const GUESSIT_SCHEMA = {
12386
12821
  "Obfuscated",
12387
12822
  "Ona",
12388
12823
  "Open Matte",
12389
- "Opening Credits",
12390
12824
  "Original Animated Video",
12391
12825
  "Original Animation DVD",
12392
12826
  "Original Aspect Ratio",
@@ -12394,6 +12828,7 @@ const GUESSIT_SCHEMA = {
12394
12828
  "Original Video",
12395
12829
  "OV",
12396
12830
  "Ova",
12831
+ "Over Under",
12397
12832
  "PAL",
12398
12833
  "postbot",
12399
12834
  "Poster",
@@ -12418,6 +12853,7 @@ const GUESSIT_SCHEMA = {
12418
12853
  "Screener",
12419
12854
  "SDR",
12420
12855
  "SECAM",
12856
+ "Side By Side",
12421
12857
  "Standard Dynamic Range",
12422
12858
  "Straight to Video",
12423
12859
  "STV",
@@ -12523,6 +12959,7 @@ const GUESSIT_SCHEMA = {
12523
12959
  "HD Telesync",
12524
12960
  "HD-DVD",
12525
12961
  "HDTV",
12962
+ "Laserdisc",
12526
12963
  "Pay-per-view",
12527
12964
  "Satellite",
12528
12965
  "Telecine",