guessit-js 3.9.0 → 4.0.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/LICENSE +165 -0
- package/README.md +105 -14
- package/dist/api.d.ts +3 -3
- package/dist/guessit-js.cjs +3034 -83
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +3034 -83
- package/dist/guessit-js.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/rules/common/diacritics.d.ts +1 -0
- package/dist/rules/common/formatters.d.ts +13 -0
- package/dist/rules/properties/imdb.d.ts +3 -0
- package/dist/rules/properties/title.d.ts +0 -3
- package/dist/rules/properties/volume.d.ts +3 -0
- package/dist/schema.d.ts +75 -0
- package/package.json +7 -3
- package/dist/dist/guessit-browser.js +0 -9869
- package/dist/dist/guessit-js.js +0 -10050
- package/dist/docs/index.html +0 -42
- package/dist/index.html +0 -697
- package/dist/openapi.json +0 -617
- package/dist/wasm/guessit.wasm +0 -0
- package/dist/wasm-test.html +0 -465
package/LICENSE
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
GNU LESSER GENERAL PUBLIC LICENSE
|
|
2
|
+
Version 3, 29 June 2007
|
|
3
|
+
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
|
+
Everyone is permitted to copy and distribute verbatim copies
|
|
6
|
+
of this license document, but changing it is not allowed.
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
This version of the GNU Lesser General Public License incorporates
|
|
10
|
+
the terms and conditions of version 3 of the GNU General Public
|
|
11
|
+
License, supplemented by the additional permissions listed below.
|
|
12
|
+
|
|
13
|
+
0. Additional Definitions.
|
|
14
|
+
|
|
15
|
+
As used herein, "this License" refers to version 3 of the GNU Lesser
|
|
16
|
+
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
|
17
|
+
General Public License.
|
|
18
|
+
|
|
19
|
+
"The Library" refers to a covered work governed by this License,
|
|
20
|
+
other than an Application or a Combined Work as defined below.
|
|
21
|
+
|
|
22
|
+
An "Application" is any work that makes use of an interface provided
|
|
23
|
+
by the Library, but which is not otherwise based on the Library.
|
|
24
|
+
Defining a subclass of a class defined by the Library is deemed a mode
|
|
25
|
+
of using an interface provided by the Library.
|
|
26
|
+
|
|
27
|
+
A "Combined Work" is a work produced by combining or linking an
|
|
28
|
+
Application with the Library. The particular version of the Library
|
|
29
|
+
with which the Combined Work was made is also called the "Linked
|
|
30
|
+
Version".
|
|
31
|
+
|
|
32
|
+
The "Minimal Corresponding Source" for a Combined Work means the
|
|
33
|
+
Corresponding Source for the Combined Work, excluding any source code
|
|
34
|
+
for portions of the Combined Work that, considered in isolation, are
|
|
35
|
+
based on the Application, and not on the Linked Version.
|
|
36
|
+
|
|
37
|
+
The "Corresponding Application Code" for a Combined Work means the
|
|
38
|
+
object code and/or source code for the Application, including any data
|
|
39
|
+
and utility programs needed for reproducing the Combined Work from the
|
|
40
|
+
Application, but excluding the System Libraries of the Combined Work.
|
|
41
|
+
|
|
42
|
+
1. Exception to Section 3 of the GNU GPL.
|
|
43
|
+
|
|
44
|
+
You may convey a covered work under sections 3 and 4 of this License
|
|
45
|
+
without being bound by section 3 of the GNU GPL.
|
|
46
|
+
|
|
47
|
+
2. Conveying Modified Versions.
|
|
48
|
+
|
|
49
|
+
If you modify a copy of the Library, and, in your modifications, a
|
|
50
|
+
facility refers to a function or data to be supplied by an Application
|
|
51
|
+
that uses the facility (other than as an argument passed when the
|
|
52
|
+
facility is invoked), then you may convey a copy of the modified
|
|
53
|
+
version:
|
|
54
|
+
|
|
55
|
+
a) under this License, provided that you make a good faith effort to
|
|
56
|
+
ensure that, in the event an Application does not supply the
|
|
57
|
+
function or data, the facility still operates, and performs
|
|
58
|
+
whatever part of its purpose remains meaningful, or
|
|
59
|
+
|
|
60
|
+
b) under the GNU GPL, with none of the additional permissions of
|
|
61
|
+
this License applicable to that copy.
|
|
62
|
+
|
|
63
|
+
3. Object Code Incorporating Material from Library Header Files.
|
|
64
|
+
|
|
65
|
+
The object code form of an Application may incorporate material from
|
|
66
|
+
a header file that is part of the Library. You may convey such object
|
|
67
|
+
code under terms of your choice, provided that, if the incorporated
|
|
68
|
+
material is not limited to numerical parameters, data structure
|
|
69
|
+
layouts and accessors, or small macros, inline functions and templates
|
|
70
|
+
(ten or fewer lines in length), you do both of the following:
|
|
71
|
+
|
|
72
|
+
a) Give prominent notice with each copy of the object code that the
|
|
73
|
+
Library is used in it and that the Library and its use are
|
|
74
|
+
covered by this License.
|
|
75
|
+
|
|
76
|
+
b) Accompany the object code with a copy of the GNU GPL and this license
|
|
77
|
+
document.
|
|
78
|
+
|
|
79
|
+
4. Combined Works.
|
|
80
|
+
|
|
81
|
+
You may convey a Combined Work under terms of your choice that,
|
|
82
|
+
taken together, effectively do not restrict modification of the
|
|
83
|
+
portions of the Library contained in the Combined Work and reverse
|
|
84
|
+
engineering for debugging such modifications, if you also do each of
|
|
85
|
+
the following:
|
|
86
|
+
|
|
87
|
+
a) Give prominent notice with each copy of the Combined Work that
|
|
88
|
+
the Library is used in it and that the Library and its use are
|
|
89
|
+
covered by this License.
|
|
90
|
+
|
|
91
|
+
b) Accompany the Combined Work with a copy of the GNU GPL and this license
|
|
92
|
+
document.
|
|
93
|
+
|
|
94
|
+
c) For a Combined Work that displays copyright notices during
|
|
95
|
+
execution, include the copyright notice for the Library among
|
|
96
|
+
these notices, as well as a reference directing the user to the
|
|
97
|
+
copies of the GNU GPL and this license document.
|
|
98
|
+
|
|
99
|
+
d) Do one of the following:
|
|
100
|
+
|
|
101
|
+
0) Convey the Minimal Corresponding Source under the terms of this
|
|
102
|
+
License, and the Corresponding Application Code in a form
|
|
103
|
+
suitable for, and under terms that permit, the user to
|
|
104
|
+
recombine or relink the Application with a modified version of
|
|
105
|
+
the Linked Version to produce a modified Combined Work, in the
|
|
106
|
+
manner specified by section 6 of the GNU GPL for conveying
|
|
107
|
+
Corresponding Source.
|
|
108
|
+
|
|
109
|
+
1) Use a suitable shared library mechanism for linking with the
|
|
110
|
+
Library. A suitable mechanism is one that (a) uses at run time
|
|
111
|
+
a copy of the Library already present on the user's computer
|
|
112
|
+
system, and (b) will operate properly with a modified version
|
|
113
|
+
of the Library that is interface-compatible with the Linked
|
|
114
|
+
Version.
|
|
115
|
+
|
|
116
|
+
e) Provide Installation Information, but only if you would otherwise
|
|
117
|
+
be required to provide such information under section 6 of the
|
|
118
|
+
GNU GPL, and only to the extent that such information is
|
|
119
|
+
necessary to install and execute a modified version of the
|
|
120
|
+
Combined Work produced by recombining or relinking the
|
|
121
|
+
Application with a modified version of the Linked Version. (If
|
|
122
|
+
you use option 4d0, the Installation Information must accompany
|
|
123
|
+
the Minimal Corresponding Source and Corresponding Application
|
|
124
|
+
Code. If you use option 4d1, you must provide the Installation
|
|
125
|
+
Information in the manner specified by section 6 of the GNU GPL
|
|
126
|
+
for conveying Corresponding Source.)
|
|
127
|
+
|
|
128
|
+
5. Combined Libraries.
|
|
129
|
+
|
|
130
|
+
You may place library facilities that are a work based on the
|
|
131
|
+
Library side by side in a single library together with other library
|
|
132
|
+
facilities that are not Applications and are not covered by this
|
|
133
|
+
License, and convey such a combined library under terms of your
|
|
134
|
+
choice, if you do both of the following:
|
|
135
|
+
|
|
136
|
+
a) Accompany the combined library with a copy of the same work based
|
|
137
|
+
on the Library, uncombined with any other library facilities,
|
|
138
|
+
conveyed under the terms of this License.
|
|
139
|
+
|
|
140
|
+
b) Give prominent notice with the combined library that part of it
|
|
141
|
+
is a work based on the Library, and explaining where to find the
|
|
142
|
+
accompanying uncombined form of the same work.
|
|
143
|
+
|
|
144
|
+
6. Revised Versions of the GNU Lesser General Public License.
|
|
145
|
+
|
|
146
|
+
The Free Software Foundation may publish revised and/or new versions
|
|
147
|
+
of the GNU Lesser General Public License from time to time. Such new
|
|
148
|
+
versions will be similar in spirit to the present version, but may
|
|
149
|
+
differ in detail to address new problems or concerns.
|
|
150
|
+
|
|
151
|
+
Each version is given a distinguishing version number. If the
|
|
152
|
+
Library as you received it specifies that a certain numbered version
|
|
153
|
+
of the GNU Lesser General Public License "or any later version"
|
|
154
|
+
applies to it, you have the option of following the terms and
|
|
155
|
+
conditions either of that published version or of any later version
|
|
156
|
+
published by the Free Software Foundation. If the Library as you
|
|
157
|
+
received it does not specify a version number of the GNU Lesser
|
|
158
|
+
General Public License, you may choose any version of the GNU Lesser
|
|
159
|
+
General Public License ever published by the Free Software Foundation.
|
|
160
|
+
|
|
161
|
+
If the Library as you received it specifies that a proxy can decide
|
|
162
|
+
whether future versions of the GNU Lesser General Public License shall
|
|
163
|
+
apply, that proxy's public statement of acceptance of any version is
|
|
164
|
+
permanent authorization for you to choose that version for the
|
|
165
|
+
Library.
|
package/README.md
CHANGED
|
@@ -3,19 +3,21 @@
|
|
|
3
3
|
Extract metadata (title, year, season, episode, codec, language, etc.) from media filenames — TypeScript port of Python [guessit](https://github.com/guessit-io/guessit).
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/guessit-js)
|
|
6
|
+
[](https://github.com/opensubtitles/guessit-js/actions/workflows/ci.yml)
|
|
6
7
|
[](https://www.gnu.org/licenses/lgpl-3.0)
|
|
8
|
+
[-brightgreen)](https://github.com/guessit-io/guessit)
|
|
7
9
|
|
|
8
|
-
**[Live Demo](https://opensubtitles.github.io/guessit-js)** · **[API Docs](https://opensubtitles.github.io/guessit-js/docs)** · **[
|
|
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)**
|
|
9
11
|
|
|
10
12
|
## Features
|
|
11
13
|
|
|
12
|
-
- **100% compatibility** with Python guessit (
|
|
14
|
+
- **100% compatibility** with Python guessit (1036/1036 fixtures passing) — and **more correct** in places: ships fixes for 32 upstream guessit bugs that Python still has (see [Differences from Python](#differences-from-python-guessit))
|
|
13
15
|
- **3.5x faster** than Python (6.87ms vs 23.86ms per parse)
|
|
14
|
-
- **
|
|
16
|
+
- **50 properties** detected: title, year, season, episode, resolution, codec, language, and more — with a [machine-readable schema](#output-schema)
|
|
15
17
|
- **Single dependency** ([rebulk-js](https://www.npmjs.com/package/rebulk-js))
|
|
16
18
|
- **Dual format**: ESM and CommonJS
|
|
17
|
-
- **TypeScript**: full type definitions
|
|
18
|
-
- **WASM**: runs in any WASI-compatible runtime
|
|
19
|
+
- **TypeScript**: full, precise type definitions (typed `GuessItResult`, enum'd value fields)
|
|
20
|
+
- **WASM**: runs in any WASI-compatible runtime, **bit-identical to the JS build**
|
|
19
21
|
|
|
20
22
|
## Install
|
|
21
23
|
|
|
@@ -39,6 +41,11 @@ const result = guessit('The.Dark.Knight.2008.1080p.BluRay.x264-GROUP.mkv');
|
|
|
39
41
|
// container: 'mkv',
|
|
40
42
|
// type: 'movie'
|
|
41
43
|
// }
|
|
44
|
+
|
|
45
|
+
// Short titles are handled correctly too:
|
|
46
|
+
guessit('X2.2003.720p.DSNP.WEB-DL.DDP5.1.H.264-EVO.mkv');
|
|
47
|
+
// { title: 'X2', year: 2003, screen_size: '720p',
|
|
48
|
+
// streaming_service: 'Disney+', source: 'Web', ... }
|
|
42
49
|
```
|
|
43
50
|
|
|
44
51
|
### CommonJS
|
|
@@ -71,34 +78,118 @@ guessit('file.mkv', { excludes: ['release_group'] });
|
|
|
71
78
|
| **Audio** | `audio_codec`, `audio_profile`, `audio_channels`, `audio_bit_rate` |
|
|
72
79
|
| **Source** | `source`, `streaming_service` |
|
|
73
80
|
| **Release** | `release_group`, `edition`, `other`, `proper_count` |
|
|
74
|
-
| **File** | `container
|
|
81
|
+
| **File** | `container` (video / subtitle / archive / image / nfo / torrent / nzb), `mimetype`, `size`, `crc32`, `uuid` |
|
|
75
82
|
| **Metadata** | `language`, `subtitle_language`, `country`, `type` |
|
|
76
83
|
|
|
84
|
+
### Output schema
|
|
85
|
+
|
|
86
|
+
The result is fully typed — import `GuessItResult` for autocomplete and type-checking:
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
import { guessit, properties, GUESSIT_SCHEMA, type GuessItResult } from 'guessit-js';
|
|
90
|
+
|
|
91
|
+
const r: GuessItResult = guessit('The.Dark.Knight.2008.1080p.BluRay.x264-GRP.mkv');
|
|
92
|
+
r.source; // typed as the closed enum: "Blu-ray" | "Web" | "HDTV" | …
|
|
93
|
+
|
|
94
|
+
properties(); // { source: ["Blu-ray", "Web", …], type: ["episode","movie"], … } for all 50 properties
|
|
95
|
+
GUESSIT_SCHEMA.source.enum; // the allowed values, programmatically
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- **`properties()`** — returns every emittable property with its possible values (value-constrained props list their full enum; free/computed props list `[null]`), mirroring Python guessit's `properties()`.
|
|
99
|
+
- **`GUESSIT_SCHEMA`** — the machine-readable schema (type, cardinality, enum) for all properties.
|
|
100
|
+
- **[`docs/output-schema.json`](docs/output-schema.json)** — a JSON Schema (draft-07) of the output, for validating results or generating clients in other languages.
|
|
101
|
+
|
|
102
|
+
Regenerate the schema (after parsing changes) with `npm run schema`. A test (`test/schema.test.ts`) guarantees it never goes stale — every value emitted across the corpus must be in the schema.
|
|
103
|
+
|
|
77
104
|
## REST API
|
|
78
105
|
|
|
79
106
|
```bash
|
|
80
107
|
npm start # port 3847
|
|
81
|
-
|
|
82
108
|
curl "http://localhost:3847/api/guessit?filename=Movie.2024.1080p.mkv"
|
|
83
109
|
```
|
|
84
110
|
|
|
85
111
|
## WASM
|
|
86
112
|
|
|
87
|
-
|
|
113
|
+
For non-JS environments (Rust, Go, C++, edge compute). Uses [Javy](https://github.com/bytecodealliance/javy) (QuickJS → WASM).
|
|
88
114
|
|
|
89
115
|
```bash
|
|
90
116
|
npm run wasm
|
|
91
117
|
echo '{"filename":"Movie.2024.1080p.mkv"}' | wasmtime wasm/guessit.wasm
|
|
92
118
|
```
|
|
93
119
|
|
|
120
|
+
The WASM build is **bit-identical to the JS build** across the entire test corpus
|
|
121
|
+
(1026/1026, including accented titles) — verified by `test/wasm-full.test.ts`.
|
|
122
|
+
|
|
123
|
+
## Differences from Python guessit
|
|
124
|
+
|
|
125
|
+
guessit-js is a faithful port (1036/1036 fixtures match Python 3.8.0), but it is
|
|
126
|
+
**not bug-for-bug identical** — where Python has a genuine parsing bug, guessit-js
|
|
127
|
+
is corrected. Highlights:
|
|
128
|
+
|
|
129
|
+
- **32 upstream guessit bugs fixed** that Python still gets wrong — e.g. `Us.2019`
|
|
130
|
+
(title vs country `US`), `The.Collector` (title vs edition), `X2.2003…` (short
|
|
131
|
+
title), `grown-ish…[eztv]` (hyphenated title split), `cd`-matching mid-hash, and
|
|
132
|
+
source/codec/extension tokens leaking into `release_group`/`title`. Full ledger:
|
|
133
|
+
[`docs/upstream-issues.md`](docs/upstream-issues.md).
|
|
134
|
+
- **More properties / better detection:** `imdb_id`/`tmdb_id`/`tvdb_id`, `volume`,
|
|
135
|
+
archive & image **containers** (`.rar`/`.7z`/`.jpg`…), artwork classification
|
|
136
|
+
(`poster`/`fanart` → `other`), VR / Opening-Ending credits, month-name dates,
|
|
137
|
+
CJK season/episode markers, and detection of Telugu/Spanish that Python misses.
|
|
138
|
+
- **Typed, schema-described output:** a precise `GuessItResult` interface, a
|
|
139
|
+
complete `properties()` (Python's is partial), and a JSON Schema.
|
|
140
|
+
- **No Python runtime:** zero runtime dependencies, ESM + CJS + WASM, ~3.5x faster.
|
|
141
|
+
- **Intentional divergences** (cases where guessit-js is *more* correct than
|
|
142
|
+
Python) are catalogued per-example in [`docs/python-parity.md`](docs/python-parity.md).
|
|
143
|
+
|
|
144
|
+
## Known issues
|
|
145
|
+
|
|
146
|
+
- **Music files are not supported** ([#599](https://github.com/guessit-io/guessit/issues/599)):
|
|
147
|
+
`Artist - Album/01 Track.flac` is parsed with the video vocabulary (title /
|
|
148
|
+
alternative_title), not `artist`/`album`/`track`. Out of scope for now.
|
|
149
|
+
- **No composite `quality` field** ([#802](https://github.com/guessit-io/guessit/issues/802)):
|
|
150
|
+
`screen_size`, `source` and `video_codec` are returned separately, not combined
|
|
151
|
+
into one string (the request is underspecified).
|
|
152
|
+
- **A few ambiguous anime conventions** remain
|
|
153
|
+
([#690](https://github.com/guessit-io/guessit/issues/690)/[#696](https://github.com/guessit-io/guessit/issues/696)/[#747](https://github.com/guessit-io/guessit/issues/747)):
|
|
154
|
+
e.g. `Re ZERO …- Season 2 - 15`, romaji + `(English title)` — no unambiguous
|
|
155
|
+
correct parse.
|
|
156
|
+
- **12 debatable cases** vs Python (neither clearly right) are listed under
|
|
157
|
+
"② NEUTRAL" in [`docs/python-parity.md`](docs/python-parity.md).
|
|
158
|
+
|
|
94
159
|
## Performance
|
|
95
160
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
|
100
|
-
|
|
161
|
+
Warm per-parse, measured on one machine (absolute numbers are hardware-dependent —
|
|
162
|
+
the [live demo](https://opensubtitles.github.io/guessit-js) times it in your browser):
|
|
163
|
+
|
|
164
|
+
| Runtime | ms/parse | Notes |
|
|
165
|
+
|---------|----------|-------|
|
|
166
|
+
| **Browser (V8)** | ~2–3 ms | fastest; JIT-compiled |
|
|
167
|
+
| **Node.js 22 (V8)** | ~4.4 ms | **~3.5× faster than Python** (same machine) — recommended for servers/CLI |
|
|
168
|
+
| **Python 3.8** | ~15.5 ms | reference |
|
|
169
|
+
| **WASM (QuickJS/Javy)** | ~35 ms warm · ~150 ms cold | for portability, **not** speed (see below) |
|
|
170
|
+
|
|
171
|
+
**About the WASM build.** It exists so you can run guessit in environments without
|
|
172
|
+
a JS engine (Rust, Go, C/C++, edge/WASI runtimes). Javy compiles the bundle to
|
|
173
|
+
**QuickJS**, which is an *interpreter* (no JIT), so per-parse compute (~35 ms) is
|
|
174
|
+
slower than V8 and even than Python — that's inherent to the engine, not the code.
|
|
175
|
+
If you want speed, use the Node/browser build (V8). If you need WASM, the levers
|
|
176
|
+
that actually help:
|
|
177
|
+
|
|
178
|
+
- **Amortize startup** — instantiate the module once and parse many filenames;
|
|
179
|
+
most of the ~150 ms single-shot cost is wasmtime + module init, not parsing.
|
|
180
|
+
- **AOT-compile the module** (`wasmtime compile guessit.wasm -o guessit.cwasm`)
|
|
181
|
+
to skip per-run JIT of the wasm itself (~30 ms off cold start).
|
|
182
|
+
- The ~35 ms warm floor is QuickJS interpretation; beating it would require a
|
|
183
|
+
JIT-capable WASI JS engine (none production-ready) or a native port — out of
|
|
184
|
+
scope. WASM correctness is **bit-identical** to the JS build.
|
|
101
185
|
|
|
102
186
|
## License
|
|
103
187
|
|
|
104
|
-
|
|
188
|
+
Copyright (C) 2024-2026 OpenSubtitles
|
|
189
|
+
|
|
190
|
+
Licensed under the [GNU Lesser General Public License v3.0](LICENSE) (LGPL-3.0),
|
|
191
|
+
the same license as the original Python [guessit](https://github.com/guessit-io/guessit)
|
|
192
|
+
library this project is ported from.
|
|
193
|
+
|
|
194
|
+
Build-time and embedded third-party components (Javy, QuickJS) are covered in
|
|
195
|
+
[THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
package/dist/api.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Rebulk } from 'rebulk-js';
|
|
2
2
|
import { AdvancedConfig } from './rules/index.js';
|
|
3
3
|
import { RawOptions } from './options.js';
|
|
4
|
+
import { GuessItResult } from './schema.js';
|
|
4
5
|
|
|
6
|
+
export type { GuessItResult, GuessitLanguage, PropertySchema } from './schema.js';
|
|
7
|
+
export { GUESSIT_SCHEMA } from './schema.js';
|
|
5
8
|
export declare class GuessItException extends Error {
|
|
6
9
|
string: string;
|
|
7
10
|
options: Record<string, unknown>;
|
|
8
11
|
constructor(string: string, options: Record<string, unknown>, cause?: unknown);
|
|
9
12
|
}
|
|
10
|
-
export interface GuessItResult {
|
|
11
|
-
[key: string]: unknown;
|
|
12
|
-
}
|
|
13
13
|
export declare class GuessItApi {
|
|
14
14
|
private _rebulk;
|
|
15
15
|
private _config;
|