guessit-js 4.4.0 → 4.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3738,6 +3738,7 @@ function episodes(config) {
3738
3738
  disabled: (context) => isDisabled(context, "episode_format")
3739
3739
  });
3740
3740
  rebulk.rules(
3741
+ RemoveGroupSuffixSeason,
3741
3742
  AnimeTrailingEpisodeRule,
3742
3743
  PreferAnchoredWeakEpisodeRule,
3743
3744
  SeasonWordDashedEpisodeRule,
@@ -3756,6 +3757,43 @@ function episodes(config) {
3756
3757
  );
3757
3758
  return rebulk;
3758
3759
  }
3760
+ const _RemoveGroupSuffixSeason = class _RemoveGroupSuffixSeason extends Rule {
3761
+ constructor() {
3762
+ super(...arguments);
3763
+ this.priority = 72;
3764
+ this.consequence = RemoveMatch;
3765
+ }
3766
+ when(matches, _context) {
3767
+ const input = matches.inputString ?? "";
3768
+ const toRemove = [];
3769
+ const TOKENS = /* @__PURE__ */ new Set(["audio_codec", "audio_channels", "video_codec", "audio_profile", "other"]);
3770
+ for (const season of matches.named("season") ?? []) {
3771
+ const init = season.initiator ?? season;
3772
+ if (!/^s\d{1,3}$/i.test(String(init.raw ?? ""))) continue;
3773
+ const hasEpisode = [...init.children ?? []].some((c) => c.name === "episode");
3774
+ if (hasEpisode) continue;
3775
+ if (input[init.start - 1] !== "-") continue;
3776
+ const prev = matches.range(
3777
+ Math.max(0, init.start - 12),
3778
+ init.start - 1,
3779
+ (m) => !m.private && TOKENS.has(m.name ?? ""),
3780
+ -1
3781
+ ) ?? matches.range(
3782
+ Math.max(0, init.start - 12),
3783
+ init.start - 1,
3784
+ (m) => !m.private && TOKENS.has(m.name ?? ""),
3785
+ 0
3786
+ );
3787
+ const inGroup = matches.markers.atMatch(init, (m) => m.name === "group", 0);
3788
+ if (!prev && !inGroup) continue;
3789
+ toRemove.push(season);
3790
+ for (const c of init.children ?? []) if (!toRemove.includes(c)) toRemove.push(c);
3791
+ }
3792
+ return toRemove.length ? toRemove : false;
3793
+ }
3794
+ };
3795
+ _RemoveGroupSuffixSeason.priority = 72;
3796
+ let RemoveGroupSuffixSeason = _RemoveGroupSuffixSeason;
3759
3797
  const _AnimeTrailingEpisodeRule = class _AnimeTrailingEpisodeRule extends Rule {
3760
3798
  constructor() {
3761
3799
  super(...arguments);
@@ -7011,6 +7049,36 @@ const _BracketedTitleFallback = class _BracketedTitleFallback extends Rule {
7011
7049
  };
7012
7050
  _BracketedTitleFallback.priority = POST_PROCESS;
7013
7051
  let BracketedTitleFallback = _BracketedTitleFallback;
7052
+ const _WordNumeralPartAtTitlePosition = class _WordNumeralPartAtTitlePosition extends Rule {
7053
+ constructor() {
7054
+ super(...arguments);
7055
+ this.priority = 64;
7056
+ this.consequence = RemoveMatch;
7057
+ }
7058
+ when(matches, context) {
7059
+ if (isDisabled(context, "part")) return false;
7060
+ const toRemove = [];
7061
+ for (const part2 of matches.named("part") ?? []) {
7062
+ const target = part2.initiator ?? part2;
7063
+ if (/\d/.test(String(target.raw ?? ""))) continue;
7064
+ const filepart = matches.markers.atMatch(part2, (m) => m.name === "path", 0);
7065
+ if (!filepart) continue;
7066
+ const anchor = matches.range(
7067
+ part2.end,
7068
+ filepart.end,
7069
+ (m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
7070
+ 0
7071
+ );
7072
+ if (!anchor) continue;
7073
+ toRemove.push(part2);
7074
+ for (const c of [...target.children ?? []]) if (!toRemove.includes(c)) toRemove.push(c);
7075
+ if (target !== part2 && !toRemove.includes(target)) toRemove.push(target);
7076
+ }
7077
+ return toRemove.length ? toRemove : false;
7078
+ }
7079
+ };
7080
+ _WordNumeralPartAtTitlePosition.priority = 64;
7081
+ let WordNumeralPartAtTitlePosition = _WordNumeralPartAtTitlePosition;
7014
7082
  const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle extends Rule {
7015
7083
  constructor() {
7016
7084
  super(...arguments);
@@ -7020,18 +7088,22 @@ const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle ex
7020
7088
  const inp = matches.inputString || "";
7021
7089
  const out = [];
7022
7090
  for (const filepart of matches.markers.named("path")) {
7023
- if (matches.range(filepart.start, filepart.end, (m) => m.name === "title", 0)) continue;
7091
+ const lead = matches.range(filepart.start, filepart.end, (m) => !m.private && !!m.value, 0);
7092
+ if (!lead) continue;
7024
7093
  const anchor = matches.range(
7025
- filepart.start,
7094
+ lead.end,
7026
7095
  filepart.end,
7027
7096
  (m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
7028
7097
  0
7029
7098
  );
7030
7099
  if (!anchor) continue;
7031
- const lead = matches.range(filepart.start, filepart.end, (m) => !m.private && !!m.value, 0);
7032
- if (!lead || !["other", "country", "edition"].includes(lead.name ?? "")) continue;
7033
- if (lead.start >= anchor.start) continue;
7034
- if ((lead.raw ?? "") === String(lead.value ?? "")) continue;
7100
+ const yearTitled = lead.name === "year" && ["season", "episode"].includes(anchor.name ?? "") && !anchor.tags?.includes("weak-episode") && !anchor.tags?.includes("weak-duplicate");
7101
+ if (!yearTitled && !["other", "country", "edition"].includes(lead.name ?? "")) continue;
7102
+ const titles = matches.range(filepart.start, filepart.end, (m) => m.name === "title") ?? [];
7103
+ if (titles.some((t) => t.start < anchor.end)) continue;
7104
+ if (titles.length && !yearTitled) continue;
7105
+ out.push(...titles);
7106
+ if (lead.name !== "year" && (lead.raw ?? "") === String(lead.value ?? "")) continue;
7035
7107
  if (![...inp.slice(filepart.start, lead.start)].every((c) => seps.includes(c))) continue;
7036
7108
  out.push(lead);
7037
7109
  }
@@ -7158,7 +7230,7 @@ function title(config) {
7158
7230
  const rebulk = new Rebulk({
7159
7231
  disabled: (context) => isDisabled(context, "title")
7160
7232
  });
7161
- rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
7233
+ rebulk.rules(CountryAtTitlePosition, TitleWordAtTitlePosition, WordNumeralPartAtTitlePosition, SplitOriginalScriptTitle, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle, BracketedTitleFallback, PreBracketJunkTitle, TrimSeasonWordFromTitle);
7162
7234
  const expectedTitle = buildExpectedFunction("expected_title");
7163
7235
  rebulk.functional(expectedTitle, {
7164
7236
  name: "title",
@@ -11355,7 +11427,8 @@ const advanced_config = {
11355
11427
  regex: [
11356
11428
  "Dolby-Digital",
11357
11429
  "DD",
11358
- "AC-?3D?"
11430
+ "AC-?3D?",
11431
+ "DolbyD"
11359
11432
  ]
11360
11433
  },
11361
11434
  "Dolby Atmos": {