guessit-js 4.9.0 → 4.10.0
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 +18 -11
- package/bin/cli.mjs +9 -2
- package/dist/guessit-js.cjs +2 -2
- package/dist/guessit-js.cjs.map +1 -1
- package/dist/guessit-js.js +211 -127
- package/dist/guessit-js.js.map +1 -1
- package/dist/schema.d.ts +14 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Extract metadata (title, year, season, episode, codec, language, etc.) from medi
|
|
|
14
14
|
|
|
15
15
|
- **Runs 2191 of the 2229 cases in Python guessit's own test suite** (upstream 4.5.1, its corpus *and* its per-rule files) — and is **more correct**: fixes for 32 historical upstream bugs, Python's still-open #877, and 114 of the 276 cross-parser cases Python admits failing (see [Differences from Python](#differences-from-python-guessit))
|
|
16
16
|
- **~2x faster** than Python per parse ([measured](#performance))
|
|
17
|
-
- **
|
|
17
|
+
- **56 properties** detected: title, year, season, episode, resolution, codec, language, ids, and more — with a [machine-readable schema](#output-schema)
|
|
18
18
|
- **Batch parsing**: `guessitMany()` in-process, or one POST for up to 100 names
|
|
19
19
|
- **Zero runtime dependencies** ([rebulk-js](https://www.npmjs.com/package/rebulk-js) is bundled at build time)
|
|
20
20
|
- **Dual format**: ESM and CommonJS
|
|
@@ -30,8 +30,12 @@ npm install guessit-js
|
|
|
30
30
|
## CLI
|
|
31
31
|
|
|
32
32
|
**Drop-in replacement** for the Python `guessit` command — same flags, same
|
|
33
|
-
output formats
|
|
34
|
-
|
|
33
|
+
output formats, byte-compared against the real Python CLI in CI on every push.
|
|
34
|
+
The one field excluded from that comparison is `mimetype`: Python reads it from
|
|
35
|
+
the operating system's MIME table, so the same `.mkv` is `video/matroska` on a
|
|
36
|
+
GitHub runner and `video/x-matroska` on macOS, while this port returns the
|
|
37
|
+
conventional `x-` spelling everywhere. Installs both `guessit-js` and `guessit`
|
|
38
|
+
binaries:
|
|
35
39
|
|
|
36
40
|
```bash
|
|
37
41
|
npx guessit-js "The.Dark.Knight.2008.1080p.BluRay.x264-GROUP.mkv"
|
|
@@ -133,16 +137,19 @@ import { version } from 'guessit-js'; // package version string
|
|
|
133
137
|
|
|
134
138
|
## Detected Properties
|
|
135
139
|
|
|
140
|
+
All 56, the same set `properties()` advertises:
|
|
141
|
+
|
|
136
142
|
| Category | Properties |
|
|
137
143
|
|----------|-----------|
|
|
138
|
-
| **Title** | `title`, `alternative_title`, `episode_title` |
|
|
139
|
-
| **Episode** | `season`, `episode`, `episode_details`, `episode_count`, `season_count`, `absolute_episode`, `disc`, `part` |
|
|
140
|
-
| **Date** | `year`, `date` |
|
|
141
|
-
| **Video** | `screen_size`, `aspect_ratio`, `frame_rate`, `video_codec`, `video_profile`, `color_depth` |
|
|
144
|
+
| **Title** | `title`, `alternative_title`, `episode_title`, `film_title`, `bonus_title` |
|
|
145
|
+
| **Episode** | `season`, `episode`, `episode_details`, `episode_count`, `season_count`, `episode_format`, `absolute_episode`, `credits_number`, `disc`, `part`, `version`, `cd`, `cd_count` |
|
|
146
|
+
| **Date** | `year`, `date`, `week` |
|
|
147
|
+
| **Video** | `screen_size`, `aspect_ratio`, `frame_rate`, `video_codec`, `video_profile`, `video_api`, `video_bit_rate`, `color_depth` |
|
|
142
148
|
| **Audio** | `audio_codec`, `audio_profile`, `audio_channels`, `audio_bit_rate` |
|
|
143
|
-
| **Source** | `source`, `streaming_service` |
|
|
144
|
-
| **Release** | `release_group`, `edition`, `other`, `proper_count` |
|
|
145
|
-
| **
|
|
149
|
+
| **Source** | `source`, `streaming_service`, `website` |
|
|
150
|
+
| **Release** | `release_group`, `edition`, `other`, `proper_count`, `film`, `bonus`, `volume`, `another` |
|
|
151
|
+
| **Ids** | `imdb_id`, `tmdb_id`, `tvdb_id`, `uuid`, `crc32` |
|
|
152
|
+
| **File** | `container` (video / subtitle / archive / image / nfo / torrent / nzb), `mimetype`, `size` |
|
|
146
153
|
| **Metadata** | `language`, `subtitle_language`, `country`, `type` |
|
|
147
154
|
|
|
148
155
|
### Output schema
|
|
@@ -155,7 +162,7 @@ import { guessit, properties, GUESSIT_SCHEMA, type GuessItResult } from 'guessit
|
|
|
155
162
|
const r: GuessItResult = guessit('The.Dark.Knight.2008.1080p.BluRay.x264-GRP.mkv');
|
|
156
163
|
r.source; // typed as the closed enum: "Blu-ray" | "Web" | "HDTV" | …
|
|
157
164
|
|
|
158
|
-
properties(); // { source: ["Blu-ray", "Web", …], type: ["episode","movie"], … } for all
|
|
165
|
+
properties(); // { source: ["Blu-ray", "Web", …], type: ["episode","movie"], … } for all 56 properties
|
|
159
166
|
GUESSIT_SCHEMA.source.enum; // the allowed values, programmatically
|
|
160
167
|
```
|
|
161
168
|
|
package/bin/cli.mjs
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { readFileSync, existsSync } from 'fs';
|
|
7
7
|
import { homedir } from 'os';
|
|
8
8
|
import { join } from 'path';
|
|
9
|
-
import { guessit, properties as apiProperties, version } from '../dist/guessit-js.js';
|
|
9
|
+
import { guessit, guessitMany, properties as apiProperties, version } from '../dist/guessit-js.js';
|
|
10
10
|
|
|
11
11
|
// Parsing cost grows with the square of the number of matches a name yields, so
|
|
12
12
|
// a long synthetic string costs far more than its length suggests: 400
|
|
@@ -424,7 +424,14 @@ if (serve) {
|
|
|
424
424
|
sendJson(res, 413, { error: `filename exceeds ${MAX_FILENAME_LENGTH} characters` });
|
|
425
425
|
return;
|
|
426
426
|
}
|
|
427
|
-
|
|
427
|
+
// One entry per name, each {input_string, result} or {input_string, error} —
|
|
428
|
+
// the documented contract, shared with server.ts and the Cloudflare worker.
|
|
429
|
+
// guessitMany parses the options once and isolates a name that throws.
|
|
430
|
+
sendJson(res, 200, guessitMany(names, opts).map((entry) => (
|
|
431
|
+
'result' in entry
|
|
432
|
+
? { input_string: entry.input_string, result: display(entry.result, 'json') }
|
|
433
|
+
: entry
|
|
434
|
+
)));
|
|
428
435
|
} else if (typeof body.filename === 'string') {
|
|
429
436
|
if (body.filename.length > MAX_FILENAME_LENGTH) {
|
|
430
437
|
sendJson(res, 413, { error: `filename exceeds ${MAX_FILENAME_LENGTH} characters` });
|