guessit-js 4.3.0 → 4.3.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.
@@ -3375,7 +3375,8 @@ function seasonEpisodeConflictSolver(match, other2) {
3375
3375
  return "__default__";
3376
3376
  }
3377
3377
  function orderingValidator(match) {
3378
- const values = match.children?.to_dict?.() || {};
3378
+ const dict = match.children?.toDict?.() ?? match.children?.to_dict?.();
3379
+ const values = dict instanceof Map ? Object.fromEntries(dict) : dict || {};
3379
3380
  if (values.season && Array.isArray(values.season)) {
3380
3381
  const sorted = [...values.season].sort((a, b) => a - b);
3381
3382
  if (JSON.stringify(sorted) !== JSON.stringify(values.season)) {
@@ -7100,6 +7101,39 @@ const LEADING_ARTICLES_RE = /^(the|a|an|le|la|les|l'|el|los|las|der|die|das)\s+/
7100
7101
  function normalizeTitle(s) {
7101
7102
  return s.toLowerCase().replace(LEADING_ARTICLES_RE, "").trim();
7102
7103
  }
7104
+ const _FormationRunEpisodeTitle = class _FormationRunEpisodeTitle extends Rule {
7105
+ constructor() {
7106
+ super(...arguments);
7107
+ this.priority = POST_PROCESS;
7108
+ this.consequence = [RemoveMatch, AppendMatch];
7109
+ }
7110
+ when(matches, _context) {
7111
+ const input = matches.inputString ?? "";
7112
+ const toRemove = [];
7113
+ const toAppend = [];
7114
+ const ets = matches.named("episode_title") ?? [];
7115
+ for (const et of ets) {
7116
+ if (!/^\d{1,2}$/.test(String(et.value ?? ""))) continue;
7117
+ const eps = (matches.named("episode") ?? []).filter((e) => e.end <= et.start && !e.private).sort((a, b) => a.start - b.start);
7118
+ if (eps.length < 3) continue;
7119
+ const run = eps.slice(1);
7120
+ const runStart = run[0].start;
7121
+ const span = input.slice(runStart, et.end);
7122
+ if (!/^\d{1,3}(-\d{1,3})+$/.test(span)) continue;
7123
+ const between = input.slice(eps[0].end, runStart);
7124
+ if (!/^[\s._]+$/.test(between)) continue;
7125
+ toRemove.push(...run, et);
7126
+ toAppend.push(new Match(runStart, et.end, {
7127
+ name: "episode_title",
7128
+ value: span,
7129
+ inputString: input
7130
+ }));
7131
+ }
7132
+ return toRemove.length || toAppend.length ? [toRemove, toAppend] : false;
7133
+ }
7134
+ };
7135
+ _FormationRunEpisodeTitle.priority = POST_PROCESS;
7136
+ let FormationRunEpisodeTitle = _FormationRunEpisodeTitle;
7103
7137
  function episodeTitle(config) {
7104
7138
  const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "episode_title") });
7105
7139
  rebulk.rules(
@@ -7119,6 +7153,7 @@ function episodeTitle(config) {
7119
7153
  RemoveSubtitleDescriptorEpisodeTitle,
7120
7154
  RemoveHashFilepartJunk,
7121
7155
  RemoveTailEpisodeTitle,
7156
+ FormationRunEpisodeTitle,
7122
7157
  RenameEpisodeTitleWhenMovieType
7123
7158
  );
7124
7159
  return rebulk;