guessit-js 4.10.0 → 5.0.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.
Files changed (49) hide show
  1. package/README.md +90 -4
  2. package/bin/cli.mjs +33 -10
  3. package/dist/api.d.ts +0 -1
  4. package/dist/config/index.d.ts +0 -1
  5. package/dist/guessit-js.cjs +6 -4
  6. package/dist/guessit-js.cjs.map +1 -1
  7. package/dist/guessit-js.js +8395 -9112
  8. package/dist/guessit-js.js.map +1 -1
  9. package/dist/index.d.ts +2 -0
  10. package/dist/language/python-names.d.ts +2 -0
  11. package/dist/options.d.ts +7 -0
  12. package/dist/output.d.ts +14 -0
  13. package/dist/rules/common/comparators.d.ts +0 -1
  14. package/dist/rules/common/expected.d.ts +0 -1
  15. package/dist/rules/common/pattern.d.ts +0 -1
  16. package/dist/rules/common/validators.d.ts +0 -1
  17. package/dist/rules/index.d.ts +0 -1
  18. package/dist/rules/markers/groups.d.ts +0 -1
  19. package/dist/rules/markers/path.d.ts +0 -1
  20. package/dist/rules/processors.d.ts +0 -1
  21. package/dist/rules/properties/audio_codec.d.ts +0 -1
  22. package/dist/rules/properties/bit_rate.d.ts +0 -1
  23. package/dist/rules/properties/bonus.d.ts +0 -1
  24. package/dist/rules/properties/cd.d.ts +0 -1
  25. package/dist/rules/properties/container.d.ts +0 -1
  26. package/dist/rules/properties/country.d.ts +0 -1
  27. package/dist/rules/properties/crc.d.ts +0 -1
  28. package/dist/rules/properties/date.d.ts +0 -1
  29. package/dist/rules/properties/edition.d.ts +0 -1
  30. package/dist/rules/properties/episode_title.d.ts +0 -1
  31. package/dist/rules/properties/episodes.d.ts +0 -1
  32. package/dist/rules/properties/film.d.ts +0 -1
  33. package/dist/rules/properties/imdb.d.ts +0 -1
  34. package/dist/rules/properties/language.d.ts +0 -1
  35. package/dist/rules/properties/mimetype.d.ts +0 -1
  36. package/dist/rules/properties/other.d.ts +0 -1
  37. package/dist/rules/properties/part.d.ts +0 -1
  38. package/dist/rules/properties/release_group.d.ts +0 -1
  39. package/dist/rules/properties/screen_size.d.ts +0 -1
  40. package/dist/rules/properties/size.d.ts +0 -1
  41. package/dist/rules/properties/source.d.ts +0 -1
  42. package/dist/rules/properties/streaming_service.d.ts +0 -1
  43. package/dist/rules/properties/title.d.ts +0 -1
  44. package/dist/rules/properties/type.d.ts +0 -1
  45. package/dist/rules/properties/video_codec.d.ts +0 -1
  46. package/dist/rules/properties/volume.d.ts +0 -1
  47. package/dist/rules/properties/website.d.ts +0 -1
  48. package/dist/schema.d.ts +4 -1
  49. package/package.json +11 -10
package/dist/index.d.ts CHANGED
@@ -10,6 +10,8 @@
10
10
  export { guessit, guessitMany, properties, configure, reset, defaultApi, GuessItApi, GuessItException } from './api.js';
11
11
  export type { GuessItBatchEntry } from './api.js';
12
12
  export { GUESSIT_SCHEMA } from './schema.js';
13
+ export { toPythonNotation, pythonLanguageName, pythonCountryName, OUTPUT_FORMATS } from './output.js';
14
+ export type { OutputFormat } from './output.js';
13
15
  export type { GuessItResult, GuessitLanguage, PropertySchema } from './schema.js';
14
16
  export { parseOptions, loadConfig, mergeOptions } from './options.js';
15
17
  export type { GuessItOptions, RawOptions } from './options.js';
@@ -0,0 +1,2 @@
1
+ export declare const PYTHON_LANGUAGE_NAMES: Record<string, string>;
2
+ export declare const PYTHON_COUNTRY_NAMES: Record<string, string>;
package/dist/options.d.ts CHANGED
@@ -14,6 +14,13 @@ export interface GuessItOptions {
14
14
  singleValue?: boolean;
15
15
  enforceList?: boolean;
16
16
  outputInputString?: boolean;
17
+ /**
18
+ * Value notation. 'python' (default): Python guessit's JSON notation, language
19
+ * and country names ("French", "UNITED STATES") and "YYYY-MM-DD" dates.
20
+ * 'codes': guessit-js native values, `{ alpha3, country? }` language objects,
21
+ * ISO alpha-2 countries and Date objects.
22
+ */
23
+ output?: 'python' | 'codes';
17
24
  noUserConfig?: boolean;
18
25
  noDefaultConfig?: boolean;
19
26
  advancedConfig?: Record<string, unknown>;
@@ -0,0 +1,14 @@
1
+ export type OutputFormat = 'python' | 'codes';
2
+ /** The output formats `guessit()` accepts as `options.output`. */
3
+ export declare const OUTPUT_FORMATS: readonly OutputFormat[];
4
+ /** Python guessit's name for an ISO 639-3 code ("fra" → "French"); unknown codes pass through. */
5
+ export declare function pythonLanguageName(alpha3: string): string;
6
+ /** Python guessit's name for an ISO 3166 alpha-2 code ("US" → "UNITED STATES"); unknown codes pass through. */
7
+ export declare function pythonCountryName(alpha2: string): string;
8
+ /**
9
+ * Convert a guessit-js result (codes notation) to Python guessit's notation.
10
+ * Returns a new object; the input is not modified.
11
+ */
12
+ export declare function toPythonNotation<T extends Record<string, unknown>>(result: T): T;
13
+ /** Normalise an `output` option value; throws on anything but 'python' / 'codes'. */
14
+ export declare function parseOutputFormat(value: unknown): OutputFormat;
@@ -1,5 +1,4 @@
1
1
  import { Match, _BaseMatches } from 'rebulk-js';
2
-
3
2
  /**
4
3
  * Predicate for marker comparator — excludes private, proper_count, title, extension containers, and Rip other.
5
4
  */
@@ -1,5 +1,4 @@
1
1
  import { Context, MatchOptions } from 'rebulk-js';
2
-
3
2
  /**
4
3
  * Build a functional pattern function that finds expected titles/groups in the string.
5
4
  * Mirrors Python's build_expected_function('expected_title').
@@ -1,5 +1,4 @@
1
1
  import { Context } from 'rebulk-js';
2
-
3
2
  /**
4
3
  * Check if a property is disabled in the current context.
5
4
  * Used by property builders: disabled=lambda context: is_disabled(context, 'video_codec')
@@ -1,5 +1,4 @@
1
1
  import { Match } from 'rebulk-js';
2
-
3
2
  export declare const sepsBefore: (match: Match) => boolean;
4
3
  export declare const sepsAfter: (match: Match) => boolean;
5
4
  export declare const sepsSurround: (match: Match) => boolean;
@@ -1,5 +1,4 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export interface AdvancedConfig {
4
3
  common_words?: string[];
5
4
  groups?: {
@@ -1,5 +1,4 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare class ConfigurationException extends Error {
4
3
  constructor(message: string);
5
4
  }
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function path(config: Record<string, unknown>): Rebulk;
@@ -1,5 +1,4 @@
1
1
  import { Rebulk, Rule, CustomRule, AppendMatch, RemoveMatch, Match, Matches, Context } from 'rebulk-js';
2
-
3
2
  /** Enlarge matches that start/end a group to include bracket characters. */
4
3
  export declare class EnlargeGroupMatches extends CustomRule {
5
4
  static priority: number;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function audioCodec(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function bitRate(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function bonus(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function cd(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function container(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function country(config: Record<string, unknown>, commonWords: Set<string>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function crc(_config: Record<string, unknown>): Rebulk;
@@ -1,5 +1,4 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  /**
4
3
  * Create a rebulk pattern for date detection.
5
4
  */
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function edition(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function episodeTitle(config: Record<string, unknown>): Rebulk;
@@ -1,5 +1,4 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  interface EpisodesConfig {
4
3
  season_max_range: number;
5
4
  episode_max_range: number;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function film(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function imdb(_config: Record<string, unknown>): Rebulk;
@@ -1,5 +1,4 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  interface LanguageConfig {
4
3
  subtitle_affixes: string[];
5
4
  subtitle_prefixes: string[];
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function mimetype(_config: Record<string, unknown>): Rebulk;
@@ -1,5 +1,4 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function other(config: Record<string, unknown>): Rebulk;
4
3
  export declare function completeWords(rebulk: Rebulk, opts: {
5
4
  completeMarkerWords: string[];
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function part(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function releaseGroup(config: Record<string, unknown>): Rebulk;
@@ -1,5 +1,4 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export interface ScreenSizeConfig {
4
3
  frame_rates: string[];
5
4
  interlaced: string[];
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function size(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function source(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function streamingService(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function title(config: Record<string, unknown>): Rebulk;
@@ -1,5 +1,4 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  /**
4
3
  * Create a rebulk pattern for type detection.
5
4
  */
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function videoCodec(config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function volume(_config: Record<string, unknown>): Rebulk;
@@ -1,3 +1,2 @@
1
1
  import { Rebulk } from 'rebulk-js';
2
-
3
2
  export declare function website(config: Record<string, unknown>): Rebulk;
package/dist/schema.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- /** A detected language or country, as guessit renders it. */
1
+ /**
2
+ * A language as returned with `output: 'codes'`. The default output gives the
3
+ * name Python guessit prints instead ("French").
4
+ */
2
5
  export interface GuessitLanguage {
3
6
  name?: string;
4
7
  alpha3?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "guessit-js",
3
- "version": "4.10.0",
3
+ "version": "5.0.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",
@@ -69,15 +69,16 @@
69
69
  },
70
70
  "devDependencies": {
71
71
  "@types/js-yaml": "^4.0.9",
72
- "@types/node": "^20.0.0",
73
- "@vitest/coverage-v8": "^1.0.0",
74
- "binaryen": "^125.0.0",
75
- "js-yaml": "^4.1.0",
72
+ "@types/node": "^22.0.0",
73
+ "@vitest/coverage-v8": "^5.1.1",
74
+ "binaryen": "^132.0.0",
75
+ "esbuild": "^0.28.2",
76
+ "js-yaml": "^5.5.0",
76
77
  "rebulk-js": "^3.5.0",
77
- "tsx": "^4.23.12",
78
- "typescript": "^5.3.0",
79
- "vite": "^5.0.0",
80
- "vite-plugin-dts": "^3.6.0",
81
- "vitest": "^1.0.0"
78
+ "tsx": "^4.23.15",
79
+ "typescript": "^6.0.3",
80
+ "vite": "^8.3.8",
81
+ "vite-plugin-dts": "^5.1.2",
82
+ "vitest": "^5.1.1"
82
83
  }
83
84
  }