guessit-js 4.5.1 → 4.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -5,13 +5,13 @@ Extract metadata (title, year, season, episode, codec, language, etc.) from medi
5
5
  [![npm version](https://img.shields.io/npm/v/guessit-js.svg)](https://www.npmjs.com/package/guessit-js)
6
6
  [![Tests](https://github.com/opensubtitles/guessit-js/actions/workflows/ci.yml/badge.svg)](https://github.com/opensubtitles/guessit-js/actions/workflows/ci.yml)
7
7
  [![License: LGPL-3.0](https://img.shields.io/badge/License-LGPL--3.0-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)
8
- [![Python guessit compat](https://img.shields.io/badge/guessit_compat-100%25_(1333%2F1333)-brightgreen)](https://github.com/guessit-io/guessit)
8
+ [![Python guessit compat](https://img.shields.io/badge/guessit_compat-100%25_(1342%2F1342)-brightgreen)](https://github.com/guessit-io/guessit)
9
9
 
10
10
  **[Live Demo](https://opensubtitles.github.io/guessit-js)** · **[API Docs](https://opensubtitles.github.io/guessit-js/docs)** · **[npm](https://www.npmjs.com/package/guessit-js)**
11
11
 
12
12
  ## Features
13
13
 
14
- - **100% compatibility** with Python guessit 4.4.0 (1333/1333 fixtures passing, including Python's own grown 4.x corpus) — and **more correct**: ships fixes for 32 historical upstream bugs, Python's still-open #875 and #877, and 104 of the 276 cross-parser cases Python admits failing (see [Differences from Python](#differences-from-python-guessit))
14
+ - **100% compatibility** with Python guessit 4.4.0 (1342/1342 fixtures passing, including Python's own grown 4.x corpus) — and **more correct**: ships fixes for 32 historical upstream bugs, Python's still-open #875 and #877, and 112 of the 276 cross-parser cases Python admits failing (see [Differences from Python](#differences-from-python-guessit))
15
15
  - **3.5x faster** than Python (6.87ms vs 23.86ms per parse)
16
16
  - **50 properties** detected: title, year, season, episode, resolution, codec, language, and more — with a [machine-readable schema](#output-schema)
17
17
  - **Single dependency** ([rebulk-js](https://www.npmjs.com/package/rebulk-js))
@@ -122,7 +122,7 @@ The WASM build is **bit-identical to the JS build** across the entire test corpu
122
122
 
123
123
  ## Differences from Python guessit
124
124
 
125
- guessit-js is a faithful port (1333/1333 fixtures, tracking Python 4.4.0), but it is
125
+ guessit-js is a faithful port (1342/1342 fixtures, tracking Python 4.4.0), but it is
126
126
  **not bug-for-bug identical** — where Python has a genuine parsing bug, guessit-js
127
127
  is corrected. Highlights:
128
128
 
@@ -372,6 +372,11 @@ class _BaseMatches {
372
372
  toArray() {
373
373
  return [...this._delegate];
374
374
  }
375
+ /** All matches as an array. Ported Python code reads `matches.matches` — without
376
+ * this getter that silently evaluated to undefined and turned rules into no-ops. */
377
+ get matches() {
378
+ return [...this._delegate];
379
+ }
375
380
  // ── Cache accessors ──────────────────────────────────────────────────────
376
381
  get nameDict() {
377
382
  if (!this._nameDict) {
@@ -1621,12 +1626,10 @@ function executeRule(rule, matches, context) {
1621
1626
  }
1622
1627
  function toposortRules(rules) {
1623
1628
  const graph = /* @__PURE__ */ new Map();
1624
- const classToDep = /* @__PURE__ */ new Map();
1629
+ const classToDeps = /* @__PURE__ */ new Map();
1625
1630
  for (const rule of rules) {
1626
- if (classToDep.has(rule.constructor)) {
1627
- throw new Error(`Duplicate class rules are not allowed: ${rule.constructor.name}`);
1628
- }
1629
- classToDep.set(rule.constructor, rule);
1631
+ const cls = rule.constructor;
1632
+ classToDeps.set(cls, [...classToDeps.get(cls) ?? [], rule]);
1630
1633
  }
1631
1634
  for (const rule of rules) {
1632
1635
  const deps = /* @__PURE__ */ new Set();
@@ -1634,18 +1637,20 @@ function toposortRules(rules) {
1634
1637
  if (rawDeps) {
1635
1638
  const depArr = Array.isArray(rawDeps) ? rawDeps : [rawDeps];
1636
1639
  for (const dep of depArr) {
1637
- let resolved;
1640
+ let resolved = [];
1638
1641
  if (typeof dep === "string") {
1639
- for (const [cls, inst] of classToDep) {
1642
+ for (const [cls, insts] of classToDeps) {
1640
1643
  if (cls.name === dep) {
1641
- resolved = inst;
1644
+ resolved = insts;
1642
1645
  break;
1643
1646
  }
1644
1647
  }
1645
1648
  } else {
1646
- resolved = classToDep.get(dep);
1649
+ resolved = classToDeps.get(dep) ?? [];
1650
+ }
1651
+ for (const inst of resolved) {
1652
+ if (inst !== rule) deps.add(inst);
1647
1653
  }
1648
- if (resolved) deps.add(resolved);
1649
1654
  }
1650
1655
  }
1651
1656
  graph.set(rule, deps);