guessit-js 4.5.3 → 4.6.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 CHANGED
@@ -27,16 +27,32 @@ npm install guessit-js
27
27
 
28
28
  ## CLI
29
29
 
30
+ **Drop-in replacement** for the Python `guessit` command — same flags, same
31
+ output formats (verified against the real Python CLI in CI). Installs both
32
+ `guessit-js` and `guessit` binaries:
33
+
30
34
  ```bash
31
35
  npx guessit-js "The.Dark.Knight.2008.1080p.BluRay.x264-GROUP.mkv"
32
36
  # title: The Dark Knight
33
37
  # year: 2008
34
38
  # ...
35
39
 
36
- npx guessit-js -j "Mob Psycho 100 - 09.mkv" # JSON output
40
+ npx guessit-js -j "Mob Psycho 100 - 09.mkv" # JSON (-y YAML, --jsonl streaming)
41
+ npx guessit-js -P title "Movie.2020.mkv" # single property
37
42
  npx guessit-js -t episode "ambiguous.file.mkv" # force type
43
+ npx guessit-js @list.txt # filenames from file (also -f list.txt)
44
+ find . -name '*.mkv' | npx guessit-js --jsonl # from stdin, one JSON per line
45
+ npx guessit-js -a "Movie.2020.mkv" # advanced: value/raw/start/end
46
+ npx guessit-js -p # list detectable properties (-V with values)
38
47
  ```
39
48
 
49
+ Parsing options match the Python CLI: `-n` name-only, `-Y`/`-D` date order,
50
+ `-L`/`-C` allowed languages/countries, `-E` episode-prefer-number,
51
+ `-T`/`-G` expected title/group, `--includes`/`--excludes`, `-s` single-value,
52
+ `-v` verbose. User config is auto-loaded from `~/.guessit/options.json` and
53
+ `~/.config/guessit/options.json` (`.yaml`/`.yml` too; disable with
54
+ `--no-user-config`), plus explicit `-c <file>`. See `npx guessit-js --help`.
55
+
40
56
  ## Usage
41
57
 
42
58
  ```typescript
package/bin/cli.mjs CHANGED
@@ -1,51 +1,364 @@
1
1
  #!/usr/bin/env node
2
- // guessit-js CLI — mirrors the Python `guessit` command.
3
- // guessit-js <filename> [<filename> ...] property: value lines
4
- // guessit-js -j <filename> JSON output
5
- // guessit-js -t movie <filename> force type
6
- import { guessit, version } from '../dist/guessit-js.js';
2
+ // guessit-js CLI — drop-in replacement for the Python `guessit` command.
3
+ // Same flags, same output formats (For:/GuessIt found:, -j compact JSON with
4
+ // Python separators, -y ?-key YAML), same user-config loading.
5
+ // Zero dependencies; the library is bundled in dist/.
6
+ import { readFileSync, existsSync } from 'fs';
7
+ import { homedir } from 'os';
8
+ import { join } from 'path';
9
+ import { guessit, properties as apiProperties, version } from '../dist/guessit-js.js';
7
10
 
11
+ // Python's GuessitEncoder emits babelfish `.name` in JSON ("English",
12
+ // "UNITED STATES") while YAML uses str() ("en", "pt-BR", "US"). Mirror both.
13
+ const ALPHA3_TO_2 = {"eng":"en","fra":"fr","deu":"de","spa":"es","ita":"it","por":"pt","rus":"ru","jpn":"ja","zho":"zh","kor":"ko","ara":"ar","hin":"hi","tur":"tr","pol":"pl","nld":"nl","swe":"sv","dan":"da","nor":"no","fin":"fi","hun":"hu","ces":"cs","ron":"ro","ukr":"uk","heb":"he","cat":"ca","vie":"vi","tha":"th","ind":"id","mal":"ml","tel":"te","tam":"ta","bul":"bg","hrv":"hr","srp":"sr","slk":"sk","slv":"sl","ell":"el","lit":"lt","lav":"lv","est":"et","glg":"gl","eus":"eu","ben":"bn","isl":"is","mkd":"mk","bos":"bs","alb":"sq","per":"fa","msa":"ms","mon":"mn","urd":"ur","pan":"pa","guj":"gu","kan":"kn","mar":"mr","asm":"as","mya":"my","khm":"km","lao":"lo"};
14
+ const LANGUAGE_NAMES = {"eng":"English","fra":"French","deu":"German","spa":"Spanish","ita":"Italian","por":"Portuguese","rus":"Russian","jpn":"Japanese","zho":"Chinese","kor":"Korean","ara":"Arabic","hin":"Hindi","tur":"Turkish","pol":"Polish","nld":"Dutch","swe":"Swedish","dan":"Danish","nor":"Norwegian","fin":"Finnish","hun":"Hungarian","ces":"Czech","ron":"Romanian","ukr":"Ukrainian","heb":"Hebrew","cat":"Catalan","vie":"Vietnamese","tha":"Thai","ind":"Indonesian","mal":"Malayalam","tel":"Telugu","tam":"Tamil","bul":"Bulgarian","hrv":"Croatian","srp":"Serbian","slk":"Slovak","slv":"Slovenian","ell":"Greek","lit":"Lithuanian","lav":"Latvian","est":"Estonian","glg":"Galician","eus":"Basque","ben":"Bengali","isl":"Icelandic","mkd":"Macedonian","bos":"Bosnian","alb":"Albanian","per":"Persian","msa":"Malay","mon":"Mongolian","urd":"Urdu","pan":"Punjabi","guj":"Gujarati","kan":"Kannada","mar":"Marathi","asm":"Assamese","mya":"Burmese","khm":"Khmer","lao":"Lao"};
15
+ const COUNTRY_NAMES = {"US":"UNITED STATES","GB":"UNITED KINGDOM","AU":"AUSTRALIA","CA":"CANADA","NZ":"NEW ZEALAND","IE":"IRELAND","FR":"FRANCE","DE":"GERMANY","ES":"SPAIN","IT":"ITALY","BR":"BRAZIL","PT":"PORTUGAL","RU":"RUSSIAN FEDERATION","JP":"JAPAN","CN":"CHINA","TW":"TAIWAN, PROVINCE OF CHINA","HK":"HONG KONG","KR":"KOREA, REPUBLIC OF","IN":"INDIA","MX":"MEXICO","NL":"NETHERLANDS","SE":"SWEDEN","NO":"NORWAY","DK":"DENMARK","FI":"FINLAND","PL":"POLAND","CH":"SWITZERLAND","AT":"AUSTRIA","BE":"BELGIUM","CZ":"CZECHIA","GR":"GREECE","HU":"HUNGARY","RO":"ROMANIA","TR":"TURKEY","UA":"UKRAINE","AR":"ARGENTINA","ZA":"SOUTH AFRICA"};
16
+
17
+ const HELP = `usage: guessit-js [options] [filename ...]
18
+
19
+ positional arguments:
20
+ filename Filename or release name to guess (@list.txt reads
21
+ one filename per line; - reads stdin)
22
+
23
+ Naming:
24
+ -t TYPE, --type TYPE The suggested file type: movie or episode
25
+ -n, --name-only Parse files as name only, without extension
26
+ -Y, --date-year-first Take the year first when parsing an ambiguous date
27
+ -D, --date-day-first Take the day first when parsing an ambiguous date
28
+ -L ALLOWED_LANGUAGES, --allowed-languages ALLOWED_LANGUAGES
29
+ Allowed language (comma-separated, repeatable)
30
+ -C ALLOWED_COUNTRIES, --allowed-countries ALLOWED_COUNTRIES
31
+ Allowed country (comma-separated, repeatable)
32
+ -E, --episode-prefer-number
33
+ Guess "serie.213.avi" as episode 213
34
+ -T EXPECTED_TITLE, --expected-title EXPECTED_TITLE
35
+ Expected title (repeatable)
36
+ -G EXPECTED_GROUP, --expected-group EXPECTED_GROUP
37
+ Expected release group (repeatable)
38
+ --includes INCLUDES Properties to include (comma-separated, repeatable)
39
+ --excludes EXCLUDES Properties to exclude (comma-separated, repeatable)
40
+
41
+ Input:
42
+ -f INPUT_FILE, --input-file INPUT_FILE
43
+ Read filenames from this file (- for stdin)
44
+
45
+ Output:
46
+ -v, --verbose Display debug output
47
+ -P SHOW_PROPERTY, --show-property SHOW_PROPERTY
48
+ Display only the given property value
49
+ -a, --advanced Display advanced information for filename guesses
50
+ -s, --single-value Keep only the first value found for each property
51
+ -j, --json Display information for filename guesses as json output
52
+ --jsonl Alias of --json (one object per line)
53
+ -y, --yaml Display information for filename guesses as yaml output
54
+ -i, --output-input-string
55
+ Add input_string property in the output
56
+
57
+ Configuration:
58
+ -c CONFIG_FILE, --config CONFIG_FILE
59
+ Config file to use (JSON, or simple flat YAML)
60
+ --no-user-config Disable user config (~/.guessit/options.json,
61
+ ~/.config/guessit/options.json, .yaml/.yml variants)
62
+ --no-default-config Disable the embedded default config
63
+
64
+ Information:
65
+ -p, --properties Display properties that can be guessed
66
+ -V, --values Display property values that can be guessed
67
+ --version Display the guessit-js version banner
68
+
69
+ Exit codes: 0 success, 1 processing error, 2 usage error.`;
70
+
71
+ function fail(msg) {
72
+ console.error(msg);
73
+ process.exit(2);
74
+ }
75
+
76
+ function readLines(path) {
77
+ const text = path === '-' ? readFileSync(0, 'utf8') : readFileSync(path, 'utf8');
78
+ return text.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
79
+ }
80
+
81
+ // Minimal config-file reader: JSON first, then a flat "key: value" YAML subset
82
+ // (scalars, [a, b] inline lists, "- item" block lists).
83
+ function readConfigFile(path) {
84
+ const text = readFileSync(path, 'utf8');
85
+ try { return JSON.parse(text); } catch { /* fall through to flat YAML */ }
86
+ const out = {};
87
+ let listKey = null;
88
+ for (const rawLine of text.split(/\r?\n/)) {
89
+ const line = rawLine.replace(/#.*$/, '').trimEnd();
90
+ if (!line.trim()) continue;
91
+ const item = line.match(/^\s+-\s+(.*)$/);
92
+ if (item && listKey) { out[listKey].push(parseScalar(item[1])); continue; }
93
+ const kv = line.match(/^([\w-]+):\s*(.*)$/);
94
+ if (!kv) continue;
95
+ const [, key, value] = kv;
96
+ if (!value) { out[key] = []; listKey = key; continue; }
97
+ listKey = null;
98
+ if (value.startsWith('[') && value.endsWith(']')) {
99
+ out[key] = value.slice(1, -1).split(',').map((s) => parseScalar(s.trim())).filter((s) => s !== '');
100
+ } else {
101
+ out[key] = parseScalar(value);
102
+ }
103
+ }
104
+ return out;
105
+ }
106
+ function parseScalar(s) {
107
+ if (s === 'true' || s === 'yes') return true;
108
+ if (s === 'false' || s === 'no') return false;
109
+ if (s === 'null' || s === '~') return null;
110
+ if (/^-?\d+(\.\d+)?$/.test(s)) return Number(s);
111
+ return s.replace(/^['"]|['"]$/g, '');
112
+ }
113
+
114
+ // ---- argument parsing -------------------------------------------------------
8
115
  const args = process.argv.slice(2);
9
116
  const filenames = [];
10
- let json = false;
11
- let type = null;
117
+ const cliOptions = {};
118
+ const configOptions = {};
119
+ let output = 'default';
120
+ let showProperty = null;
121
+ let verbose = false;
122
+ let listProperties = false;
123
+ let listValues = false;
124
+ let noUserConfig = false;
125
+ let endOfOptions = false;
126
+
127
+ const needsValue = (a, i) => {
128
+ if (i + 1 >= args.length) fail(`option ${a} requires a value`);
129
+ return args[i + 1];
130
+ };
131
+ const pushList = (key, raw) => {
132
+ cliOptions[key] = (cliOptions[key] || []).concat(raw.split(',').map((s) => s.trim()).filter(Boolean));
133
+ };
12
134
 
13
135
  for (let i = 0; i < args.length; i++) {
14
136
  const a = args[i];
15
- if (a === '-j' || a === '--json') json = true;
16
- else if (a === '-t' || a === '--type') type = args[++i];
17
- else if (a === '-v' || a === '--version') {
18
- console.log(version);
19
- process.exit(0);
20
- } else if (a === '-h' || a === '--help') {
21
- console.log(`guessit-js ${version} — extract metadata from media filenames
22
-
23
- Usage: guessit-js [options] <filename> [<filename> ...]
24
-
25
- Options:
26
- -j, --json output JSON (single object, or array for multiple files)
27
- -t, --type <type> suggested type: movie or episode
28
- -v, --version print version
29
- -h, --help this help`);
30
- process.exit(0);
31
- } else filenames.push(a);
32
- }
33
-
34
- if (!filenames.length) {
35
- console.error('usage: guessit-js [options] <filename> — see --help');
36
- process.exit(2);
137
+ if (endOfOptions || !a.startsWith('-') || a === '-') {
138
+ if (a.startsWith('@') && a.length > 1 && !endOfOptions) filenames.push(...readLines(a.slice(1)));
139
+ else if (a === '-') filenames.push(...readLines('-'));
140
+ else filenames.push(a);
141
+ continue;
142
+ }
143
+ switch (a) {
144
+ case '--': endOfOptions = true; break;
145
+ case '-j': case '--json': case '--jsonl': output = 'json'; break;
146
+ case '-y': case '--yaml': output = 'yaml'; break;
147
+ case '-P': case '--show-property': showProperty = needsValue(a, i); i++; break;
148
+ case '-f': case '--input-file': filenames.push(...readLines(needsValue(a, i))); i++; break;
149
+ case '-i': case '--output-input-string': cliOptions.output_input_string = true; break;
150
+ case '-t': case '--type': cliOptions.type = needsValue(a, i); i++; break;
151
+ case '-n': case '--name-only': cliOptions.name_only = true; break;
152
+ case '-Y': case '--date-year-first': cliOptions.date_year_first = true; break;
153
+ case '-D': case '--date-day-first': cliOptions.date_day_first = true; break;
154
+ case '-L': case '--allowed-languages': pushList('allowed_languages', needsValue(a, i)); i++; break;
155
+ case '-C': case '--allowed-countries': pushList('allowed_countries', needsValue(a, i)); i++; break;
156
+ case '-E': case '--episode-prefer-number': cliOptions.episode_prefer_number = true; break;
157
+ case '-T': case '--expected-title': pushList('expected_title', needsValue(a, i)); i++; break;
158
+ case '-G': case '--expected-group': pushList('expected_group', needsValue(a, i)); i++; break;
159
+ case '--includes': pushList('includes', needsValue(a, i)); i++; break;
160
+ case '--excludes': pushList('excludes', needsValue(a, i)); i++; break;
161
+ case '-s': case '--single-value': cliOptions.single_value = true; break;
162
+ case '-a': case '--advanced': cliOptions.advanced = true; break;
163
+ case '-v': case '--verbose': verbose = true; break;
164
+ case '-c': case '--config': {
165
+ const path = needsValue(a, i); i++;
166
+ try { Object.assign(configOptions, readConfigFile(path)); }
167
+ catch (e) { fail(`cannot read config ${path}: ${e.message}`); }
168
+ break;
169
+ }
170
+ case '--no-user-config': noUserConfig = true; cliOptions.no_user_config = true; break;
171
+ case '--no-default-config': cliOptions.no_default_config = true; break;
172
+ case '-p': case '--properties': listProperties = true; break;
173
+ case '-V': case '--values': listValues = true; break;
174
+ case '--version': {
175
+ console.log('+-------------------------------------------------------+');
176
+ console.log(`+ GuessIt-JS ${version}`.padEnd(56) + '+');
177
+ console.log('+-------------------------------------------------------+');
178
+ console.log('| Please report any bug or feature request at |');
179
+ console.log('| https://github.com/opensubtitles/guessit-js/issues. |');
180
+ console.log('+-------------------------------------------------------+');
181
+ process.exit(0);
182
+ break;
183
+ }
184
+ case '-h': case '--help': console.log(HELP); process.exit(0); break;
185
+ default: fail(`unknown option: ${a} — see --help`);
186
+ }
37
187
  }
38
188
 
39
- const options = type ? { type } : {};
40
- const results = filenames.map((f) => guessit(f, options));
189
+ // User config, same locations as Python guessit.
190
+ if (!noUserConfig) {
191
+ const home = homedir();
192
+ for (const dir of [join(home, '.guessit'), join(home, '.config', 'guessit')]) {
193
+ for (const ext of ['json', 'yaml', 'yml']) {
194
+ const path = join(dir, `options.${ext}`);
195
+ if (existsSync(path)) {
196
+ try { Object.assign(configOptions, readConfigFile(path)); } catch { /* ignore broken user config */ }
197
+ }
198
+ }
199
+ }
200
+ }
41
201
 
42
- if (json) {
43
- console.log(JSON.stringify(filenames.length === 1 ? results[0] : results, null, 2));
44
- } else {
45
- results.forEach((r, i) => {
46
- if (filenames.length > 1) console.log(`${i ? '\n' : ''}For: ${filenames[i]}`);
47
- for (const [k, v] of Object.entries(r)) {
48
- console.log(`${k}: ${Array.isArray(v) ? JSON.stringify(v) : v}`);
202
+ // Precedence: user/explicit config < CLI flags.
203
+ const options = { ...configOptions, ...cliOptions };
204
+ for (const key of ['allowed_languages', 'allowed_countries', 'expected_title', 'expected_group', 'includes', 'excludes']) {
205
+ if (configOptions[key] && cliOptions[key]) options[key] = [...configOptions[key], ...cliOptions[key]];
206
+ }
207
+
208
+ if (options.type && options.type !== 'movie' && options.type !== 'episode') {
209
+ fail(`invalid --type "${options.type}": must be movie or episode`);
210
+ }
211
+
212
+ // ---- value + output formatting ---------------------------------------------
213
+ // Python: JSON output uses babelfish .name ("English", "UNITED STATES"),
214
+ // YAML output uses str() ("en", "pt-BR", "US"); dates become ISO strings.
215
+ function display(v, mode, key) {
216
+ if (Array.isArray(v)) return v.map((x) => display(x, mode, key));
217
+ if (v instanceof Date) return v.toISOString().slice(0, 10);
218
+ if (v && typeof v === 'object') {
219
+ if (typeof v.alpha3 === 'string') {
220
+ if (mode === 'yaml') {
221
+ const base = ALPHA3_TO_2[v.alpha3] || v.alpha3;
222
+ return v.country ? `${base}-${v.country}` : base;
223
+ }
224
+ return LANGUAGE_NAMES[v.alpha3] || v.alpha3;
49
225
  }
50
- });
226
+ const out = {};
227
+ for (const [k, val] of Object.entries(v)) out[k] = display(val, mode, k);
228
+ return out;
229
+ }
230
+ if (key === 'country' && typeof v === 'string' && mode !== 'yaml') {
231
+ return COUNTRY_NAMES[v] || v;
232
+ }
233
+ return v;
234
+ }
235
+
236
+ // json.dumps-compatible emitters (Python uses ", " / ": " separators).
237
+ function pyJson(v) {
238
+ if (Array.isArray(v)) return '[' + v.map(pyJson).join(', ') + ']';
239
+ if (v && typeof v === 'object') {
240
+ return '{' + Object.entries(v).map(([k, val]) => `${JSON.stringify(k)}: ${pyJson(val)}`).join(', ') + '}';
241
+ }
242
+ return JSON.stringify(v);
243
+ }
244
+ function pyJsonIndent(v, level = 1) {
245
+ const pad = ' '.repeat(level);
246
+ const close = ' '.repeat(level - 1);
247
+ if (Array.isArray(v)) {
248
+ if (!v.length) return '[]';
249
+ return '[\n' + v.map((x) => pad + pyJsonIndent(x, level + 1)).join(',\n') + `\n${close}]`;
250
+ }
251
+ if (v && typeof v === 'object') {
252
+ const entries = Object.entries(v);
253
+ if (!entries.length) return '{}';
254
+ return '{\n' + entries.map(([k, x]) => `${pad}${JSON.stringify(k)}: ${pyJsonIndent(x, level + 1)}`).join(',\n') + `\n${close}}`;
255
+ }
256
+ return JSON.stringify(v);
257
+ }
258
+
259
+ function yamlScalar(v) {
260
+ if (typeof v !== 'string') return String(v);
261
+ const needsQuote =
262
+ /^[\s'"&*?|>%@`!,\[\]{}#-]/.test(v) || /: /.test(v) || / #/.test(v) ||
263
+ /[\n\t]/.test(v) || /\s$/.test(v) || v.endsWith(':') ||
264
+ /^(true|false|null|yes|no|on|off|~)$/i.test(v) || /^-?[\d.]+$/.test(v);
265
+ // pyyaml prefers single-quoted style
266
+ return needsQuote ? `'${v.replace(/'/g, "''")}'` : v;
267
+ }
268
+ function toYaml(value, indent) {
269
+ if (Array.isArray(value)) {
270
+ return value.map((v) =>
271
+ typeof v === 'object' && v !== null
272
+ ? `${indent}-\n${toYaml(v, indent + ' ')}`
273
+ : `${indent}- ${yamlScalar(v)}`
274
+ ).join('\n');
275
+ }
276
+ if (typeof value === 'object' && value !== null) {
277
+ return Object.entries(value).map(([k, v]) => {
278
+ if (Array.isArray(v)) return `${indent}${k}:\n${toYaml(v, indent)}`; // pyyaml: list items at key level
279
+ if (typeof v === 'object' && v !== null) return `${indent}${k}:\n${toYaml(v, indent + ' ')}`;
280
+ return `${indent}${k}: ${yamlScalar(v)}`;
281
+ }).join('\n');
282
+ }
283
+ return indent + yamlScalar(value);
284
+ }
285
+
286
+ // Advanced mode returns live Match objects; reduce them to the Python shape.
287
+ function simplifyAdvanced(v) {
288
+ if (Array.isArray(v)) return v.map(simplifyAdvanced);
289
+ if (v && typeof v === 'object' && 'start' in v && 'end' in v) {
290
+ const out = { value: display(v.value, 'json') };
291
+ if (v.raw) out.raw = v.raw; // Python omits raw for synthesized matches
292
+ out.start = v.start;
293
+ out.end = v.end;
294
+ return out;
295
+ }
296
+ return v;
51
297
  }
298
+
299
+ // ---- introspection modes ----------------------------------------------------
300
+ if (listProperties || listValues) {
301
+ const props = apiProperties(options);
302
+ for (const name of Object.keys(props).sort()) {
303
+ if (listValues) {
304
+ const vals = (props[name] || []).filter((v) => v !== null && v !== undefined);
305
+ console.log(`${name}${vals.length ? ': ' + vals.join(', ') : ''}`);
306
+ } else {
307
+ console.log(name);
308
+ }
309
+ }
310
+ process.exit(0);
311
+ }
312
+
313
+ // ---- main -------------------------------------------------------------------
314
+ if (!process.stdin.isTTY && !filenames.length) {
315
+ filenames.push(...readLines('-'));
316
+ }
317
+ if (!filenames.length) fail('usage: guessit-js [options] <filename> — see --help');
318
+
319
+ let hadError = false;
320
+ for (const filename of filenames) {
321
+ let result;
322
+ try {
323
+ const raw = guessit(filename, options);
324
+ if (options.advanced) {
325
+ result = {};
326
+ for (const [k, v] of Object.entries(raw)) result[k] = simplifyAdvanced(v);
327
+ } else {
328
+ result = display(raw, output === 'yaml' ? 'yaml' : 'json');
329
+ }
330
+ } catch (e) {
331
+ hadError = true;
332
+ result = { error: String((e && e.message) || e) };
333
+ }
334
+
335
+ if (verbose && output === 'default' && !showProperty) {
336
+ // Approximation of Python's rebulk debug log: one line per final match.
337
+ try {
338
+ const adv = guessit(filename, { ...options, advanced: true });
339
+ for (const [name, v] of Object.entries(adv)) {
340
+ for (const m of Array.isArray(v) ? v : [v]) {
341
+ if (m && typeof m === 'object' && 'start' in m) {
342
+ console.log(`Match found. (<${m.raw}:(${m.start}, ${m.end})+name=${name}>)`);
343
+ }
344
+ }
345
+ }
346
+ } catch { /* debug output is best-effort */ }
347
+ }
348
+
349
+ if (showProperty) {
350
+ const v = result[showProperty];
351
+ console.log(v === undefined ? '' : typeof v === 'object' && v !== null ? pyJson(v) : String(v));
352
+ } else if (output === 'json') {
353
+ console.log(pyJson(result));
354
+ } else if (output === 'yaml') {
355
+ console.log(`? ${yamlScalar(filename)}`);
356
+ const body = toYaml(result, ' ');
357
+ console.log(':' + body.slice(1));
358
+ } else {
359
+ console.log(`For: ${filename}`);
360
+ console.log(`GuessIt found: ${pyJsonIndent(result)}`);
361
+ }
362
+ }
363
+
364
+ process.exit(hadError ? 1 : 0);
@@ -14516,7 +14516,7 @@ function configure(options, rulesBuilder, force = false) {
14516
14516
  function reset() {
14517
14517
  defaultApi.reset();
14518
14518
  }
14519
- const version$1 = "4.5.3";
14519
+ const version$1 = "4.6.0";
14520
14520
  const version = version$1;
14521
14521
  exports.GUESSIT_SCHEMA = GUESSIT_SCHEMA;
14522
14522
  exports.GuessItApi = GuessItApi;
@@ -14514,7 +14514,7 @@ function configure(options, rulesBuilder, force = false) {
14514
14514
  function reset() {
14515
14515
  defaultApi.reset();
14516
14516
  }
14517
- const version$1 = "4.5.3";
14517
+ const version$1 = "4.6.0";
14518
14518
  const version = version$1;
14519
14519
  export {
14520
14520
  GUESSIT_SCHEMA,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "guessit-js",
3
- "version": "4.5.3",
3
+ "version": "4.6.0",
4
4
  "description": "Extract metadata (title, year, season, episode, codec, language, etc.) from media filenames — TypeScript port of Python guessit",
5
5
  "keywords": [
6
6
  "guessit",
@@ -35,7 +35,8 @@
35
35
  "types": "./dist/index.d.ts",
36
36
  "sideEffects": false,
37
37
  "bin": {
38
- "guessit-js": "./bin/cli.mjs"
38
+ "guessit-js": "./bin/cli.mjs",
39
+ "guessit": "./bin/cli.mjs"
39
40
  },
40
41
  "engines": {
41
42
  "node": ">=18"