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.
- package/README.md +3 -3
- package/dist/guessit-js.cjs +36 -1
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +36 -1
- package/dist/guessit-js.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,13 +5,13 @@ Extract metadata (title, year, season, episode, codec, language, etc.) from medi
|
|
|
5
5
|
[](https://www.npmjs.com/package/guessit-js)
|
|
6
6
|
[](https://github.com/opensubtitles/guessit-js/actions/workflows/ci.yml)
|
|
7
7
|
[](https://www.gnu.org/licenses/lgpl-3.0)
|
|
8
|
-
[-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 (
|
|
14
|
+
- **100% compatibility** with Python guessit 4.4.0 (1289/1289 fixtures passing, including Python's own grown 4.x corpus) — and **more correct**: ships fixes for 32 historical upstream bugs plus Python's still-open #875 and #877 (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 (
|
|
125
|
+
guessit-js is a faithful port (1289/1289 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
|
|
package/dist/guessit-js.cjs
CHANGED
|
@@ -3377,7 +3377,8 @@ function seasonEpisodeConflictSolver(match, other2) {
|
|
|
3377
3377
|
return "__default__";
|
|
3378
3378
|
}
|
|
3379
3379
|
function orderingValidator(match) {
|
|
3380
|
-
const
|
|
3380
|
+
const dict = match.children?.toDict?.() ?? match.children?.to_dict?.();
|
|
3381
|
+
const values = dict instanceof Map ? Object.fromEntries(dict) : dict || {};
|
|
3381
3382
|
if (values.season && Array.isArray(values.season)) {
|
|
3382
3383
|
const sorted = [...values.season].sort((a, b) => a - b);
|
|
3383
3384
|
if (JSON.stringify(sorted) !== JSON.stringify(values.season)) {
|
|
@@ -7102,6 +7103,39 @@ const LEADING_ARTICLES_RE = /^(the|a|an|le|la|les|l'|el|los|las|der|die|das)\s+/
|
|
|
7102
7103
|
function normalizeTitle(s) {
|
|
7103
7104
|
return s.toLowerCase().replace(LEADING_ARTICLES_RE, "").trim();
|
|
7104
7105
|
}
|
|
7106
|
+
const _FormationRunEpisodeTitle = class _FormationRunEpisodeTitle extends Rule {
|
|
7107
|
+
constructor() {
|
|
7108
|
+
super(...arguments);
|
|
7109
|
+
this.priority = POST_PROCESS;
|
|
7110
|
+
this.consequence = [RemoveMatch, AppendMatch];
|
|
7111
|
+
}
|
|
7112
|
+
when(matches, _context) {
|
|
7113
|
+
const input = matches.inputString ?? "";
|
|
7114
|
+
const toRemove = [];
|
|
7115
|
+
const toAppend = [];
|
|
7116
|
+
const ets = matches.named("episode_title") ?? [];
|
|
7117
|
+
for (const et of ets) {
|
|
7118
|
+
if (!/^\d{1,2}$/.test(String(et.value ?? ""))) continue;
|
|
7119
|
+
const eps = (matches.named("episode") ?? []).filter((e) => e.end <= et.start && !e.private).sort((a, b) => a.start - b.start);
|
|
7120
|
+
if (eps.length < 3) continue;
|
|
7121
|
+
const run = eps.slice(1);
|
|
7122
|
+
const runStart = run[0].start;
|
|
7123
|
+
const span = input.slice(runStart, et.end);
|
|
7124
|
+
if (!/^\d{1,3}(-\d{1,3})+$/.test(span)) continue;
|
|
7125
|
+
const between = input.slice(eps[0].end, runStart);
|
|
7126
|
+
if (!/^[\s._]+$/.test(between)) continue;
|
|
7127
|
+
toRemove.push(...run, et);
|
|
7128
|
+
toAppend.push(new Match(runStart, et.end, {
|
|
7129
|
+
name: "episode_title",
|
|
7130
|
+
value: span,
|
|
7131
|
+
inputString: input
|
|
7132
|
+
}));
|
|
7133
|
+
}
|
|
7134
|
+
return toRemove.length || toAppend.length ? [toRemove, toAppend] : false;
|
|
7135
|
+
}
|
|
7136
|
+
};
|
|
7137
|
+
_FormationRunEpisodeTitle.priority = POST_PROCESS;
|
|
7138
|
+
let FormationRunEpisodeTitle = _FormationRunEpisodeTitle;
|
|
7105
7139
|
function episodeTitle(config) {
|
|
7106
7140
|
const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "episode_title") });
|
|
7107
7141
|
rebulk.rules(
|
|
@@ -7121,6 +7155,7 @@ function episodeTitle(config) {
|
|
|
7121
7155
|
RemoveSubtitleDescriptorEpisodeTitle,
|
|
7122
7156
|
RemoveHashFilepartJunk,
|
|
7123
7157
|
RemoveTailEpisodeTitle,
|
|
7158
|
+
FormationRunEpisodeTitle,
|
|
7124
7159
|
RenameEpisodeTitleWhenMovieType
|
|
7125
7160
|
);
|
|
7126
7161
|
return rebulk;
|