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.
@@ -2241,7 +2241,7 @@ const WORD_NUMERALS = {
2241
2241
  "trois": 3,
2242
2242
  "quatre": 4,
2243
2243
  "cinq": 5,
2244
- "six": 6,
2244
+ // 'six' is shared with the English list above (same spelling and value)
2245
2245
  "sept": 7,
2246
2246
  "huit": 8,
2247
2247
  "neuf": 9,
@@ -2306,6 +2306,857 @@ function and_(...validators) {
2306
2306
  function or_(...validators) {
2307
2307
  return (m) => validators.some((v) => v(m));
2308
2308
  }
2309
+ const DIACRITIC_FOLD = {
2310
+ "À": "A",
2311
+ "Á": "A",
2312
+ "Â": "A",
2313
+ "Ã": "A",
2314
+ "Ä": "A",
2315
+ "Å": "A",
2316
+ "Ç": "C",
2317
+ "È": "E",
2318
+ "É": "E",
2319
+ "Ê": "E",
2320
+ "Ë": "E",
2321
+ "Ì": "I",
2322
+ "Í": "I",
2323
+ "Î": "I",
2324
+ "Ï": "I",
2325
+ "Ñ": "N",
2326
+ "Ò": "O",
2327
+ "Ó": "O",
2328
+ "Ô": "O",
2329
+ "Õ": "O",
2330
+ "Ö": "O",
2331
+ "Ù": "U",
2332
+ "Ú": "U",
2333
+ "Û": "U",
2334
+ "Ü": "U",
2335
+ "Ý": "Y",
2336
+ "à": "a",
2337
+ "á": "a",
2338
+ "â": "a",
2339
+ "ã": "a",
2340
+ "ä": "a",
2341
+ "å": "a",
2342
+ "ç": "c",
2343
+ "è": "e",
2344
+ "é": "e",
2345
+ "ê": "e",
2346
+ "ë": "e",
2347
+ "ì": "i",
2348
+ "í": "i",
2349
+ "î": "i",
2350
+ "ï": "i",
2351
+ "ñ": "n",
2352
+ "ò": "o",
2353
+ "ó": "o",
2354
+ "ô": "o",
2355
+ "õ": "o",
2356
+ "ö": "o",
2357
+ "ù": "u",
2358
+ "ú": "u",
2359
+ "û": "u",
2360
+ "ü": "u",
2361
+ "ý": "y",
2362
+ "ÿ": "y",
2363
+ "Ā": "A",
2364
+ "ā": "a",
2365
+ "Ă": "A",
2366
+ "ă": "a",
2367
+ "Ą": "A",
2368
+ "ą": "a",
2369
+ "Ć": "C",
2370
+ "ć": "c",
2371
+ "Ĉ": "C",
2372
+ "ĉ": "c",
2373
+ "Ċ": "C",
2374
+ "ċ": "c",
2375
+ "Č": "C",
2376
+ "č": "c",
2377
+ "Ď": "D",
2378
+ "ď": "d",
2379
+ "Ē": "E",
2380
+ "ē": "e",
2381
+ "Ĕ": "E",
2382
+ "ĕ": "e",
2383
+ "Ė": "E",
2384
+ "ė": "e",
2385
+ "Ę": "E",
2386
+ "ę": "e",
2387
+ "Ě": "E",
2388
+ "ě": "e",
2389
+ "Ĝ": "G",
2390
+ "ĝ": "g",
2391
+ "Ğ": "G",
2392
+ "ğ": "g",
2393
+ "Ġ": "G",
2394
+ "ġ": "g",
2395
+ "Ģ": "G",
2396
+ "ģ": "g",
2397
+ "Ĥ": "H",
2398
+ "ĥ": "h",
2399
+ "Ĩ": "I",
2400
+ "ĩ": "i",
2401
+ "Ī": "I",
2402
+ "ī": "i",
2403
+ "Ĭ": "I",
2404
+ "ĭ": "i",
2405
+ "Į": "I",
2406
+ "į": "i",
2407
+ "İ": "I",
2408
+ "Ĵ": "J",
2409
+ "ĵ": "j",
2410
+ "Ķ": "K",
2411
+ "ķ": "k",
2412
+ "Ĺ": "L",
2413
+ "ĺ": "l",
2414
+ "Ļ": "L",
2415
+ "ļ": "l",
2416
+ "Ľ": "L",
2417
+ "ľ": "l",
2418
+ "Ń": "N",
2419
+ "ń": "n",
2420
+ "Ņ": "N",
2421
+ "ņ": "n",
2422
+ "Ň": "N",
2423
+ "ň": "n",
2424
+ "Ō": "O",
2425
+ "ō": "o",
2426
+ "Ŏ": "O",
2427
+ "ŏ": "o",
2428
+ "Ő": "O",
2429
+ "ő": "o",
2430
+ "Ŕ": "R",
2431
+ "ŕ": "r",
2432
+ "Ŗ": "R",
2433
+ "ŗ": "r",
2434
+ "Ř": "R",
2435
+ "ř": "r",
2436
+ "Ś": "S",
2437
+ "ś": "s",
2438
+ "Ŝ": "S",
2439
+ "ŝ": "s",
2440
+ "Ş": "S",
2441
+ "ş": "s",
2442
+ "Š": "S",
2443
+ "š": "s",
2444
+ "Ţ": "T",
2445
+ "ţ": "t",
2446
+ "Ť": "T",
2447
+ "ť": "t",
2448
+ "Ũ": "U",
2449
+ "ũ": "u",
2450
+ "Ū": "U",
2451
+ "ū": "u",
2452
+ "Ŭ": "U",
2453
+ "ŭ": "u",
2454
+ "Ů": "U",
2455
+ "ů": "u",
2456
+ "Ű": "U",
2457
+ "ű": "u",
2458
+ "Ų": "U",
2459
+ "ų": "u",
2460
+ "Ŵ": "W",
2461
+ "ŵ": "w",
2462
+ "Ŷ": "Y",
2463
+ "ŷ": "y",
2464
+ "Ÿ": "Y",
2465
+ "Ź": "Z",
2466
+ "ź": "z",
2467
+ "Ż": "Z",
2468
+ "ż": "z",
2469
+ "Ž": "Z",
2470
+ "ž": "z",
2471
+ "Ơ": "O",
2472
+ "ơ": "o",
2473
+ "Ư": "U",
2474
+ "ư": "u",
2475
+ "Ǎ": "A",
2476
+ "ǎ": "a",
2477
+ "Ǐ": "I",
2478
+ "ǐ": "i",
2479
+ "Ǒ": "O",
2480
+ "ǒ": "o",
2481
+ "Ǔ": "U",
2482
+ "ǔ": "u",
2483
+ "Ǖ": "U",
2484
+ "ǖ": "u",
2485
+ "Ǘ": "U",
2486
+ "ǘ": "u",
2487
+ "Ǚ": "U",
2488
+ "ǚ": "u",
2489
+ "Ǜ": "U",
2490
+ "ǜ": "u",
2491
+ "Ǟ": "A",
2492
+ "ǟ": "a",
2493
+ "Ǡ": "A",
2494
+ "ǡ": "a",
2495
+ "Ǣ": "Æ",
2496
+ "ǣ": "æ",
2497
+ "Ǧ": "G",
2498
+ "ǧ": "g",
2499
+ "Ǩ": "K",
2500
+ "ǩ": "k",
2501
+ "Ǫ": "O",
2502
+ "ǫ": "o",
2503
+ "Ǭ": "O",
2504
+ "ǭ": "o",
2505
+ "Ǯ": "Ʒ",
2506
+ "ǯ": "ʒ",
2507
+ "ǰ": "j",
2508
+ "Ǵ": "G",
2509
+ "ǵ": "g",
2510
+ "Ǹ": "N",
2511
+ "ǹ": "n",
2512
+ "Ǻ": "A",
2513
+ "ǻ": "a",
2514
+ "Ǽ": "Æ",
2515
+ "ǽ": "æ",
2516
+ "Ǿ": "Ø",
2517
+ "ǿ": "ø",
2518
+ "Ȁ": "A",
2519
+ "ȁ": "a",
2520
+ "Ȃ": "A",
2521
+ "ȃ": "a",
2522
+ "Ȅ": "E",
2523
+ "ȅ": "e",
2524
+ "Ȇ": "E",
2525
+ "ȇ": "e",
2526
+ "Ȉ": "I",
2527
+ "ȉ": "i",
2528
+ "Ȋ": "I",
2529
+ "ȋ": "i",
2530
+ "Ȍ": "O",
2531
+ "ȍ": "o",
2532
+ "Ȏ": "O",
2533
+ "ȏ": "o",
2534
+ "Ȑ": "R",
2535
+ "ȑ": "r",
2536
+ "Ȓ": "R",
2537
+ "ȓ": "r",
2538
+ "Ȕ": "U",
2539
+ "ȕ": "u",
2540
+ "Ȗ": "U",
2541
+ "ȗ": "u",
2542
+ "Ș": "S",
2543
+ "ș": "s",
2544
+ "Ț": "T",
2545
+ "ț": "t",
2546
+ "Ȟ": "H",
2547
+ "ȟ": "h",
2548
+ "Ȧ": "A",
2549
+ "ȧ": "a",
2550
+ "Ȩ": "E",
2551
+ "ȩ": "e",
2552
+ "Ȫ": "O",
2553
+ "ȫ": "o",
2554
+ "Ȭ": "O",
2555
+ "ȭ": "o",
2556
+ "Ȯ": "O",
2557
+ "ȯ": "o",
2558
+ "Ȱ": "O",
2559
+ "ȱ": "o",
2560
+ "Ȳ": "Y",
2561
+ "ȳ": "y",
2562
+ "΅": "¨",
2563
+ "Ά": "Α",
2564
+ "Έ": "Ε",
2565
+ "Ή": "Η",
2566
+ "Ί": "Ι",
2567
+ "Ό": "Ο",
2568
+ "Ύ": "Υ",
2569
+ "Ώ": "Ω",
2570
+ "ΐ": "ι",
2571
+ "Ϊ": "Ι",
2572
+ "Ϋ": "Υ",
2573
+ "ά": "α",
2574
+ "έ": "ε",
2575
+ "ή": "η",
2576
+ "ί": "ι",
2577
+ "ΰ": "υ",
2578
+ "ϊ": "ι",
2579
+ "ϋ": "υ",
2580
+ "ό": "ο",
2581
+ "ύ": "υ",
2582
+ "ώ": "ω",
2583
+ "ϓ": "ϒ",
2584
+ "ϔ": "ϒ",
2585
+ "Ѐ": "Е",
2586
+ "Ё": "Е",
2587
+ "Ѓ": "Г",
2588
+ "Ї": "І",
2589
+ "Ќ": "К",
2590
+ "Ѝ": "И",
2591
+ "Ў": "У",
2592
+ "Й": "И",
2593
+ "й": "и",
2594
+ "ѐ": "е",
2595
+ "ё": "е",
2596
+ "ѓ": "г",
2597
+ "ї": "і",
2598
+ "ќ": "к",
2599
+ "ѝ": "и",
2600
+ "ў": "у",
2601
+ "Ѷ": "Ѵ",
2602
+ "ѷ": "ѵ",
2603
+ "Ӂ": "Ж",
2604
+ "ӂ": "ж",
2605
+ "Ӑ": "А",
2606
+ "ӑ": "а",
2607
+ "Ӓ": "А",
2608
+ "ӓ": "а",
2609
+ "Ӗ": "Е",
2610
+ "ӗ": "е",
2611
+ "Ӛ": "Ә",
2612
+ "ӛ": "ә",
2613
+ "Ӝ": "Ж",
2614
+ "ӝ": "ж",
2615
+ "Ӟ": "З",
2616
+ "ӟ": "з",
2617
+ "Ӣ": "И",
2618
+ "ӣ": "и",
2619
+ "Ӥ": "И",
2620
+ "ӥ": "и",
2621
+ "Ӧ": "О",
2622
+ "ӧ": "о",
2623
+ "Ӫ": "Ө",
2624
+ "ӫ": "ө",
2625
+ "Ӭ": "Э",
2626
+ "ӭ": "э",
2627
+ "Ӯ": "У",
2628
+ "ӯ": "у",
2629
+ "Ӱ": "У",
2630
+ "ӱ": "у",
2631
+ "Ӳ": "У",
2632
+ "ӳ": "у",
2633
+ "Ӵ": "Ч",
2634
+ "ӵ": "ч",
2635
+ "Ӹ": "Ы",
2636
+ "ӹ": "ы",
2637
+ "Ḁ": "A",
2638
+ "ḁ": "a",
2639
+ "Ḃ": "B",
2640
+ "ḃ": "b",
2641
+ "Ḅ": "B",
2642
+ "ḅ": "b",
2643
+ "Ḇ": "B",
2644
+ "ḇ": "b",
2645
+ "Ḉ": "C",
2646
+ "ḉ": "c",
2647
+ "Ḋ": "D",
2648
+ "ḋ": "d",
2649
+ "Ḍ": "D",
2650
+ "ḍ": "d",
2651
+ "Ḏ": "D",
2652
+ "ḏ": "d",
2653
+ "Ḑ": "D",
2654
+ "ḑ": "d",
2655
+ "Ḓ": "D",
2656
+ "ḓ": "d",
2657
+ "Ḕ": "E",
2658
+ "ḕ": "e",
2659
+ "Ḗ": "E",
2660
+ "ḗ": "e",
2661
+ "Ḙ": "E",
2662
+ "ḙ": "e",
2663
+ "Ḛ": "E",
2664
+ "ḛ": "e",
2665
+ "Ḝ": "E",
2666
+ "ḝ": "e",
2667
+ "Ḟ": "F",
2668
+ "ḟ": "f",
2669
+ "Ḡ": "G",
2670
+ "ḡ": "g",
2671
+ "Ḣ": "H",
2672
+ "ḣ": "h",
2673
+ "Ḥ": "H",
2674
+ "ḥ": "h",
2675
+ "Ḧ": "H",
2676
+ "ḧ": "h",
2677
+ "Ḩ": "H",
2678
+ "ḩ": "h",
2679
+ "Ḫ": "H",
2680
+ "ḫ": "h",
2681
+ "Ḭ": "I",
2682
+ "ḭ": "i",
2683
+ "Ḯ": "I",
2684
+ "ḯ": "i",
2685
+ "Ḱ": "K",
2686
+ "ḱ": "k",
2687
+ "Ḳ": "K",
2688
+ "ḳ": "k",
2689
+ "Ḵ": "K",
2690
+ "ḵ": "k",
2691
+ "Ḷ": "L",
2692
+ "ḷ": "l",
2693
+ "Ḹ": "L",
2694
+ "ḹ": "l",
2695
+ "Ḻ": "L",
2696
+ "ḻ": "l",
2697
+ "Ḽ": "L",
2698
+ "ḽ": "l",
2699
+ "Ḿ": "M",
2700
+ "ḿ": "m",
2701
+ "Ṁ": "M",
2702
+ "ṁ": "m",
2703
+ "Ṃ": "M",
2704
+ "ṃ": "m",
2705
+ "Ṅ": "N",
2706
+ "ṅ": "n",
2707
+ "Ṇ": "N",
2708
+ "ṇ": "n",
2709
+ "Ṉ": "N",
2710
+ "ṉ": "n",
2711
+ "Ṋ": "N",
2712
+ "ṋ": "n",
2713
+ "Ṍ": "O",
2714
+ "ṍ": "o",
2715
+ "Ṏ": "O",
2716
+ "ṏ": "o",
2717
+ "Ṑ": "O",
2718
+ "ṑ": "o",
2719
+ "Ṓ": "O",
2720
+ "ṓ": "o",
2721
+ "Ṕ": "P",
2722
+ "ṕ": "p",
2723
+ "Ṗ": "P",
2724
+ "ṗ": "p",
2725
+ "Ṙ": "R",
2726
+ "ṙ": "r",
2727
+ "Ṛ": "R",
2728
+ "ṛ": "r",
2729
+ "Ṝ": "R",
2730
+ "ṝ": "r",
2731
+ "Ṟ": "R",
2732
+ "ṟ": "r",
2733
+ "Ṡ": "S",
2734
+ "ṡ": "s",
2735
+ "Ṣ": "S",
2736
+ "ṣ": "s",
2737
+ "Ṥ": "S",
2738
+ "ṥ": "s",
2739
+ "Ṧ": "S",
2740
+ "ṧ": "s",
2741
+ "Ṩ": "S",
2742
+ "ṩ": "s",
2743
+ "Ṫ": "T",
2744
+ "ṫ": "t",
2745
+ "Ṭ": "T",
2746
+ "ṭ": "t",
2747
+ "Ṯ": "T",
2748
+ "ṯ": "t",
2749
+ "Ṱ": "T",
2750
+ "ṱ": "t",
2751
+ "Ṳ": "U",
2752
+ "ṳ": "u",
2753
+ "Ṵ": "U",
2754
+ "ṵ": "u",
2755
+ "Ṷ": "U",
2756
+ "ṷ": "u",
2757
+ "Ṹ": "U",
2758
+ "ṹ": "u",
2759
+ "Ṻ": "U",
2760
+ "ṻ": "u",
2761
+ "Ṽ": "V",
2762
+ "ṽ": "v",
2763
+ "Ṿ": "V",
2764
+ "ṿ": "v",
2765
+ "Ẁ": "W",
2766
+ "ẁ": "w",
2767
+ "Ẃ": "W",
2768
+ "ẃ": "w",
2769
+ "Ẅ": "W",
2770
+ "ẅ": "w",
2771
+ "Ẇ": "W",
2772
+ "ẇ": "w",
2773
+ "Ẉ": "W",
2774
+ "ẉ": "w",
2775
+ "Ẋ": "X",
2776
+ "ẋ": "x",
2777
+ "Ẍ": "X",
2778
+ "ẍ": "x",
2779
+ "Ẏ": "Y",
2780
+ "ẏ": "y",
2781
+ "Ẑ": "Z",
2782
+ "ẑ": "z",
2783
+ "Ẓ": "Z",
2784
+ "ẓ": "z",
2785
+ "Ẕ": "Z",
2786
+ "ẕ": "z",
2787
+ "ẖ": "h",
2788
+ "ẗ": "t",
2789
+ "ẘ": "w",
2790
+ "ẙ": "y",
2791
+ "ẛ": "ſ",
2792
+ "Ạ": "A",
2793
+ "ạ": "a",
2794
+ "Ả": "A",
2795
+ "ả": "a",
2796
+ "Ấ": "A",
2797
+ "ấ": "a",
2798
+ "Ầ": "A",
2799
+ "ầ": "a",
2800
+ "Ẩ": "A",
2801
+ "ẩ": "a",
2802
+ "Ẫ": "A",
2803
+ "ẫ": "a",
2804
+ "Ậ": "A",
2805
+ "ậ": "a",
2806
+ "Ắ": "A",
2807
+ "ắ": "a",
2808
+ "Ằ": "A",
2809
+ "ằ": "a",
2810
+ "Ẳ": "A",
2811
+ "ẳ": "a",
2812
+ "Ẵ": "A",
2813
+ "ẵ": "a",
2814
+ "Ặ": "A",
2815
+ "ặ": "a",
2816
+ "Ẹ": "E",
2817
+ "ẹ": "e",
2818
+ "Ẻ": "E",
2819
+ "ẻ": "e",
2820
+ "Ẽ": "E",
2821
+ "ẽ": "e",
2822
+ "Ế": "E",
2823
+ "ế": "e",
2824
+ "Ề": "E",
2825
+ "ề": "e",
2826
+ "Ể": "E",
2827
+ "ể": "e",
2828
+ "Ễ": "E",
2829
+ "ễ": "e",
2830
+ "Ệ": "E",
2831
+ "ệ": "e",
2832
+ "Ỉ": "I",
2833
+ "ỉ": "i",
2834
+ "Ị": "I",
2835
+ "ị": "i",
2836
+ "Ọ": "O",
2837
+ "ọ": "o",
2838
+ "Ỏ": "O",
2839
+ "ỏ": "o",
2840
+ "Ố": "O",
2841
+ "ố": "o",
2842
+ "Ồ": "O",
2843
+ "ồ": "o",
2844
+ "Ổ": "O",
2845
+ "ổ": "o",
2846
+ "Ỗ": "O",
2847
+ "ỗ": "o",
2848
+ "Ộ": "O",
2849
+ "ộ": "o",
2850
+ "Ớ": "O",
2851
+ "ớ": "o",
2852
+ "Ờ": "O",
2853
+ "ờ": "o",
2854
+ "Ở": "O",
2855
+ "ở": "o",
2856
+ "Ỡ": "O",
2857
+ "ỡ": "o",
2858
+ "Ợ": "O",
2859
+ "ợ": "o",
2860
+ "Ụ": "U",
2861
+ "ụ": "u",
2862
+ "Ủ": "U",
2863
+ "ủ": "u",
2864
+ "Ứ": "U",
2865
+ "ứ": "u",
2866
+ "Ừ": "U",
2867
+ "ừ": "u",
2868
+ "Ử": "U",
2869
+ "ử": "u",
2870
+ "Ữ": "U",
2871
+ "ữ": "u",
2872
+ "Ự": "U",
2873
+ "ự": "u",
2874
+ "Ỳ": "Y",
2875
+ "ỳ": "y",
2876
+ "Ỵ": "Y",
2877
+ "ỵ": "y",
2878
+ "Ỷ": "Y",
2879
+ "ỷ": "y",
2880
+ "Ỹ": "Y",
2881
+ "ỹ": "y",
2882
+ "ἀ": "α",
2883
+ "ἁ": "α",
2884
+ "ἂ": "α",
2885
+ "ἃ": "α",
2886
+ "ἄ": "α",
2887
+ "ἅ": "α",
2888
+ "ἆ": "α",
2889
+ "ἇ": "α",
2890
+ "Ἀ": "Α",
2891
+ "Ἁ": "Α",
2892
+ "Ἂ": "Α",
2893
+ "Ἃ": "Α",
2894
+ "Ἄ": "Α",
2895
+ "Ἅ": "Α",
2896
+ "Ἆ": "Α",
2897
+ "Ἇ": "Α",
2898
+ "ἐ": "ε",
2899
+ "ἑ": "ε",
2900
+ "ἒ": "ε",
2901
+ "ἓ": "ε",
2902
+ "ἔ": "ε",
2903
+ "ἕ": "ε",
2904
+ "Ἐ": "Ε",
2905
+ "Ἑ": "Ε",
2906
+ "Ἒ": "Ε",
2907
+ "Ἓ": "Ε",
2908
+ "Ἔ": "Ε",
2909
+ "Ἕ": "Ε",
2910
+ "ἠ": "η",
2911
+ "ἡ": "η",
2912
+ "ἢ": "η",
2913
+ "ἣ": "η",
2914
+ "ἤ": "η",
2915
+ "ἥ": "η",
2916
+ "ἦ": "η",
2917
+ "ἧ": "η",
2918
+ "Ἠ": "Η",
2919
+ "Ἡ": "Η",
2920
+ "Ἢ": "Η",
2921
+ "Ἣ": "Η",
2922
+ "Ἤ": "Η",
2923
+ "Ἥ": "Η",
2924
+ "Ἦ": "Η",
2925
+ "Ἧ": "Η",
2926
+ "ἰ": "ι",
2927
+ "ἱ": "ι",
2928
+ "ἲ": "ι",
2929
+ "ἳ": "ι",
2930
+ "ἴ": "ι",
2931
+ "ἵ": "ι",
2932
+ "ἶ": "ι",
2933
+ "ἷ": "ι",
2934
+ "Ἰ": "Ι",
2935
+ "Ἱ": "Ι",
2936
+ "Ἲ": "Ι",
2937
+ "Ἳ": "Ι",
2938
+ "Ἴ": "Ι",
2939
+ "Ἵ": "Ι",
2940
+ "Ἶ": "Ι",
2941
+ "Ἷ": "Ι",
2942
+ "ὀ": "ο",
2943
+ "ὁ": "ο",
2944
+ "ὂ": "ο",
2945
+ "ὃ": "ο",
2946
+ "ὄ": "ο",
2947
+ "ὅ": "ο",
2948
+ "Ὀ": "Ο",
2949
+ "Ὁ": "Ο",
2950
+ "Ὂ": "Ο",
2951
+ "Ὃ": "Ο",
2952
+ "Ὄ": "Ο",
2953
+ "Ὅ": "Ο",
2954
+ "ὐ": "υ",
2955
+ "ὑ": "υ",
2956
+ "ὒ": "υ",
2957
+ "ὓ": "υ",
2958
+ "ὔ": "υ",
2959
+ "ὕ": "υ",
2960
+ "ὖ": "υ",
2961
+ "ὗ": "υ",
2962
+ "Ὑ": "Υ",
2963
+ "Ὓ": "Υ",
2964
+ "Ὕ": "Υ",
2965
+ "Ὗ": "Υ",
2966
+ "ὠ": "ω",
2967
+ "ὡ": "ω",
2968
+ "ὢ": "ω",
2969
+ "ὣ": "ω",
2970
+ "ὤ": "ω",
2971
+ "ὥ": "ω",
2972
+ "ὦ": "ω",
2973
+ "ὧ": "ω",
2974
+ "Ὠ": "Ω",
2975
+ "Ὡ": "Ω",
2976
+ "Ὢ": "Ω",
2977
+ "Ὣ": "Ω",
2978
+ "Ὤ": "Ω",
2979
+ "Ὥ": "Ω",
2980
+ "Ὦ": "Ω",
2981
+ "Ὧ": "Ω",
2982
+ "ὰ": "α",
2983
+ "ά": "α",
2984
+ "ὲ": "ε",
2985
+ "έ": "ε",
2986
+ "ὴ": "η",
2987
+ "ή": "η",
2988
+ "ὶ": "ι",
2989
+ "ί": "ι",
2990
+ "ὸ": "ο",
2991
+ "ό": "ο",
2992
+ "ὺ": "υ",
2993
+ "ύ": "υ",
2994
+ "ὼ": "ω",
2995
+ "ώ": "ω",
2996
+ "ᾀ": "α",
2997
+ "ᾁ": "α",
2998
+ "ᾂ": "α",
2999
+ "ᾃ": "α",
3000
+ "ᾄ": "α",
3001
+ "ᾅ": "α",
3002
+ "ᾆ": "α",
3003
+ "ᾇ": "α",
3004
+ "ᾈ": "Α",
3005
+ "ᾉ": "Α",
3006
+ "ᾊ": "Α",
3007
+ "ᾋ": "Α",
3008
+ "ᾌ": "Α",
3009
+ "ᾍ": "Α",
3010
+ "ᾎ": "Α",
3011
+ "ᾏ": "Α",
3012
+ "ᾐ": "η",
3013
+ "ᾑ": "η",
3014
+ "ᾒ": "η",
3015
+ "ᾓ": "η",
3016
+ "ᾔ": "η",
3017
+ "ᾕ": "η",
3018
+ "ᾖ": "η",
3019
+ "ᾗ": "η",
3020
+ "ᾘ": "Η",
3021
+ "ᾙ": "Η",
3022
+ "ᾚ": "Η",
3023
+ "ᾛ": "Η",
3024
+ "ᾜ": "Η",
3025
+ "ᾝ": "Η",
3026
+ "ᾞ": "Η",
3027
+ "ᾟ": "Η",
3028
+ "ᾠ": "ω",
3029
+ "ᾡ": "ω",
3030
+ "ᾢ": "ω",
3031
+ "ᾣ": "ω",
3032
+ "ᾤ": "ω",
3033
+ "ᾥ": "ω",
3034
+ "ᾦ": "ω",
3035
+ "ᾧ": "ω",
3036
+ "ᾨ": "Ω",
3037
+ "ᾩ": "Ω",
3038
+ "ᾪ": "Ω",
3039
+ "ᾫ": "Ω",
3040
+ "ᾬ": "Ω",
3041
+ "ᾭ": "Ω",
3042
+ "ᾮ": "Ω",
3043
+ "ᾯ": "Ω",
3044
+ "ᾰ": "α",
3045
+ "ᾱ": "α",
3046
+ "ᾲ": "α",
3047
+ "ᾳ": "α",
3048
+ "ᾴ": "α",
3049
+ "ᾶ": "α",
3050
+ "ᾷ": "α",
3051
+ "Ᾰ": "Α",
3052
+ "Ᾱ": "Α",
3053
+ "Ὰ": "Α",
3054
+ "Ά": "Α",
3055
+ "ᾼ": "Α",
3056
+ "῁": "¨",
3057
+ "ῂ": "η",
3058
+ "ῃ": "η",
3059
+ "ῄ": "η",
3060
+ "ῆ": "η",
3061
+ "ῇ": "η",
3062
+ "Ὲ": "Ε",
3063
+ "Έ": "Ε",
3064
+ "Ὴ": "Η",
3065
+ "Ή": "Η",
3066
+ "ῌ": "Η",
3067
+ "῍": "᾿",
3068
+ "῎": "᾿",
3069
+ "῏": "᾿",
3070
+ "ῐ": "ι",
3071
+ "ῑ": "ι",
3072
+ "ῒ": "ι",
3073
+ "ΐ": "ι",
3074
+ "ῖ": "ι",
3075
+ "ῗ": "ι",
3076
+ "Ῐ": "Ι",
3077
+ "Ῑ": "Ι",
3078
+ "Ὶ": "Ι",
3079
+ "Ί": "Ι",
3080
+ "῝": "῾",
3081
+ "῞": "῾",
3082
+ "῟": "῾",
3083
+ "ῠ": "υ",
3084
+ "ῡ": "υ",
3085
+ "ῢ": "υ",
3086
+ "ΰ": "υ",
3087
+ "ῤ": "ρ",
3088
+ "ῥ": "ρ",
3089
+ "ῦ": "υ",
3090
+ "ῧ": "υ",
3091
+ "Ῠ": "Υ",
3092
+ "Ῡ": "Υ",
3093
+ "Ὺ": "Υ",
3094
+ "Ύ": "Υ",
3095
+ "Ῥ": "Ρ",
3096
+ "῭": "¨",
3097
+ "΅": "¨",
3098
+ "ῲ": "ω",
3099
+ "ῳ": "ω",
3100
+ "ῴ": "ω",
3101
+ "ῶ": "ω",
3102
+ "ῷ": "ω",
3103
+ "Ὸ": "Ο",
3104
+ "Ό": "Ο",
3105
+ "Ὼ": "Ω",
3106
+ "Ώ": "Ω",
3107
+ "ῼ": "Ω",
3108
+ "Å": "A",
3109
+ "↚": "←",
3110
+ "↛": "→",
3111
+ "↮": "↔",
3112
+ "⇍": "⇐",
3113
+ "⇎": "⇔",
3114
+ "⇏": "⇒",
3115
+ "∄": "∃",
3116
+ "∉": "∈",
3117
+ "∌": "∋",
3118
+ "∤": "∣",
3119
+ "∦": "∥",
3120
+ "≁": "∼",
3121
+ "≄": "≃",
3122
+ "≇": "≅",
3123
+ "≉": "≈",
3124
+ "≠": "=",
3125
+ "≢": "≡",
3126
+ "≭": "≍",
3127
+ "≮": "<",
3128
+ "≯": ">",
3129
+ "≰": "≤",
3130
+ "≱": "≥",
3131
+ "≴": "≲",
3132
+ "≵": "≳",
3133
+ "≸": "≶",
3134
+ "≹": "≷",
3135
+ "⊀": "≺",
3136
+ "⊁": "≻",
3137
+ "⊄": "⊂",
3138
+ "⊅": "⊃",
3139
+ "⊈": "⊆",
3140
+ "⊉": "⊇",
3141
+ "⊬": "⊢",
3142
+ "⊭": "⊨",
3143
+ "⊮": "⊩",
3144
+ "⊯": "⊫",
3145
+ "⋠": "≼",
3146
+ "⋡": "≽",
3147
+ "⋢": "⊑",
3148
+ "⋣": "⊒",
3149
+ "⋪": "⊲",
3150
+ "⋫": "⊳",
3151
+ "⋬": "⊴",
3152
+ "⋭": "⊵",
3153
+ "⫝̸": "⫝"
3154
+ };
3155
+ function foldDiacritics(input) {
3156
+ let out = "";
3157
+ for (const ch of input) out += DIACRITIC_FOLD[ch] ?? ch;
3158
+ return out.replace(/[̀-ͯ]/g, "");
3159
+ }
2309
3160
  const EXCLUDED_CLEAN_CHARS = /* @__PURE__ */ new Set([",", ":", ";", "-", "/", "\\"]);
2310
3161
  const cleanChars = seps.split("").filter((c) => !EXCLUDED_CLEAN_CHARS.has(c)).join("");
2311
3162
  function potentialBefore(i, inputString) {
@@ -2460,6 +3311,14 @@ function validateRoman(match) {
2460
3311
  }
2461
3312
  return sepsSurround(match);
2462
3313
  }
3314
+ function seasonWordNotYear(match) {
3315
+ const raw = String(match.raw ?? "");
3316
+ if (/^\d{4}$/.test(raw)) {
3317
+ const n = parseInt(raw, 10);
3318
+ if (n >= 1900 && n <= 2100) return false;
3319
+ }
3320
+ return validateRoman(match);
3321
+ }
2463
3322
  function episodes(config) {
2464
3323
  config.range_separators;
2465
3324
  const discreteSeparators = config.discrete_separators;
@@ -2521,6 +3380,9 @@ function episodes(config) {
2521
3380
  conflictSolver: seasonEpisodeConflictSolver,
2522
3381
  abbreviations: [altDash]
2523
3382
  });
3383
+ rebulk.regex("第(?<episode>\\d{1,4})話", { tags: ["SxxExx"] });
3384
+ rebulk.regex("(?:シーズン|シリーズ)(?<season>\\d{1,2})", { tags: ["SxxExx"] });
3385
+ rebulk.regex("(?<season>\\d{1,2})期", {});
2524
3386
  const seasonMarkerPattern = buildOrPattern(config.season_markers, "seasonMarker");
2525
3387
  const episodeMarkerPattern = buildOrPattern(
2526
3388
  [...config.episode_markers, ...config.disc_markers],
@@ -2599,14 +3461,14 @@ function episodes(config) {
2599
3461
  formatter: { season: parseNumber, season_count: parseNumber },
2600
3462
  validator: {
2601
3463
  __parent__: and_(sepsSurround, orderingValidator),
2602
- season: validateRoman,
3464
+ season: seasonWordNotYear,
2603
3465
  season_count: validateRoman
2604
3466
  },
2605
3467
  chainBreaker: (matches) => episodesSeasonChainBreaker(matches, config),
2606
3468
  disabled: (context) => context?.type === "movie" || isDisabled(context, "season")
2607
3469
  }).defaults({
2608
3470
  formatter: { season: parseNumber, season_count: parseNumber },
2609
- validator: { season: validateRoman, season_count: validateRoman },
3471
+ validator: { season: seasonWordNotYear, season_count: validateRoman },
2610
3472
  conflictSolver: seasonEpisodeConflictSolver
2611
3473
  }).regex(seasonWordPattern + `@?(?P<season>${numeralWithWords})`).regex(ofWordPattern + `@?(?P<season_count>${numeral})`).repeater("?").regex(
2612
3474
  `@?` + buildOrPattern(
@@ -2852,13 +3714,11 @@ class RangeExpansionRule extends Rule {
2852
3714
  const gap = nextVal - curVal;
2853
3715
  if (gap <= 1 || gap > maxRange) continue;
2854
3716
  const between = matches.inputString?.slice(current.end, next.start) || "";
2855
- const betweenClean = between.replace(/[\s._]/g, "").toLowerCase();
2856
- const betweenStripMarkers = betweenClean.replace(/[sex]/gi, "");
2857
- const isRange = rangeSeps.has(betweenClean) || rangeSeps.has(betweenStripMarkers);
2858
- const sameChain = current.initiator && current.initiator === next.initiator;
2859
- const discreteSeps = new Set((this.config.discrete_separators || ["+", "&", "and", "et"]).map((s) => s.toLowerCase()));
2860
- const isDiscrete = discreteSeps.has(betweenClean);
2861
- if (isRange || sameChain && !isDiscrete) {
3717
+ const betweenClean = between.replace(/[\s.]/g, "").toLowerCase();
3718
+ const betweenStripMarkers = betweenClean.replace(/[sexp]/gi, "");
3719
+ const hasRangeChar = /[-~_]/.test(between);
3720
+ const isRange = hasRangeChar || rangeSeps.has(betweenClean) || rangeSeps.has(betweenStripMarkers);
3721
+ if (isRange) {
2862
3722
  for (let v = curVal + 1; v < nextVal; v++) {
2863
3723
  const m = new Match(current.start, next.end, {
2864
3724
  name,
@@ -3212,6 +4072,17 @@ function container(config) {
3212
4072
  const videos = config["videos"] || [];
3213
4073
  const torrent = config["torrent"] || [];
3214
4074
  const nzb = config["nzb"] || [];
4075
+ const archives = config["archives"] || [];
4076
+ const images = config["images"] || [];
4077
+ if (archives.length) rebulk.regex("\\." + buildOrPattern(archives, void 0, true) + "$", {
4078
+ exts: archives,
4079
+ tags: ["extension", "archive"]
4080
+ });
4081
+ rebulk.regex("\\.r\\d{2}$", { tags: ["extension", "archive"] });
4082
+ if (images.length) rebulk.regex("\\." + buildOrPattern(images, void 0, true) + "$", {
4083
+ exts: images,
4084
+ tags: ["extension", "image"]
4085
+ });
3215
4086
  if (subtitles.length) rebulk.regex("\\." + buildOrPattern(subtitles, void 0, true) + "$", {
3216
4087
  exts: subtitles,
3217
4088
  tags: ["extension", "subtitle"]
@@ -4415,10 +5286,38 @@ const DATE_REGEXPS = [
4415
5286
  new RegExp(`(?:^|[^\\d])((\\d{1,2})${DSEP}(\\d{1,2})${DSEP}(\\d{2}))(?:$|[^\\d])`, "i"),
4416
5287
  new RegExp(`(?:^|[^\\d])((\\d{4})${DSEP_BIS}(\\d{1,2})${DSEP}(\\d{1,2}))(?:$|[^\\d])`, "i"),
4417
5288
  new RegExp(`(?:^|[^\\d])((\\d{1,2})${DSEP}(\\d{1,2})${DSEP_BIS}(\\d{4}))(?:$|[^\\d])`, "i"),
4418
- new RegExp(`(?:^|[^\\d])((\\d{1,2}(?:st|nd|rd|th)?${DSEP}(?:[a-z]{3,10})${DSEP}\\d{4}))(?:$|[^\\d])`, "i")
5289
+ new RegExp(`(?:^|[^\\d])((\\d{1,2}(?:st|nd|rd|th)?${DSEP}(?:[a-z]{3,10})${DSEP}\\d{4}))(?:$|[^\\d])`, "i"),
5290
+ // Month-name first: "July 30 2021", "Jul.30.2021"
5291
+ new RegExp(`(?:^|[^a-z\\d])(([a-z]{3,10})${DSEP}\\d{1,2}(?:st|nd|rd|th)?${DSEP}\\d{4})(?:$|[^\\d])`, "i")
4419
5292
  ];
5293
+ const MONTHS = {
5294
+ jan: 1,
5295
+ january: 1,
5296
+ feb: 2,
5297
+ february: 2,
5298
+ mar: 3,
5299
+ march: 3,
5300
+ apr: 4,
5301
+ april: 4,
5302
+ may: 5,
5303
+ jun: 6,
5304
+ june: 6,
5305
+ jul: 7,
5306
+ july: 7,
5307
+ aug: 8,
5308
+ august: 8,
5309
+ sep: 9,
5310
+ sept: 9,
5311
+ september: 9,
5312
+ oct: 10,
5313
+ october: 10,
5314
+ nov: 11,
5315
+ november: 11,
5316
+ dec: 12,
5317
+ december: 12
5318
+ };
4420
5319
  function validYear(year) {
4421
- return year >= 1920 && year < 2035;
5320
+ return year >= 1900 && year < 2035;
4422
5321
  }
4423
5322
  function validWeek(week) {
4424
5323
  return week >= 1 && week < 53;
@@ -4443,6 +5342,27 @@ function tryParseDate(match, groups2, yearFirst, dayFirst) {
4443
5342
  for (const yf of yearFirstOpts) {
4444
5343
  for (const df of dayFirstOpts) {
4445
5344
  let year, month, day;
5345
+ const monthNameIdx = parts.findIndex((x) => MONTHS[x.toLowerCase()] !== void 0);
5346
+ if (parts.length === 3 && monthNameIdx >= 0) {
5347
+ month = MONTHS[parts[monthNameIdx].toLowerCase()];
5348
+ const rest = parts.filter((_, i) => i !== monthNameIdx).map((x) => parseInt(x.replace(/(st|nd|rd|th)$/i, ""), 10));
5349
+ const yearPos = rest.findIndex((n) => n >= 1e3);
5350
+ if (yearPos >= 0) {
5351
+ year = rest[yearPos];
5352
+ day = rest[1 - yearPos];
5353
+ } else {
5354
+ year = rest[1];
5355
+ day = rest[0];
5356
+ }
5357
+ if (month >= 1 && month <= 12 && day >= 1 && day <= 31 && validYear(year)) {
5358
+ const ts = Date.UTC(year, month - 1, day);
5359
+ const d = new Date(ts);
5360
+ if (d.getUTCFullYear() === year && d.getUTCMonth() === month - 1 && d.getUTCDate() === day) {
5361
+ return d;
5362
+ }
5363
+ }
5364
+ continue;
5365
+ }
4446
5366
  if (parts.length === 1) {
4447
5367
  const s = parts[0];
4448
5368
  if (s.length === 8) {
@@ -4701,6 +5621,32 @@ function buildExpectedFunction(optionName) {
4701
5621
  return results;
4702
5622
  };
4703
5623
  }
5624
+ const TITLE_STOP_WORDS = /* @__PURE__ */ new Set([
5625
+ "the",
5626
+ "a",
5627
+ "an",
5628
+ "and",
5629
+ "or",
5630
+ "of",
5631
+ "to",
5632
+ "in",
5633
+ "on",
5634
+ "at",
5635
+ "for",
5636
+ "from",
5637
+ "by",
5638
+ "with",
5639
+ "into",
5640
+ "onto",
5641
+ "no",
5642
+ "le",
5643
+ "la",
5644
+ "les",
5645
+ "de",
5646
+ "du",
5647
+ "des",
5648
+ "el"
5649
+ ]);
4704
5650
  function hasmatch$1(result) {
4705
5651
  if (result === null || result === void 0) return false;
4706
5652
  if (Array.isArray(result)) return result.length > 0;
@@ -4748,9 +5694,21 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
4748
5694
  }
4749
5695
  /**
4750
5696
  * Determine if a match should be ignored (e.g., language, country).
5697
+ *
5698
+ * Python parity: a full-word (len > 3) UPPERCASE language/country is a real
5699
+ * token, not title filler, so it is NOT ignored — e.g. the trailing "FRENCH"
5700
+ * in "...XViD-NTK.FRENCH..." must not be pulled into an alternative_title.
5701
+ * Lowercase or short (<= 3 char) language/country codes remain ignored.
4751
5702
  */
4752
5703
  isIgnored(match) {
4753
- return match.name === "language" || match.name === "country" || match.name === "episode_details";
5704
+ if (!(match.name === "language" || match.name === "country" || match.name === "episode_details")) {
5705
+ return false;
5706
+ }
5707
+ const raw = match.raw ?? "";
5708
+ if (match.end - match.start > 3 && raw !== "" && raw === raw.toUpperCase() && raw !== raw.toLowerCase()) {
5709
+ return false;
5710
+ }
5711
+ return true;
4754
5712
  }
4755
5713
  /**
4756
5714
  * Determine if we should keep a hole boundary (don't trim this side).
@@ -4954,6 +5912,15 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
4954
5912
  while (ignoredArray.length > 0) {
4955
5913
  const lastIgnored = ignoredArray[ignoredArray.length - 1];
4956
5914
  if (lastIgnored.end === trimmedHole.end) {
5915
+ if (lastIgnored.name === "language" || lastIgnored.name === "country") {
5916
+ const beforeWords = inp.slice(trimmedHole.start, lastIgnored.start).toLowerCase().split(/[^a-z0-9]+/i).filter(Boolean);
5917
+ const lastWord = beforeWords[beforeWords.length - 1];
5918
+ if (lastWord && TITLE_STOP_WORDS.has(lastWord)) {
5919
+ toRemove.push(lastIgnored);
5920
+ ignoredArray.pop();
5921
+ break;
5922
+ }
5923
+ }
4957
5924
  if (lastIgnored.name === "episode_details" && lastIgnored.value === "Special") {
4958
5925
  const nextMatch = matches.range(
4959
5926
  lastIgnored.end,
@@ -5014,6 +5981,16 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
5014
5981
  }
5015
5982
  }
5016
5983
  }
5984
+ const mainTitle = toAppend.find((t) => t.name === this.matchName);
5985
+ if (mainTitle) {
5986
+ const absorbedRaw = matches.range(
5987
+ mainTitle.start,
5988
+ mainTitle.end,
5989
+ (m) => m.name === "episode_details" || m.name === "country" || m.name === "language"
5990
+ );
5991
+ const absorbed = Array.isArray(absorbedRaw) ? absorbedRaw : absorbedRaw ? [absorbedRaw] : [];
5992
+ for (const m of absorbed) if (!toRemove.includes(m)) toRemove.push(m);
5993
+ }
5017
5994
  return { toAppend, toRemove };
5018
5995
  }
5019
5996
  /**
@@ -5119,13 +6096,7 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
5119
6096
  const result = this.checkTitlesInFilepart(filepart, matches);
5120
6097
  if (result.toAppend.length > 0 || result.toRemove.length > 0) {
5121
6098
  if (serieNameMatch) {
5122
- const normTitle = (s) => {
5123
- try {
5124
- s = s.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
5125
- } catch {
5126
- }
5127
- return s.replace(/[''`]/g, "").replace(/\.+$/, "").toLowerCase().trim();
5128
- };
6099
+ const normTitle = (s) => foldDiacritics(s).replace(/[''`]/g, "").replace(/\.+$/, "").toLowerCase().trim();
5129
6100
  for (const titleMatch of result.toAppend) {
5130
6101
  if (normTitle(String(titleMatch.value)) !== normTitle(String(serieNameMatch.value))) {
5131
6102
  titleMatch.name = "episode_title";
@@ -5147,13 +6118,7 @@ const _TitleBaseRule = class _TitleBaseRule extends Rule {
5147
6118
  continue;
5148
6119
  }
5149
6120
  const newVal = String(newTitle.value ?? "");
5150
- const norm = (s) => {
5151
- try {
5152
- s = s.normalize("NFD").replace(/[\u0300-\u036f]/g, "");
5153
- } catch {
5154
- }
5155
- return s.replace(/[''`]/g, "").toLowerCase();
5156
- };
6121
+ const norm = (s) => foldDiacritics(s).replace(/[''`]/g, "").toLowerCase();
5157
6122
  const existingIdx = toAppend.findIndex((m) => {
5158
6123
  const existingVal = String(m.value ?? "");
5159
6124
  return norm(existingVal) === norm(newVal) && existingVal !== newVal;
@@ -5247,11 +6212,253 @@ const _PreferTitleWithYear = class _PreferTitleWithYear extends Rule {
5247
6212
  _PreferTitleWithYear.priority = 32;
5248
6213
  _PreferTitleWithYear.dependency = [TitleFromPosition];
5249
6214
  let PreferTitleWithYear = _PreferTitleWithYear;
6215
+ const ARTICLES = /* @__PURE__ */ new Set([
6216
+ "the",
6217
+ "a",
6218
+ "an",
6219
+ "le",
6220
+ "la",
6221
+ "les",
6222
+ "l'",
6223
+ "el",
6224
+ "los",
6225
+ "las",
6226
+ "il",
6227
+ "lo",
6228
+ "un",
6229
+ "una",
6230
+ "der",
6231
+ "die",
6232
+ "das",
6233
+ "de",
6234
+ "het",
6235
+ "o",
6236
+ "os"
6237
+ ]);
6238
+ const _ExtendLoneArticleTitle = class _ExtendLoneArticleTitle extends Rule {
6239
+ constructor() {
6240
+ super(...arguments);
6241
+ this.consequence = RemoveMatch;
6242
+ }
6243
+ when(matches, _context) {
6244
+ const inp = matches.inputString || "";
6245
+ const out = [];
6246
+ const titles = matches.named("title");
6247
+ const titleArr = Array.isArray(titles) ? titles : titles ? [titles] : [];
6248
+ for (const title2 of titleArr) {
6249
+ if (!ARTICLES.has(String(title2.value ?? "").trim().toLowerCase())) continue;
6250
+ const filepart = matches.markers.atMatch(title2, (m) => m.name === "path", 0);
6251
+ if (!filepart) continue;
6252
+ const prop = matches.range(
6253
+ title2.end,
6254
+ filepart.end,
6255
+ (m) => !m.private && ["edition", "language", "country", "other", "source"].includes(m.name ?? ""),
6256
+ 0
6257
+ );
6258
+ if (!prop) continue;
6259
+ if (![...inp.slice(title2.end, prop.start)].every((c) => seps.includes(c))) continue;
6260
+ const next = matches.range(
6261
+ prop.end,
6262
+ filepart.end,
6263
+ (m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
6264
+ 0
6265
+ );
6266
+ if (next && inp.slice(prop.end, next.start).replace(/[sexd]/gi, "").split("").some((c) => !seps.includes(c))) continue;
6267
+ out.push({ title: title2, prop });
6268
+ }
6269
+ return out.length ? out : false;
6270
+ }
6271
+ then(matches, whenResponse, _context) {
6272
+ for (const { title: title2, prop } of whenResponse) {
6273
+ const inp = matches.inputString || "";
6274
+ matches.remove(title2);
6275
+ matches.remove(prop);
6276
+ title2.end = prop.end;
6277
+ title2.value = cleanup(inp.slice(title2.start, title2.end));
6278
+ matches.append(title2);
6279
+ }
6280
+ }
6281
+ };
6282
+ _ExtendLoneArticleTitle.priority = -32;
6283
+ let ExtendLoneArticleTitle = _ExtendLoneArticleTitle;
6284
+ const _CountryAtTitlePosition = class _CountryAtTitlePosition extends Rule {
6285
+ constructor() {
6286
+ super(...arguments);
6287
+ this.consequence = RemoveMatch;
6288
+ }
6289
+ when(matches, _context) {
6290
+ const inp = matches.inputString || "";
6291
+ const out = [];
6292
+ const cand = matches.range(
6293
+ 0,
6294
+ inp.length,
6295
+ (m) => !m.private && ["country", "other", "edition"].includes(m.name ?? "")
6296
+ );
6297
+ const arr = Array.isArray(cand) ? cand : cand ? [cand] : [];
6298
+ for (const c of arr) {
6299
+ if (!/^[A-Z][a-z]+$/.test(c.raw ?? "")) continue;
6300
+ const filepart = matches.markers.atMatch(c, (m) => m.name === "path", 0);
6301
+ if (!filepart) continue;
6302
+ if (![...inp.slice(filepart.start, c.start)].every((ch) => seps.includes(ch))) continue;
6303
+ const year = matches.range(c.end, filepart.end, (m) => !m.private && m.name === "year", 0);
6304
+ if (!year) continue;
6305
+ const se = matches.range(c.end, year.start, (m) => !m.private && ["season", "episode", "date"].includes(m.name ?? ""), 0);
6306
+ if (se) continue;
6307
+ if (![...inp.slice(c.end, year.start)].every((ch) => seps.includes(ch))) continue;
6308
+ out.push(c);
6309
+ }
6310
+ return out.length ? out : false;
6311
+ }
6312
+ };
6313
+ _CountryAtTitlePosition.priority = 64;
6314
+ let CountryAtTitlePosition = _CountryAtTitlePosition;
6315
+ const _PropertyAtTitlePositionAsTitle = class _PropertyAtTitlePositionAsTitle extends Rule {
6316
+ constructor() {
6317
+ super(...arguments);
6318
+ this.consequence = RemoveMatch;
6319
+ }
6320
+ when(matches, _context) {
6321
+ const inp = matches.inputString || "";
6322
+ const out = [];
6323
+ for (const filepart of matches.markers.named("path")) {
6324
+ if (matches.range(filepart.start, filepart.end, (m) => m.name === "title", 0)) continue;
6325
+ const anchor = matches.range(
6326
+ filepart.start,
6327
+ filepart.end,
6328
+ (m) => !m.private && ["year", "season", "episode", "date"].includes(m.name ?? ""),
6329
+ 0
6330
+ );
6331
+ if (!anchor) continue;
6332
+ const lead = matches.range(filepart.start, filepart.end, (m) => !m.private && !!m.value, 0);
6333
+ if (!lead || !["other", "country", "edition"].includes(lead.name ?? "")) continue;
6334
+ if (lead.start >= anchor.start) continue;
6335
+ if (![...inp.slice(filepart.start, lead.start)].every((c) => seps.includes(c))) continue;
6336
+ out.push(lead);
6337
+ }
6338
+ return out.length ? out : false;
6339
+ }
6340
+ then(matches, whenResponse, _context) {
6341
+ const inp = matches.inputString || "";
6342
+ for (const lead of whenResponse) {
6343
+ matches.remove(lead);
6344
+ const t = new Match(lead.start, lead.end, {
6345
+ name: "title",
6346
+ value: cleanup(inp.slice(lead.start, lead.end)),
6347
+ inputString: inp
6348
+ });
6349
+ matches.append(t);
6350
+ }
6351
+ }
6352
+ };
6353
+ _PropertyAtTitlePositionAsTitle.priority = -48;
6354
+ let PropertyAtTitlePositionAsTitle = _PropertyAtTitlePositionAsTitle;
6355
+ const _RemoveNumericAlternativeTitle = class _RemoveNumericAlternativeTitle extends Rule {
6356
+ constructor() {
6357
+ super(...arguments);
6358
+ this.consequence = RemoveMatch;
6359
+ }
6360
+ when(matches, _context) {
6361
+ const alts = matches.named("alternative_title");
6362
+ const altArr = Array.isArray(alts) ? alts : alts ? [alts] : [];
6363
+ if (!altArr.length) return false;
6364
+ const out = [];
6365
+ for (const alt of altArr) {
6366
+ const raw = String(alt.raw ?? alt.value ?? "");
6367
+ if (!/^[\d\s.~_-]+$/.test(raw) || !/\d/.test(raw)) continue;
6368
+ const filepart = matches.markers.atMatch(alt, (m) => m.name === "path", 0);
6369
+ if (!filepart) continue;
6370
+ const hasEpisode = matches.range(
6371
+ filepart.start,
6372
+ filepart.end,
6373
+ (m) => m.name === "episode" || m.name === "absolute_episode",
6374
+ 0
6375
+ );
6376
+ if (hasEpisode) out.push(alt);
6377
+ }
6378
+ return out.length ? out : false;
6379
+ }
6380
+ };
6381
+ _RemoveNumericAlternativeTitle.priority = -64;
6382
+ let RemoveNumericAlternativeTitle = _RemoveNumericAlternativeTitle;
6383
+ const _RemoveTailAlternativeTitle = class _RemoveTailAlternativeTitle extends Rule {
6384
+ constructor() {
6385
+ super(...arguments);
6386
+ this.consequence = RemoveMatch;
6387
+ }
6388
+ when(matches, _context) {
6389
+ const alts = matches.named("alternative_title");
6390
+ const altArr = Array.isArray(alts) ? alts : alts ? [alts] : [];
6391
+ if (!altArr.length) return false;
6392
+ const titleish = /* @__PURE__ */ new Set(["year", "title", "alternative_title", "episode_title", "type"]);
6393
+ const out = [];
6394
+ for (const alt of altArr) {
6395
+ const filepart = matches.markers.atMatch(alt, (m) => m.name === "path", 0);
6396
+ if (!filepart) continue;
6397
+ const years = matches.range(filepart.start, filepart.end, (m) => m.name === "year");
6398
+ const yearArr = Array.isArray(years) ? years : years ? [years] : [];
6399
+ if (!yearArr.length) continue;
6400
+ const yMax = Math.max(...yearArr.map((y) => y.end));
6401
+ if (alt.start < yMax) continue;
6402
+ const between = matches.range(
6403
+ yMax,
6404
+ alt.start,
6405
+ (m) => !m.private && !!m.value && !titleish.has(m.name ?? ""),
6406
+ 0
6407
+ );
6408
+ if (between) out.push(alt);
6409
+ }
6410
+ return out.length ? out : false;
6411
+ }
6412
+ };
6413
+ _RemoveTailAlternativeTitle.priority = POST_PROCESS;
6414
+ _RemoveTailAlternativeTitle.dependency = ["RenameEpisodeTitleWhenMovieType"];
6415
+ let RemoveTailAlternativeTitle = _RemoveTailAlternativeTitle;
6416
+ const _RemoveTailTitle = class _RemoveTailTitle extends Rule {
6417
+ constructor() {
6418
+ super(...arguments);
6419
+ this.consequence = RemoveMatch;
6420
+ }
6421
+ when(matches, _context) {
6422
+ const titleish = /* @__PURE__ */ new Set(["year", "title", "alternative_title", "episode_title", "type"]);
6423
+ const out = [];
6424
+ for (const filepart of matches.markers.named("path")) {
6425
+ const titles = matches.range(
6426
+ filepart.start,
6427
+ filepart.end,
6428
+ (m) => m.name === "title"
6429
+ );
6430
+ const titleArr = (Array.isArray(titles) ? titles : titles ? [titles] : []).slice().sort((a, b) => a.start - b.start);
6431
+ if (titleArr.length < 2) continue;
6432
+ const primary = titleArr[0];
6433
+ const head = String(primary.value ?? "").trim().toLowerCase();
6434
+ if (!head) continue;
6435
+ if (TITLE_STOP_WORDS.has(head)) {
6436
+ if (titleArr.slice(1).some((t) => !TITLE_STOP_WORDS.has(String(t.value ?? "").trim().toLowerCase()))) {
6437
+ out.push(primary);
6438
+ }
6439
+ continue;
6440
+ }
6441
+ for (const t of titleArr.slice(1)) {
6442
+ const between = matches.range(
6443
+ primary.end,
6444
+ t.start,
6445
+ (m) => !m.private && !!m.value && !titleish.has(m.name ?? ""),
6446
+ 0
6447
+ );
6448
+ if (between) out.push(t);
6449
+ }
6450
+ }
6451
+ return out.length ? out : false;
6452
+ }
6453
+ };
6454
+ _RemoveTailTitle.priority = POST_PROCESS;
6455
+ _RemoveTailTitle.dependency = ["RenameEpisodeTitleWhenMovieType"];
6456
+ let RemoveTailTitle = _RemoveTailTitle;
5250
6457
  function title(config) {
5251
6458
  const rebulk = new Rebulk({
5252
6459
  disabled: (context) => isDisabled(context, "title")
5253
6460
  });
5254
- rebulk.rules(TitleFromPosition, PreferTitleWithYear);
6461
+ rebulk.rules(CountryAtTitlePosition, TitleFromPosition, PreferTitleWithYear, ExtendLoneArticleTitle, PropertyAtTitlePositionAsTitle, RemoveNumericAlternativeTitle, RemoveTailAlternativeTitle, RemoveTailTitle);
5255
6462
  const expectedTitle = buildExpectedFunction("expected_title");
5256
6463
  rebulk.functional(expectedTitle, {
5257
6464
  name: "title",
@@ -5283,10 +6490,279 @@ function episodeTitle(config) {
5283
6490
  TrimLanguageFromEpisodeTitle,
5284
6491
  Filepart3EpisodeTitle,
5285
6492
  Filepart2EpisodeTitle,
6493
+ NumericEpisodeTitleToEpisode,
6494
+ RemoveEpisodeTitleInReleaseGroup,
6495
+ RemoveEpisodeMarkerWordTitle,
6496
+ RemoveEpisodeTitleCoveredByDetailsInGroup,
6497
+ RemoveFansubCreditEpisodeTitle,
6498
+ RemoveSubtitleDescriptorEpisodeTitle,
6499
+ RemoveHashFilepartJunk,
6500
+ RemoveTailEpisodeTitle,
5286
6501
  RenameEpisodeTitleWhenMovieType
5287
6502
  );
5288
6503
  return rebulk;
5289
6504
  }
6505
+ const EPISODE_MARKER_WORDS = /* @__PURE__ */ new Set([
6506
+ "ep",
6507
+ "eps",
6508
+ "episode",
6509
+ "episodes",
6510
+ "episodio",
6511
+ "episodios",
6512
+ "cap",
6513
+ "capitulo",
6514
+ "capitulos",
6515
+ "folge",
6516
+ "e"
6517
+ ]);
6518
+ const _RemoveEpisodeMarkerWordTitle = class _RemoveEpisodeMarkerWordTitle extends Rule {
6519
+ constructor() {
6520
+ super(...arguments);
6521
+ this.consequence = RemoveMatch;
6522
+ }
6523
+ when(matches, _context) {
6524
+ const ets = matches.named("episode_title");
6525
+ const etArr = Array.isArray(ets) ? ets : ets ? [ets] : [];
6526
+ if (!etArr.length) return false;
6527
+ const out = [];
6528
+ for (const et of etArr) {
6529
+ if (!EPISODE_MARKER_WORDS.has(String(et.value ?? "").trim().toLowerCase())) continue;
6530
+ const next = matches.range(
6531
+ et.end,
6532
+ matches.inputString?.length ?? et.end + 100,
6533
+ (m) => !m.private && !!m.value,
6534
+ 0
6535
+ );
6536
+ if (next && next.name === "episode") out.push(et);
6537
+ }
6538
+ return out.length ? out : false;
6539
+ }
6540
+ };
6541
+ _RemoveEpisodeMarkerWordTitle.priority = POST_PROCESS;
6542
+ let RemoveEpisodeMarkerWordTitle = _RemoveEpisodeMarkerWordTitle;
6543
+ const _RemoveHashFilepartJunk = class _RemoveHashFilepartJunk extends Rule {
6544
+ constructor() {
6545
+ super(...arguments);
6546
+ this.consequence = RemoveMatch;
6547
+ }
6548
+ static isHash(token) {
6549
+ if (/[\s._\-]/.test(token)) return false;
6550
+ if (/^[0-9a-f]{16,}$/i.test(token)) return true;
6551
+ return token.length >= 24 && /[a-z]/.test(token) && /[A-Z]/.test(token) && /\d/.test(token);
6552
+ }
6553
+ when(matches, _context) {
6554
+ const inp = matches.inputString ?? "";
6555
+ const strip2 = /* @__PURE__ */ new Set(["episode_title", "version", "episode_details", "alternative_title"]);
6556
+ const out = [];
6557
+ for (const fp of matches.markers.named("path")) {
6558
+ let text = inp.slice(fp.start, fp.end);
6559
+ const cont = matches.range(fp.start, fp.end, (m) => m.name === "container", 0);
6560
+ if (cont) text = inp.slice(fp.start, cont.start);
6561
+ if (!_RemoveHashFilepartJunk.isHash(text.replace(/[.\s]+$/, ""))) continue;
6562
+ for (const m of matches.range(fp.start, fp.end, (m2) => strip2.has(m2.name ?? ""))) {
6563
+ out.push(m);
6564
+ }
6565
+ }
6566
+ return out.length ? out : false;
6567
+ }
6568
+ };
6569
+ _RemoveHashFilepartJunk.priority = POST_PROCESS;
6570
+ let RemoveHashFilepartJunk = _RemoveHashFilepartJunk;
6571
+ const _RemoveEpisodeTitleCoveredByDetailsInGroup = class _RemoveEpisodeTitleCoveredByDetailsInGroup extends Rule {
6572
+ constructor() {
6573
+ super(...arguments);
6574
+ this.consequence = RemoveMatch;
6575
+ }
6576
+ when(matches, _context) {
6577
+ const ets = matches.named("episode_title");
6578
+ const etArr = Array.isArray(ets) ? ets : ets ? [ets] : [];
6579
+ const out = [];
6580
+ for (const et of etArr) {
6581
+ if (!matches.markers.atMatch(et, (m) => m.name === "group", 0)) continue;
6582
+ const covered = matches.range(
6583
+ et.start,
6584
+ et.end,
6585
+ (m) => m.name === "episode_details" && m.start <= et.start && m.end >= et.end,
6586
+ 0
6587
+ );
6588
+ if (covered) out.push(et);
6589
+ }
6590
+ return out.length ? out : false;
6591
+ }
6592
+ };
6593
+ _RemoveEpisodeTitleCoveredByDetailsInGroup.priority = POST_PROCESS;
6594
+ let RemoveEpisodeTitleCoveredByDetailsInGroup = _RemoveEpisodeTitleCoveredByDetailsInGroup;
6595
+ const _RemoveFansubCreditEpisodeTitle = class _RemoveFansubCreditEpisodeTitle extends Rule {
6596
+ constructor() {
6597
+ super(...arguments);
6598
+ this.consequence = RemoveMatch;
6599
+ }
6600
+ when(matches, _context) {
6601
+ const ets = matches.named("episode_title");
6602
+ const etArr = Array.isArray(ets) ? ets : ets ? [ets] : [];
6603
+ const out = etArr.filter((et) => /\bfansub/i.test(String(et.value ?? "")));
6604
+ return out.length ? out : false;
6605
+ }
6606
+ };
6607
+ _RemoveFansubCreditEpisodeTitle.priority = POST_PROCESS;
6608
+ let RemoveFansubCreditEpisodeTitle = _RemoveFansubCreditEpisodeTitle;
6609
+ const _RemoveSubtitleDescriptorEpisodeTitle = class _RemoveSubtitleDescriptorEpisodeTitle extends Rule {
6610
+ constructor() {
6611
+ super(...arguments);
6612
+ this.consequence = RemoveMatch;
6613
+ }
6614
+ when(matches, _context) {
6615
+ const inp = matches.inputString ?? "";
6616
+ const ets = matches.named("episode_title");
6617
+ const etArr = Array.isArray(ets) ? ets : ets ? [ets] : [];
6618
+ const out = [];
6619
+ for (const et of etArr) {
6620
+ if (/[\s.]/.test(String(et.value ?? "").trim())) continue;
6621
+ const after = inp.slice(et.end).replace(/^[\s._-]+/, "");
6622
+ if (/^subtitl(e|es)\b|^subs?\b/i.test(after)) out.push(et);
6623
+ }
6624
+ return out.length ? out : false;
6625
+ }
6626
+ };
6627
+ _RemoveSubtitleDescriptorEpisodeTitle.priority = POST_PROCESS;
6628
+ let RemoveSubtitleDescriptorEpisodeTitle = _RemoveSubtitleDescriptorEpisodeTitle;
6629
+ const ET_STOP_WORDS = /* @__PURE__ */ new Set([
6630
+ "the",
6631
+ "a",
6632
+ "an",
6633
+ "and",
6634
+ "or",
6635
+ "of",
6636
+ "to",
6637
+ "in",
6638
+ "on",
6639
+ "at",
6640
+ "for",
6641
+ "from",
6642
+ "by",
6643
+ "with",
6644
+ "le",
6645
+ "la",
6646
+ "les",
6647
+ "de",
6648
+ "du",
6649
+ "des",
6650
+ "el"
6651
+ ]);
6652
+ const _RemoveTailEpisodeTitle = class _RemoveTailEpisodeTitle extends Rule {
6653
+ constructor() {
6654
+ super(...arguments);
6655
+ this.consequence = RemoveMatch;
6656
+ }
6657
+ when(matches, _context) {
6658
+ const out = [];
6659
+ for (const fp of matches.markers.named("path")) {
6660
+ const ets = matches.range(fp.start, fp.end, (m) => m.name === "episode_title");
6661
+ const etArr = (Array.isArray(ets) ? ets : ets ? [ets] : []).slice().sort((a, b) => a.start - b.start);
6662
+ if (etArr.length < 2) continue;
6663
+ const primary = etArr[0];
6664
+ const head = String(primary.value ?? "").trim().toLowerCase();
6665
+ if (!head || ET_STOP_WORDS.has(head)) continue;
6666
+ for (const et of etArr.slice(1)) {
6667
+ const between = matches.range(
6668
+ primary.end,
6669
+ et.start,
6670
+ (m) => !m.private && !!m.value && !_RemoveTailEpisodeTitle.TITLEISH.has(m.name ?? ""),
6671
+ 0
6672
+ );
6673
+ if (between) out.push(et);
6674
+ }
6675
+ }
6676
+ return out.length ? out : false;
6677
+ }
6678
+ };
6679
+ _RemoveTailEpisodeTitle.priority = POST_PROCESS;
6680
+ _RemoveTailEpisodeTitle.TITLEISH = /* @__PURE__ */ new Set([
6681
+ "year",
6682
+ "title",
6683
+ "alternative_title",
6684
+ "episode_title",
6685
+ "type",
6686
+ "episode",
6687
+ "season"
6688
+ ]);
6689
+ let RemoveTailEpisodeTitle = _RemoveTailEpisodeTitle;
6690
+ const _RemoveEpisodeTitleInReleaseGroup = class _RemoveEpisodeTitleInReleaseGroup extends Rule {
6691
+ constructor() {
6692
+ super(...arguments);
6693
+ this.consequence = RemoveMatch;
6694
+ }
6695
+ when(matches, _context) {
6696
+ const ets = matches.named("episode_title");
6697
+ const etArr = Array.isArray(ets) ? ets : ets ? [ets] : [];
6698
+ if (!etArr.length) return false;
6699
+ const out = [];
6700
+ const inp = matches.inputString ?? "";
6701
+ const hasReleaseIn = (s, e) => !!matches.range(s, e, (m) => _RemoveEpisodeTitleInReleaseGroup.RELEASE_PROPS.has(m.name ?? ""), 0);
6702
+ const onlySeps = (s, e) => e <= s || [...inp.slice(s, e)].every((c) => "[](){} .-_".includes(c));
6703
+ for (const et of etArr) {
6704
+ const group = matches.markers.atMatch(et, (m) => m.name === "group", 0);
6705
+ if (!group) continue;
6706
+ let tag = hasReleaseIn(group.start, group.end);
6707
+ if (!tag) {
6708
+ for (const other2 of matches.markers.named("group")) {
6709
+ if (other2.span?.[0] === group.span?.[0]) continue;
6710
+ const adjacent = other2.start >= group.end && onlySeps(group.end, other2.start) || other2.end <= group.start && onlySeps(other2.end, group.start);
6711
+ if (adjacent && hasReleaseIn(other2.start, other2.end)) {
6712
+ tag = true;
6713
+ break;
6714
+ }
6715
+ }
6716
+ }
6717
+ if (tag) out.push(et);
6718
+ }
6719
+ return out.length ? out : false;
6720
+ }
6721
+ };
6722
+ _RemoveEpisodeTitleInReleaseGroup.priority = POST_PROCESS;
6723
+ _RemoveEpisodeTitleInReleaseGroup.RELEASE_PROPS = /* @__PURE__ */ new Set([
6724
+ "screen_size",
6725
+ "video_codec",
6726
+ "audio_codec",
6727
+ "audio_channels",
6728
+ "source",
6729
+ "color_depth",
6730
+ "video_profile",
6731
+ "audio_profile",
6732
+ "streaming_service",
6733
+ "video_bit_rate",
6734
+ "audio_bit_rate",
6735
+ "container"
6736
+ ]);
6737
+ let RemoveEpisodeTitleInReleaseGroup = _RemoveEpisodeTitleInReleaseGroup;
6738
+ const _NumericEpisodeTitleToEpisode = class _NumericEpisodeTitleToEpisode extends Rule {
6739
+ constructor() {
6740
+ super(...arguments);
6741
+ this.consequence = RemoveMatch;
6742
+ }
6743
+ when(matches, _context) {
6744
+ const out = [];
6745
+ for (const fp of matches.markers.named("path")) {
6746
+ if (matches.range(fp.start, fp.end, (m) => m.name === "episode" && !m.private, 0)) continue;
6747
+ if (!matches.range(fp.start, fp.end, (m) => m.name === "season" && !m.private, 0)) continue;
6748
+ const ets = matches.range(fp.start, fp.end, (m) => m.name === "episode_title");
6749
+ for (const et of Array.isArray(ets) ? ets : ets ? [ets] : []) {
6750
+ if (/^\d{1,3}$/.test(String(et.value ?? "").trim())) out.push(et);
6751
+ }
6752
+ }
6753
+ return out.length ? out : false;
6754
+ }
6755
+ then(matches, whenResponse, _context) {
6756
+ for (const et of whenResponse) {
6757
+ matches.remove(et);
6758
+ et.name = "episode";
6759
+ et.value = parseInt(String(et.value).trim(), 10);
6760
+ matches.append(et);
6761
+ }
6762
+ }
6763
+ };
6764
+ _NumericEpisodeTitleToEpisode.priority = POST_PROCESS;
6765
+ let NumericEpisodeTitleToEpisode = _NumericEpisodeTitleToEpisode;
5290
6766
  const _RemoveConflictsWithEpisodeTitle = class _RemoveConflictsWithEpisodeTitle extends Rule {
5291
6767
  constructor() {
5292
6768
  super(...arguments);
@@ -5459,7 +6935,14 @@ const _EpisodeTitleFromPosition = class _EpisodeTitleFromPosition extends Rule {
5459
6935
  this.previousNames = ["episode", "episode_count", "season", "season_count", "date", "title", "year"];
5460
6936
  }
5461
6937
  isIgnored(match) {
5462
- return match.name === "language" || match.name === "country" || match.name === "episode_details";
6938
+ if (!(match.name === "language" || match.name === "country" || match.name === "episode_details")) {
6939
+ return false;
6940
+ }
6941
+ const raw = match.raw ?? "";
6942
+ if (match.end - match.start > 3 && raw !== "" && raw === raw.toUpperCase() && raw !== raw.toLowerCase()) {
6943
+ return false;
6944
+ }
6945
+ return true;
5463
6946
  }
5464
6947
  when(matches, _context) {
5465
6948
  const toAppend = [];
@@ -5491,7 +6974,44 @@ const _EpisodeTitleFromPosition = class _EpisodeTitleFromPosition extends Rule {
5491
6974
  predicate: (m) => !!m.value
5492
6975
  });
5493
6976
  const holeArray = Array.isArray(holesResult) ? holesResult : holesResult ? [holesResult] : [];
6977
+ const inp = matches.inputString || "";
5494
6978
  for (const hole of holeArray) {
6979
+ const groupMarker = matches.markers?.atMatch?.(hole, (m) => m.name === "group", 0);
6980
+ if (groupMarker) {
6981
+ const yearInGroup = matches.range(
6982
+ groupMarker.start,
6983
+ groupMarker.end,
6984
+ (m) => (m.name === "year" || m.name === "date") && !m.private,
6985
+ 0
6986
+ );
6987
+ if (yearInGroup) continue;
6988
+ }
6989
+ const cropName = (m) => m.name === "language" || m.name === "country";
6990
+ const fpLangsRaw = matches.range(filepart.start, filepart.end, (m) => cropName(m));
6991
+ const langArr = Array.isArray(fpLangsRaw) ? fpLangsRaw : fpLangsRaw ? [fpLangsRaw] : [];
6992
+ let guard = 0;
6993
+ while (guard++ < 64) {
6994
+ let e = hole.end;
6995
+ while (e > hole.start && seps.includes(inp[e - 1])) e--;
6996
+ if (e <= hole.start) break;
6997
+ const cover = langArr.find((m) => m.start <= e - 1 && m.end >= e);
6998
+ if (cover && cover.start < hole.end) {
6999
+ hole.end = Math.min(hole.end, cover.start);
7000
+ } else break;
7001
+ }
7002
+ guard = 0;
7003
+ while (guard++ < 64) {
7004
+ let s = hole.start;
7005
+ while (s < hole.end && seps.includes(inp[s])) s++;
7006
+ if (s >= hole.end) break;
7007
+ const cover = langArr.find((m) => m.start <= s && m.end >= s + 1);
7008
+ if (cover && cover.end > hole.start) {
7009
+ hole.start = Math.max(hole.start, cover.end);
7010
+ } else break;
7011
+ }
7012
+ while (hole.start < hole.end && seps.includes(inp[hole.start])) hole.start++;
7013
+ while (hole.end > hole.start && seps.includes(inp[hole.end - 1])) hole.end--;
7014
+ if (hole.end <= hole.start || !hole.value) continue;
5495
7015
  const prevPred = (m) => !m.private && this.previousNames.includes(m.name ?? "");
5496
7016
  const prevMatches = matches.range(filepart.start, hole.start, prevPred);
5497
7017
  const prevArr = Array.isArray(prevMatches) ? prevMatches : prevMatches ? [prevMatches] : [];
@@ -5796,7 +7316,7 @@ const LANGUAGES = [
5796
7316
  { alpha3: "fin", alpha2: "fi", name: "Finnish", opensubtitles: "fin" },
5797
7317
  { alpha3: "hun", alpha2: "hu", name: "Hungarian", opensubtitles: "hun" },
5798
7318
  { alpha3: "ces", alpha2: "cs", name: "Czech", opensubtitles: "cze" },
5799
- { alpha3: "rum", alpha2: "ro", name: "Romanian", opensubtitles: "rum" },
7319
+ { alpha3: "ron", alpha2: "ro", name: "Romanian", opensubtitles: "rum" },
5800
7320
  { alpha3: "ukr", alpha2: "uk", name: "Ukrainian", opensubtitles: "ukr" },
5801
7321
  { alpha3: "heb", alpha2: "he", name: "Hebrew", opensubtitles: "heb" },
5802
7322
  { alpha3: "cat", alpha2: "ca", name: "Catalan", opensubtitles: "cat" },
@@ -6143,23 +7663,33 @@ class LanguageFinder {
6143
7663
  regularLangMap.get(key).add(match);
6144
7664
  }
6145
7665
  }
7666
+ const emitted = /* @__PURE__ */ new Set();
7667
+ const emit = (m) => {
7668
+ const key = `${m.propertyName}:${m.word.start}-${m.word.end}:${m.lang.alpha3}`;
7669
+ if (emitted.has(key)) return void 0;
7670
+ emitted.add(key);
7671
+ return this.toRebulkMatch(m);
7672
+ };
6146
7673
  for (const [key, values] of multiMap) {
6147
7674
  if (regularLangMap.has(key) || !undeterminedMap.has(key)) {
6148
7675
  for (const value of values) {
6149
- yield this.toRebulkMatch(value);
7676
+ const r = emit(value);
7677
+ if (r) yield r;
6150
7678
  }
6151
7679
  }
6152
7680
  }
6153
7681
  for (const [key, values] of undeterminedMap) {
6154
7682
  if (!regularLangMap.has(key)) {
6155
7683
  for (const value of values) {
6156
- yield this.toRebulkMatch(value);
7684
+ const r = emit(value);
7685
+ if (r) yield r;
6157
7686
  }
6158
7687
  }
6159
7688
  }
6160
7689
  for (const values of regularLangMap.values()) {
6161
7690
  for (const value of values) {
6162
- yield this.toRebulkMatch(value);
7691
+ const r = emit(value);
7692
+ if (r) yield r;
6163
7693
  }
6164
7694
  }
6165
7695
  }
@@ -6281,7 +7811,13 @@ class LanguageFinder {
6281
7811
  let matchEnd = currentWord.end;
6282
7812
  if (currentWord !== word) {
6283
7813
  const trimmedValue = value.trim();
6284
- if (trimmedValue && fallbackWord) {
7814
+ if (trimmedValue && word && word.value.toLowerCase() === trimmedValue) {
7815
+ matchStart = word.start;
7816
+ matchEnd = word.end;
7817
+ } else if (trimmedValue && word && word.nextWord && word.nextWord.value.toLowerCase() === trimmedValue) {
7818
+ matchStart = word.nextWord.start;
7819
+ matchEnd = word.nextWord.end;
7820
+ } else if (trimmedValue && fallbackWord) {
6285
7821
  matchStart = fallbackWord.start;
6286
7822
  matchEnd = fallbackWord.end;
6287
7823
  }
@@ -6530,30 +8066,29 @@ const _RemoveCommonWordsLanguageRule = class _RemoveCommonWordsLanguageRule exte
6530
8066
  this.consequence = RemoveMatch;
6531
8067
  this.priority = 32;
6532
8068
  }
6533
- when(matches, context) {
8069
+ when(matches, _context) {
6534
8070
  const toRemove = [];
6535
- const fileparts = matches.markers?.named("path") || [];
6536
- const filepartArr = Array.isArray(fileparts) ? fileparts : fileparts ? [fileparts] : [];
6537
- for (const filepart of filepartArr) {
6538
- const langs = matches.range?.(
6539
- filepart.start,
6540
- filepart.end,
6541
- (m) => m.name === "language" || m.name === "subtitle_language"
6542
- ) || [];
6543
- const commonLangs = langs.filter((m) => m.tags?.includes("common"));
6544
- const nonCommonLangs = langs.filter((m) => !m.tags?.includes("common"));
6545
- if (nonCommonLangs.length === 0) {
6546
- toRemove.push(...commonLangs);
6547
- } else {
6548
- const groups2 = matches.markers?.named?.("group") || [];
6549
- const groupArr = Array.isArray(groups2) ? groups2 : groups2 ? [groups2] : [];
6550
- const isInGroup = (m) => groupArr.some((g) => m.start >= g.start && m.end <= g.end);
6551
- const nonCommonOutsideGroups = nonCommonLangs.filter((m) => !isInGroup(m));
6552
- if (nonCommonOutsideGroups.length === 0) {
6553
- const commonOutsideGroups = commonLangs.filter((m) => !isInGroup(m));
6554
- toRemove.push(...commonOutsideGroups);
6555
- }
8071
+ const all = matches.range?.(0, matches.inputString?.length ?? 0, (m) => m.name === "language" || m.name === "subtitle_language") || [];
8072
+ const allArr = Array.isArray(all) ? all : all ? [all] : [];
8073
+ for (const match of allArr) {
8074
+ if (!match.tags?.includes("common")) continue;
8075
+ const group = matches.markers?.atMatch?.(match, (m) => m.name === "group", 0);
8076
+ if (group) {
8077
+ const nonLang = matches.range?.(
8078
+ group.start,
8079
+ group.end,
8080
+ (m) => m.name !== "language" && m.name !== "subtitle_language"
8081
+ );
8082
+ const hasNonLang = Array.isArray(nonLang) ? nonLang.length > 0 : !!nonLang;
8083
+ const holesRes = matches.holes?.(
8084
+ group.start,
8085
+ group.end,
8086
+ { predicate: (m) => m.value && [...String(m.value)].some((c) => !seps.includes(c)) }
8087
+ );
8088
+ const hasContentHoles = Array.isArray(holesRes) ? holesRes.length > 0 : !!holesRes;
8089
+ if (!hasNonLang && !hasContentHoles) continue;
6556
8090
  }
8091
+ toRemove.push(match);
6557
8092
  }
6558
8093
  return toRemove.length > 0 ? toRemove : false;
6559
8094
  }
@@ -6596,16 +8131,44 @@ const _RemoveUndeterminedLanguagesRule = class _RemoveUndeterminedLanguagesRule
6596
8131
  };
6597
8132
  _RemoveUndeterminedLanguagesRule.priority = 32;
6598
8133
  let RemoveUndeterminedLanguagesRule = _RemoveUndeterminedLanguagesRule;
6599
- function language(config, commonWords) {
6600
- const subtitleBoth = config.subtitle_affixes;
6601
- const subtitlePrefixes = [
6602
- ...subtitleBoth,
6603
- ...config.subtitle_prefixes
6604
- ].sort((a, b) => b.length - a.length);
6605
- const subtitleSuffixes = [
6606
- ...subtitleBoth,
6607
- ...config.subtitle_suffixes
6608
- ].sort((a, b) => b.length - a.length);
8134
+ class DedupLanguageRule extends Rule {
8135
+ constructor() {
8136
+ super(...arguments);
8137
+ this.consequence = RemoveMatch;
8138
+ this.dependency = [SubtitlePrefixLanguageRule, SubtitleSuffixLanguageRule, SubtitleExtensionRule];
8139
+ }
8140
+ identity(match) {
8141
+ const v = match.value;
8142
+ if (v instanceof Language) {
8143
+ const country2 = v.country;
8144
+ return `${v.alpha3}:${country2 ? String(country2) : ""}`;
8145
+ }
8146
+ return String(v);
8147
+ }
8148
+ when(matches) {
8149
+ const toRemove = [];
8150
+ for (const name of ["language", "subtitle_language"]) {
8151
+ const list = [...matches.named(name) || []].sort((a, b) => a.start - b.start || a.end - b.end);
8152
+ const seen = /* @__PURE__ */ new Set();
8153
+ for (const m of list) {
8154
+ const key = `${m.start}-${m.end}:${this.identity(m)}`;
8155
+ if (seen.has(key)) toRemove.push(m);
8156
+ else seen.add(key);
8157
+ }
8158
+ }
8159
+ return toRemove.length > 0 ? toRemove : false;
8160
+ }
8161
+ }
8162
+ function language(config, commonWords) {
8163
+ const subtitleBoth = config.subtitle_affixes;
8164
+ const subtitlePrefixes = [
8165
+ ...subtitleBoth,
8166
+ ...config.subtitle_prefixes
8167
+ ].sort((a, b) => b.length - a.length);
8168
+ const subtitleSuffixes = [
8169
+ ...subtitleBoth,
8170
+ ...config.subtitle_suffixes
8171
+ ].sort((a, b) => b.length - a.length);
6609
8172
  const langBoth = config.language_affixes;
6610
8173
  const langPrefixes = [...langBoth, ...config.language_prefixes].sort(
6611
8174
  (a, b) => b.length - a.length
@@ -6670,10 +8233,38 @@ function language(config, commonWords) {
6670
8233
  SubtitleExtensionRule,
6671
8234
  RemoveCommonWordsLanguageRule,
6672
8235
  RemoveLanguageRule,
6673
- RemoveUndeterminedLanguagesRule
8236
+ RemoveUndeterminedLanguagesRule,
8237
+ DedupLanguageRule,
8238
+ RemoveLanguageInsideTitle
6674
8239
  );
6675
8240
  return rebulk;
6676
8241
  }
8242
+ const _RemoveLanguageInsideTitle = class _RemoveLanguageInsideTitle extends Rule {
8243
+ constructor() {
8244
+ super(...arguments);
8245
+ this.consequence = RemoveMatch;
8246
+ }
8247
+ when(matches) {
8248
+ const titleNames = /* @__PURE__ */ new Set(["title", "episode_title", "alternative_title"]);
8249
+ const titles = matches.range(
8250
+ 0,
8251
+ (matches.inputString ?? "").length,
8252
+ (m) => titleNames.has(m.name ?? "")
8253
+ );
8254
+ if (!titles.length) return false;
8255
+ const out = [];
8256
+ for (const name of ["language", "subtitle_language"]) {
8257
+ for (const lang of matches.named(name)) {
8258
+ const rawLen = String(lang.raw ?? "").trim().length;
8259
+ if (rawLen > 3) continue;
8260
+ if (titles.some((t) => t.start <= lang.start && t.end >= lang.end)) out.push(lang);
8261
+ }
8262
+ }
8263
+ return out.length ? out : false;
8264
+ }
8265
+ };
8266
+ _RemoveLanguageInsideTitle.priority = POST_PROCESS;
8267
+ let RemoveLanguageInsideTitle = _RemoveLanguageInsideTitle;
6677
8268
  const COUNTRY_MAP = {
6678
8269
  "us": "US",
6679
8270
  "usa": "US",
@@ -6813,9 +8404,24 @@ function releaseGroup(config) {
6813
8404
  return rebulk.rules(
6814
8405
  new DashSeparatedReleaseGroup(cleanGroupname),
6815
8406
  new SceneReleaseGroup(cleanGroupname),
6816
- AnimeReleaseGroup
8407
+ AnimeReleaseGroup,
8408
+ new TrailingTokenAfterEpisodeAsReleaseGroup(cleanGroupname),
8409
+ RemoveSeasonPackReleaseGroup
6817
8410
  );
6818
8411
  }
8412
+ const _RemoveSeasonPackReleaseGroup = class _RemoveSeasonPackReleaseGroup extends Rule {
8413
+ constructor() {
8414
+ super(...arguments);
8415
+ this.consequence = RemoveMatch;
8416
+ }
8417
+ when(matches) {
8418
+ const rgs = matches.named("release_group");
8419
+ const out = (Array.isArray(rgs) ? rgs : rgs ? [rgs] : []).filter((m) => /(^|[\s._\-\[(])seasons?[\s._-]*\d/i.test(String(m.value ?? "")));
8420
+ return out.length ? out : false;
8421
+ }
8422
+ };
8423
+ _RemoveSeasonPackReleaseGroup.priority = POST_PROCESS;
8424
+ let RemoveSeasonPackReleaseGroup = _RemoveSeasonPackReleaseGroup;
6819
8425
  class DashSeparatedReleaseGroup extends Rule {
6820
8426
  constructor(valueFormatter) {
6821
8427
  super();
@@ -6830,6 +8436,17 @@ class DashSeparatedReleaseGroup extends Rule {
6830
8436
  if (matches.markers.atMatch(candidate, (m) => m.name === "group", 0)) {
6831
8437
  return false;
6832
8438
  }
8439
+ if (matches.range(candidate.start, candidate.end, (m) => m.name === "episode", 0)) {
8440
+ return false;
8441
+ }
8442
+ if (candidate.start === start && matches.range(
8443
+ candidate.end,
8444
+ end,
8445
+ (m) => ["season", "episode", "date"].includes(m.name ?? "") && !m.private,
8446
+ 0
8447
+ )) {
8448
+ return false;
8449
+ }
6833
8450
  const firstHole = matches.holes(
6834
8451
  candidate.end,
6835
8452
  end,
@@ -7069,7 +8686,11 @@ const _AnimeReleaseGroup = class _AnimeReleaseGroup extends Rule {
7069
8686
  (mm) => !mm.tags.includes("weak-language")
7070
8687
  );
7071
8688
  if (innerMatches.length === 0) return true;
7072
- return innerMatches.every((mm) => mm.name === "other");
8689
+ if (innerMatches.every((mm) => mm.name === "other")) return true;
8690
+ if (m.start === filepart.start && innerMatches.every((mm) => mm.name === "container" && mm.tags?.includes("subtitle"))) {
8691
+ return true;
8692
+ }
8693
+ return false;
7073
8694
  };
7074
8695
  const emptyGroup = matches.markers.range(
7075
8696
  filepart.start,
@@ -7088,7 +8709,7 @@ const _AnimeReleaseGroup = class _AnimeReleaseGroup extends Rule {
7088
8709
  ...matches.range(
7089
8710
  emptyGroup.start,
7090
8711
  emptyGroup.end,
7091
- (m) => m.tags.includes("weak-language") || m.name === "other"
8712
+ (m) => m.tags.includes("weak-language") || m.name === "other" || m.name === "container" && m.tags?.includes("subtitle")
7092
8713
  )
7093
8714
  );
7094
8715
  }
@@ -7103,6 +8724,57 @@ _AnimeReleaseGroup.dependency = ["SceneReleaseGroup", "TitleFromPosition"];
7103
8724
  _AnimeReleaseGroup.consequence = [RemoveMatch, AppendMatch];
7104
8725
  _AnimeReleaseGroup.properties = { release_group: [null] };
7105
8726
  let AnimeReleaseGroup = _AnimeReleaseGroup;
8727
+ const _TrailingTokenAfterEpisodeAsReleaseGroup = class _TrailingTokenAfterEpisodeAsReleaseGroup extends Rule {
8728
+ constructor(valueFormatter) {
8729
+ super();
8730
+ this.consequence = [RemoveMatch, AppendMatch];
8731
+ this.valueFormatter = valueFormatter;
8732
+ }
8733
+ when(matches) {
8734
+ if (matches.named("release_group").length > 0) return false;
8735
+ const inp = matches.inputString ?? "";
8736
+ const toRemove = [];
8737
+ const toAppend = [];
8738
+ for (const filepart of matches.markers.named("path")) {
8739
+ const last = matches.range(
8740
+ filepart.start,
8741
+ filepart.end,
8742
+ (m) => !m.private && m.name === "episode_title" && m.value,
8743
+ -1
8744
+ );
8745
+ if (!last) continue;
8746
+ const after = matches.range(
8747
+ last.end,
8748
+ filepart.end,
8749
+ (m) => !m.private && m.span[0] !== m.span[1],
8750
+ 0
8751
+ );
8752
+ if (after) continue;
8753
+ const raw = String(last.raw ?? last.value);
8754
+ if (/[\s.]/.test(raw.trim())) continue;
8755
+ if (inp[last.start - 1] !== "-") continue;
8756
+ const prev = matches.range(
8757
+ filepart.start,
8758
+ last.start,
8759
+ (m) => !m.private,
8760
+ -1
8761
+ );
8762
+ if (!prev || !["episode", "absolute_episode"].includes(prev.name ?? "")) continue;
8763
+ const rg = new Match(last.start, last.end, {
8764
+ name: "release_group",
8765
+ inputString: inp
8766
+ });
8767
+ rg.formatter = this.valueFormatter;
8768
+ if (rg.value) {
8769
+ toRemove.push(last);
8770
+ toAppend.push(rg);
8771
+ }
8772
+ }
8773
+ return toRemove.length || toAppend.length ? [toRemove, toAppend] : false;
8774
+ }
8775
+ };
8776
+ _TrailingTokenAfterEpisodeAsReleaseGroup.dependency = ["AnimeReleaseGroup"];
8777
+ let TrailingTokenAfterEpisodeAsReleaseGroup = _TrailingTokenAfterEpisodeAsReleaseGroup;
7106
8778
  function streamingService(config) {
7107
8779
  const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "streaming_service") });
7108
8780
  rebulk.stringDefaults({ ignoreCase: true }).regexDefaults({ flags: "i", abbreviations: [dash] });
@@ -7116,7 +8788,17 @@ const _ValidateStreamingService = class _ValidateStreamingService extends Rule {
7116
8788
  const toRemove = [];
7117
8789
  const allServices = matches.named("streaming_service");
7118
8790
  if (process.env.DEBUG_SS) console.log(`[VS.when] allServices count=${allServices.length}`);
8791
+ const inp = matches.inputString || "";
7119
8792
  for (const service of allServices) {
8793
+ const rawLen = (service.raw ?? "").length;
8794
+ if (rawLen <= 3) {
8795
+ const charAfter = inp[service.end];
8796
+ const charBefore = inp[service.start - 1];
8797
+ if (charAfter && /[a-z0-9]/i.test(charAfter) || charBefore && /[a-z0-9]/i.test(charBefore)) {
8798
+ toRemove.push(service);
8799
+ continue;
8800
+ }
8801
+ }
7120
8802
  const suffixPred = (m) => !m.private && m.tags?.includes("streaming_service.suffix");
7121
8803
  const prefixPred = (m) => !m.private && m.tags?.includes("streaming_service.prefix");
7122
8804
  const suffixMatches = matches.range(service.end, service.end + 30, suffixPred);
@@ -7184,11 +8866,60 @@ function other(config) {
7184
8866
  ValidateStreamingServiceNeighbor,
7185
8867
  ValidateAtEnd,
7186
8868
  ValidateReal,
8869
+ RemoveTitleCaseAmbiguous,
8870
+ ImageArtKeywordToOther,
7187
8871
  ProperCountRule,
7188
8872
  FixCountRule
7189
8873
  );
7190
8874
  return rebulk;
7191
8875
  }
8876
+ const ART_KEYWORDS = {
8877
+ poster: "Poster",
8878
+ fanart: "Fanart",
8879
+ banner: "Banner",
8880
+ thumb: "Thumbnail",
8881
+ thumbnail: "Thumbnail",
8882
+ landscape: "Landscape",
8883
+ cover: "Cover",
8884
+ clearart: "Clear Art",
8885
+ clearlogo: "Clear Logo",
8886
+ logo: "Logo",
8887
+ discart: "Disc Art"
8888
+ };
8889
+ const _ImageArtKeywordToOther = class _ImageArtKeywordToOther extends Rule {
8890
+ constructor() {
8891
+ super(...arguments);
8892
+ this.consequence = [RemoveMatch, AppendMatch];
8893
+ }
8894
+ when(matches) {
8895
+ const toRemove = [];
8896
+ const toAppend = [];
8897
+ for (const fp of matches.markers.named("path")) {
8898
+ const hasImage = matches.range(
8899
+ fp.start,
8900
+ fp.end,
8901
+ (m) => m.name === "container" && m.tags?.includes("image"),
8902
+ 0
8903
+ );
8904
+ if (!hasImage) continue;
8905
+ const cands = matches.range(
8906
+ fp.start,
8907
+ fp.end,
8908
+ (m) => ["title", "alternative_title", "episode_title"].includes(m.name ?? "")
8909
+ );
8910
+ for (const c of cands) {
8911
+ const key = String(c.value ?? "").trim().toLowerCase().replace(/[\s._-]+/g, "");
8912
+ const canon = ART_KEYWORDS[key];
8913
+ if (!canon) continue;
8914
+ toRemove.push(c);
8915
+ toAppend.push(new Match(c.start, c.end, { name: "other", value: canon, inputString: matches.inputString }));
8916
+ }
8917
+ }
8918
+ return toRemove.length ? [toRemove, toAppend] : false;
8919
+ }
8920
+ };
8921
+ _ImageArtKeywordToOther.priority = POST_PROCESS;
8922
+ let ImageArtKeywordToOther = _ImageArtKeywordToOther;
7192
8923
  function completeWords(rebulk, seasonWords, completeArticleWords) {
7193
8924
  const seasonWordsPattern = buildOrPattern(seasonWords);
7194
8925
  const completeArticleWordsPattern = buildOrPattern(completeArticleWords);
@@ -7254,7 +8985,7 @@ let ProperCountRule = _ProperCountRule;
7254
8985
  const _FixCountRule = class _FixCountRule extends Rule {
7255
8986
  when(matches) {
7256
8987
  const fixes = matches.named("other", (m2) => m2.value === "Fix").filter((m2) => {
7257
- const raw = rawCleanup(m2.raw).toLowerCase();
8988
+ const raw = rawCleanup(m2.raw ?? "").toLowerCase();
7258
8989
  return raw === "fix" || raw === "fixed";
7259
8990
  });
7260
8991
  if (!fixes || fixes.length === 0) return;
@@ -7497,6 +9228,23 @@ const _ValidateAtEnd = class _ValidateAtEnd extends Rule {
7497
9228
  _ValidateAtEnd.priority = 32;
7498
9229
  _ValidateAtEnd.consequence = RemoveMatch;
7499
9230
  let ValidateAtEnd = _ValidateAtEnd;
9231
+ const _RemoveTitleCaseAmbiguous = class _RemoveTitleCaseAmbiguous extends Rule {
9232
+ // Exact Title-Case spellings of words that double as common title words. The
9233
+ // canonical tag spellings ("PROPER", "REAL.PROPER", "CAM", "CONVERT") and
9234
+ // lowercase scene spellings are unaffected; only the Title-Case word is removed.
9235
+ when(matches) {
9236
+ const TITLE_WORDS = /* @__PURE__ */ new Set(["Real", "Cam", "Convert"]);
9237
+ const ret = [];
9238
+ for (const m of matches.range(0, matches.inputString?.length ?? 0)) {
9239
+ if (m.name !== "other" && m.name !== "source") continue;
9240
+ if (TITLE_WORDS.has(m.raw ?? "")) ret.push(m);
9241
+ }
9242
+ return ret.length ? ret : false;
9243
+ }
9244
+ };
9245
+ _RemoveTitleCaseAmbiguous.consequence = RemoveMatch;
9246
+ _RemoveTitleCaseAmbiguous.priority = 64;
9247
+ let RemoveTitleCaseAmbiguous = _RemoveTitleCaseAmbiguous;
7500
9248
  const _ValidateReal = class _ValidateReal extends Rule {
7501
9249
  when(matches) {
7502
9250
  const ret = [];
@@ -7613,9 +9361,35 @@ function bonus(config) {
7613
9361
  const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "bonus") });
7614
9362
  rebulk.regexDefaults({ name: "bonus", flags: "i" });
7615
9363
  loadConfigPatterns(rebulk, config["bonus"]);
7616
- rebulk.rules(BonusToEpisodeRule, BonusTitleRule);
9364
+ rebulk.rules(BonusAtFilepartStartRule, BonusToEpisodeRule, BonusTitleRule);
7617
9365
  return rebulk;
7618
9366
  }
9367
+ const _BonusAtFilepartStartRule = class _BonusAtFilepartStartRule extends Rule {
9368
+ when(matches) {
9369
+ const inputString = matches.inputString || "";
9370
+ const bonuses = matches.named("bonus")?.filter((m) => !m.private) ?? [];
9371
+ const toRemove = [];
9372
+ for (const bonus2 of bonuses) {
9373
+ const filepart = matches.markers.atMatch(bonus2, (m) => m.name === "path", 0);
9374
+ if (!filepart) continue;
9375
+ const parent = bonus2.parent;
9376
+ const xStart = parent ? parent.start : bonus2.start - 1;
9377
+ const before = inputString.slice(filepart.start, xStart);
9378
+ if ([...before].every((c) => seps.includes(c))) {
9379
+ toRemove.push(bonus2);
9380
+ if (parent) toRemove.push(parent);
9381
+ }
9382
+ }
9383
+ return toRemove;
9384
+ }
9385
+ then(matches, whenResponse) {
9386
+ for (const m of whenResponse) {
9387
+ matches.remove(m);
9388
+ }
9389
+ }
9390
+ };
9391
+ _BonusAtFilepartStartRule.priority = 128;
9392
+ let BonusAtFilepartStartRule = _BonusAtFilepartStartRule;
7619
9393
  const _BonusToEpisodeRule = class _BonusToEpisodeRule extends Rule {
7620
9394
  when(matches) {
7621
9395
  const bonuses = matches.named("bonus")?.filter((m) => !m.private) ?? [];
@@ -7942,7 +9716,7 @@ function crc(_config) {
7942
9716
  });
7943
9717
  rebulk.regex("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}", {
7944
9718
  name: "uuid",
7945
- validator: null,
9719
+ validator: void 0,
7946
9720
  conflictSolver: (_match, other2) => ["episode", "season", "crc32"].includes(other2.name ?? "") ? other2 : "__default__"
7947
9721
  });
7948
9722
  rebulk.functional(guessIdnumber, {
@@ -7951,6 +9725,38 @@ function crc(_config) {
7951
9725
  });
7952
9726
  return rebulk;
7953
9727
  }
9728
+ function imdb(_config) {
9729
+ const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "imdb_id") });
9730
+ rebulk.regexDefaults({ flags: "i" });
9731
+ rebulk.defaults({ validator: sepsSurround });
9732
+ rebulk.regex("tt\\d{7,8}", {
9733
+ name: "imdb_id",
9734
+ formatter: (value) => value.toLowerCase()
9735
+ });
9736
+ rebulk.regex("tmdb(?:id)?[-=]?(?<tmdb_id>\\d{1,9})", {
9737
+ name: "tmdb_id",
9738
+ private_parent: true,
9739
+ children: true,
9740
+ formatter: (value) => parseInt(value, 10)
9741
+ });
9742
+ rebulk.regex("tvdb(?:id)?[-=]?(?<tvdb_id>\\d{1,9})", {
9743
+ name: "tvdb_id",
9744
+ private_parent: true,
9745
+ children: true,
9746
+ formatter: (value) => parseInt(value, 10)
9747
+ });
9748
+ return rebulk;
9749
+ }
9750
+ function volume(_config) {
9751
+ const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "volume") });
9752
+ rebulk.regexDefaults({ flags: "i" });
9753
+ rebulk.regex("vol(?:\\d{1,3}|(?:ume)?[-. ]\\d{1,3})", {
9754
+ name: "volume",
9755
+ validator: sepsSurround,
9756
+ formatter: (value) => parseInt(value.replace(/\D/g, ""), 10)
9757
+ });
9758
+ return rebulk;
9759
+ }
7954
9760
  const MIMETYPE_MAP = {
7955
9761
  "mkv": "video/x-matroska",
7956
9762
  "mp4": "video/mp4",
@@ -7968,9 +9774,19 @@ const MIMETYPE_MAP = {
7968
9774
  "jpeg": "image/jpeg",
7969
9775
  "png": "image/png",
7970
9776
  "gif": "image/gif",
9777
+ "svg": "image/svg+xml",
7971
9778
  "zip": "application/zip",
7972
9779
  "rar": "application/x-rar-compressed",
7973
- "pdf": "application/pdf"
9780
+ "pdf": "application/pdf",
9781
+ // .srt subtitles are plain text (matches Python's text/plain).
9782
+ "srt": "text/plain",
9783
+ // MPEG transport stream (Blu-ray/DVD/broadcast). video/mp2t is the correct
9784
+ // IANA type — Python's mimetypes returns a bogus "text/vnd.trolltech.linguist"
9785
+ // for .ts, so here we intentionally diverge to the *correct* value.
9786
+ "ts": "video/mp2t",
9787
+ // Disc image and torrent — both correct and match Python.
9788
+ "iso": "application/x-iso9660-image",
9789
+ "torrent": "application/x-bittorrent"
7974
9790
  };
7975
9791
  function mimetype(_config) {
7976
9792
  const rebulk = new Rebulk({ disabled: (context) => isDisabled(context, "mimetype") });
@@ -8461,6 +10277,8 @@ function rebulkBuilder(config) {
8461
10277
  rebulk.rebulk(film(cfg("film")));
8462
10278
  rebulk.rebulk(part(cfg("part")));
8463
10279
  rebulk.rebulk(crc(cfg("crc")));
10280
+ rebulk.rebulk(imdb(cfg("imdb")));
10281
+ rebulk.rebulk(volume(cfg("volume")));
8464
10282
  rebulk.rebulk(processors(cfg("processors")));
8465
10283
  rebulk.rebulk(mimetype(cfg("mimetype")));
8466
10284
  rebulk.rebulk(type_(cfg("type")));
@@ -8730,7 +10548,7 @@ const advanced_config = {
8730
10548
  },
8731
10549
  cd: {
8732
10550
  _cd_of_cd_count: {
8733
- regex: "cd-?(?P<cd>\\d+)(?:-?of-?(?P<cd_count>\\d+))?",
10551
+ regex: "(?<!\\d)(?<![^\\W\\d_])cd-?(?P<cd>\\d+)(?:-?of-?(?P<cd_count>\\d+))?",
8734
10552
  validator: {
8735
10553
  cd: "lambda match: 0 < match.value < 100",
8736
10554
  cd_count: "lambda match: 0 < match.value < 100"
@@ -8821,6 +10639,29 @@ const advanced_config = {
8821
10639
  ],
8822
10640
  nzb: [
8823
10641
  "nzb"
10642
+ ],
10643
+ archives: [
10644
+ "rar",
10645
+ "zip",
10646
+ "7z",
10647
+ "tar",
10648
+ "gz",
10649
+ "bz2",
10650
+ "tgz",
10651
+ "ace",
10652
+ "arj",
10653
+ "cbr",
10654
+ "cbz",
10655
+ "cb7"
10656
+ ],
10657
+ images: [
10658
+ "jpg",
10659
+ "jpeg",
10660
+ "png",
10661
+ "gif",
10662
+ "bmp",
10663
+ "tbn",
10664
+ "webp"
8824
10665
  ]
8825
10666
  },
8826
10667
  country: {
@@ -9035,7 +10876,8 @@ const advanced_config = {
9035
10876
  "s"
9036
10877
  ],
9037
10878
  season_ep_markers: [
9038
- "x"
10879
+ "x",
10880
+ "×"
9039
10881
  ],
9040
10882
  disc_markers: [
9041
10883
  "d"
@@ -9045,7 +10887,8 @@ const advanced_config = {
9045
10887
  "ex",
9046
10888
  "ep",
9047
10889
  "e",
9048
- "x"
10890
+ "x",
10891
+ "×"
9049
10892
  ],
9050
10893
  range_separators: [
9051
10894
  "-",
@@ -9392,6 +11235,57 @@ const advanced_config = {
9392
11235
  string: "3D",
9393
11236
  tags: "has-neighbor"
9394
11237
  },
11238
+ "Virtual Reality": {
11239
+ string: [
11240
+ "VR"
11241
+ ],
11242
+ regex: [
11243
+ "VR180",
11244
+ "VR360"
11245
+ ],
11246
+ tags: "has-neighbor"
11247
+ },
11248
+ "Opening Credits": {
11249
+ string: [
11250
+ "NCOP",
11251
+ "OPED"
11252
+ ],
11253
+ regex: [
11254
+ "NC-?OP",
11255
+ "creditless-?opening"
11256
+ ],
11257
+ tags: "has-neighbor"
11258
+ },
11259
+ "Ending Credits": {
11260
+ string: [
11261
+ "NCED"
11262
+ ],
11263
+ regex: [
11264
+ "NC-?ED",
11265
+ "creditless-?ending"
11266
+ ],
11267
+ tags: "has-neighbor"
11268
+ },
11269
+ "Half SBS": {
11270
+ string: [
11271
+ "HSBS"
11272
+ ],
11273
+ regex: [
11274
+ "Half-?SBS"
11275
+ ],
11276
+ tags: "has-neighbor"
11277
+ },
11278
+ "Half OU": {
11279
+ string: [
11280
+ "HOU",
11281
+ "HTAB"
11282
+ ],
11283
+ regex: [
11284
+ "Half-?OU",
11285
+ "Half-?TAB"
11286
+ ],
11287
+ tags: "has-neighbor"
11288
+ },
9395
11289
  "High Quality": {
9396
11290
  string: "HQ",
9397
11291
  tags: "uhdbluray-neighbor"
@@ -9399,10 +11293,16 @@ const advanced_config = {
9399
11293
  "High Resolution": "HR",
9400
11294
  "Line Dubbed": "LD",
9401
11295
  "Mic Dubbed": "MD",
9402
- "Micro HD": [
9403
- "mHD",
9404
- "HDLight"
9405
- ],
11296
+ "Micro HD": {
11297
+ string: [
11298
+ "mHD",
11299
+ "HDLight"
11300
+ ],
11301
+ regex: [
11302
+ "micro-?hd",
11303
+ "hd-?lite"
11304
+ ]
11305
+ },
9406
11306
  "Low Definition": "LDTV",
9407
11307
  "High Frame Rate": "HFR",
9408
11308
  "Variable Frame Rate": "VFR",
@@ -10025,6 +11925,1035 @@ function mergeOptionValue(option, value, merged) {
10025
11925
  function deepCopy(obj) {
10026
11926
  return JSON.parse(JSON.stringify(obj));
10027
11927
  }
11928
+ const GUESSIT_SCHEMA = {
11929
+ "absolute_episode": {
11930
+ "type": [
11931
+ "number"
11932
+ ],
11933
+ "array": true,
11934
+ "scalar": true
11935
+ },
11936
+ "alternative_title": {
11937
+ "type": [
11938
+ "string"
11939
+ ],
11940
+ "array": true,
11941
+ "scalar": true
11942
+ },
11943
+ "another": {
11944
+ "type": [
11945
+ "string"
11946
+ ],
11947
+ "array": false,
11948
+ "scalar": false
11949
+ },
11950
+ "aspect_ratio": {
11951
+ "type": [
11952
+ "number"
11953
+ ],
11954
+ "array": false,
11955
+ "scalar": true
11956
+ },
11957
+ "audio_bit_rate": {
11958
+ "type": [
11959
+ "string"
11960
+ ],
11961
+ "array": false,
11962
+ "scalar": true
11963
+ },
11964
+ "audio_channels": {
11965
+ "type": [
11966
+ "string"
11967
+ ],
11968
+ "array": true,
11969
+ "scalar": true,
11970
+ "enum": [
11971
+ "1.0",
11972
+ "1ch",
11973
+ "2.0",
11974
+ "20",
11975
+ "2ch",
11976
+ "5.1",
11977
+ "5ch",
11978
+ "6ch",
11979
+ "7.1",
11980
+ "7ch",
11981
+ "8ch",
11982
+ "mono",
11983
+ "stereo"
11984
+ ]
11985
+ },
11986
+ "audio_codec": {
11987
+ "type": [
11988
+ "string"
11989
+ ],
11990
+ "array": true,
11991
+ "scalar": true,
11992
+ "enum": [
11993
+ "AAC",
11994
+ "Atmos",
11995
+ "DD+",
11996
+ "DDP",
11997
+ "Dolby",
11998
+ "Dolby Atmos",
11999
+ "Dolby Digital",
12000
+ "Dolby Digital Plus",
12001
+ "Dolby TrueHD",
12002
+ "DolbyDigital",
12003
+ "DTS",
12004
+ "DTS-HD",
12005
+ "DTS-X",
12006
+ "DTS:X",
12007
+ "DTSX",
12008
+ "Flac",
12009
+ "FLAC",
12010
+ "LAME",
12011
+ "LPCM",
12012
+ "MP2",
12013
+ "MP3",
12014
+ "Opus",
12015
+ "PCM",
12016
+ "Vorbis"
12017
+ ]
12018
+ },
12019
+ "audio_profile": {
12020
+ "type": [
12021
+ "string"
12022
+ ],
12023
+ "array": true,
12024
+ "scalar": true,
12025
+ "enum": [
12026
+ "ES",
12027
+ "EX",
12028
+ "Extended Surround",
12029
+ "HE",
12030
+ "High Efficiency",
12031
+ "High Quality",
12032
+ "High Resolution Audio",
12033
+ "HQ",
12034
+ "HR",
12035
+ "HRA",
12036
+ "LC",
12037
+ "Low Complexity",
12038
+ "MA",
12039
+ "Master Audio"
12040
+ ]
12041
+ },
12042
+ "bonus": {
12043
+ "type": [
12044
+ "number"
12045
+ ],
12046
+ "array": false,
12047
+ "scalar": true
12048
+ },
12049
+ "bonus_title": {
12050
+ "type": [
12051
+ "string"
12052
+ ],
12053
+ "array": false,
12054
+ "scalar": true
12055
+ },
12056
+ "cd": {
12057
+ "type": [
12058
+ "number"
12059
+ ],
12060
+ "array": false,
12061
+ "scalar": true
12062
+ },
12063
+ "cd_count": {
12064
+ "type": [
12065
+ "number"
12066
+ ],
12067
+ "array": false,
12068
+ "scalar": true
12069
+ },
12070
+ "color_depth": {
12071
+ "type": [
12072
+ "string"
12073
+ ],
12074
+ "array": false,
12075
+ "scalar": true,
12076
+ "enum": [
12077
+ "10-bit",
12078
+ "12-bit",
12079
+ "8-bit"
12080
+ ]
12081
+ },
12082
+ "container": {
12083
+ "type": [
12084
+ "string"
12085
+ ],
12086
+ "array": true,
12087
+ "scalar": true,
12088
+ "enum": [
12089
+ "3g2",
12090
+ "3gp",
12091
+ "3gp2",
12092
+ "7z",
12093
+ "ace",
12094
+ "arj",
12095
+ "asf",
12096
+ "avi",
12097
+ "bmp",
12098
+ "bz2",
12099
+ "cb7",
12100
+ "cbr",
12101
+ "cbz",
12102
+ "divx",
12103
+ "flv",
12104
+ "gif",
12105
+ "gz",
12106
+ "idx",
12107
+ "iso",
12108
+ "jpeg",
12109
+ "jpg",
12110
+ "m2ts",
12111
+ "m4v",
12112
+ "mk2",
12113
+ "mk3d",
12114
+ "mka",
12115
+ "mkv",
12116
+ "MKV",
12117
+ "mov",
12118
+ "mp4",
12119
+ "mp4a",
12120
+ "mpeg",
12121
+ "mpg",
12122
+ "nfo",
12123
+ "nzb",
12124
+ "ogg",
12125
+ "ogm",
12126
+ "ogv",
12127
+ "png",
12128
+ "qt",
12129
+ "r00",
12130
+ "ra",
12131
+ "ram",
12132
+ "rar",
12133
+ "rm",
12134
+ "srt",
12135
+ "ssa",
12136
+ "tar",
12137
+ "tbn",
12138
+ "tgz",
12139
+ "torrent",
12140
+ "ts",
12141
+ "vob",
12142
+ "wav",
12143
+ "webm",
12144
+ "webp",
12145
+ "wma",
12146
+ "wmv",
12147
+ "zip"
12148
+ ]
12149
+ },
12150
+ "country": {
12151
+ "type": [
12152
+ "Language"
12153
+ ],
12154
+ "array": false,
12155
+ "scalar": true
12156
+ },
12157
+ "crc32": {
12158
+ "type": [
12159
+ "string"
12160
+ ],
12161
+ "array": false,
12162
+ "scalar": true
12163
+ },
12164
+ "date": {
12165
+ "type": [
12166
+ "object"
12167
+ ],
12168
+ "array": false,
12169
+ "scalar": true
12170
+ },
12171
+ "disc": {
12172
+ "type": [
12173
+ "number"
12174
+ ],
12175
+ "array": true,
12176
+ "scalar": true
12177
+ },
12178
+ "edition": {
12179
+ "type": [
12180
+ "string"
12181
+ ],
12182
+ "array": true,
12183
+ "scalar": true,
12184
+ "enum": [
12185
+ "Alternative Cut",
12186
+ "CC",
12187
+ "collector",
12188
+ "Collector",
12189
+ "Criterion",
12190
+ "DC",
12191
+ "ddc",
12192
+ "deluxe",
12193
+ "Deluxe",
12194
+ "Director's Cut",
12195
+ "Director's Definitive Cut",
12196
+ "extended",
12197
+ "Extended",
12198
+ "Fan",
12199
+ "Festival",
12200
+ "imax",
12201
+ "IMAX",
12202
+ "limited",
12203
+ "Limited",
12204
+ "Remastered",
12205
+ "Restored",
12206
+ "se",
12207
+ "Special",
12208
+ "theatrical",
12209
+ "Theatrical",
12210
+ "Ultimate",
12211
+ "Uncensored",
12212
+ "Uncut",
12213
+ "Unrated"
12214
+ ]
12215
+ },
12216
+ "episode": {
12217
+ "type": [
12218
+ "number"
12219
+ ],
12220
+ "array": true,
12221
+ "scalar": true
12222
+ },
12223
+ "episode_count": {
12224
+ "type": [
12225
+ "number"
12226
+ ],
12227
+ "array": false,
12228
+ "scalar": true
12229
+ },
12230
+ "episode_details": {
12231
+ "type": [
12232
+ "string"
12233
+ ],
12234
+ "array": true,
12235
+ "scalar": true
12236
+ },
12237
+ "episode_format": {
12238
+ "type": [
12239
+ "string"
12240
+ ],
12241
+ "array": false,
12242
+ "scalar": true,
12243
+ "enum": [
12244
+ "Minisode"
12245
+ ]
12246
+ },
12247
+ "episode_title": {
12248
+ "type": [
12249
+ "string"
12250
+ ],
12251
+ "array": true,
12252
+ "scalar": true
12253
+ },
12254
+ "film": {
12255
+ "type": [
12256
+ "number"
12257
+ ],
12258
+ "array": false,
12259
+ "scalar": true
12260
+ },
12261
+ "film_title": {
12262
+ "type": [
12263
+ "string"
12264
+ ],
12265
+ "array": false,
12266
+ "scalar": true
12267
+ },
12268
+ "frame_rate": {
12269
+ "type": [
12270
+ "string"
12271
+ ],
12272
+ "array": false,
12273
+ "scalar": true
12274
+ },
12275
+ "language": {
12276
+ "type": [
12277
+ "Language"
12278
+ ],
12279
+ "array": true,
12280
+ "scalar": true
12281
+ },
12282
+ "mimetype": {
12283
+ "type": [
12284
+ "string"
12285
+ ],
12286
+ "array": false,
12287
+ "scalar": true,
12288
+ "enum": [
12289
+ "application/x-bittorrent",
12290
+ "application/x-iso9660-image",
12291
+ "application/x-rar-compressed",
12292
+ "application/zip",
12293
+ "image/gif",
12294
+ "image/jpeg",
12295
+ "image/png",
12296
+ "text/plain",
12297
+ "video/mp2t",
12298
+ "video/mp4",
12299
+ "video/webm",
12300
+ "video/x-matroska",
12301
+ "video/x-msvideo"
12302
+ ]
12303
+ },
12304
+ "other": {
12305
+ "type": [
12306
+ "string"
12307
+ ],
12308
+ "array": true,
12309
+ "scalar": true,
12310
+ "enum": [
12311
+ "2in1",
12312
+ "3D",
12313
+ "asrequested",
12314
+ "Audio Fixed",
12315
+ "Banner",
12316
+ "Bonus",
12317
+ "BT.2020",
12318
+ "Classic",
12319
+ "Clear Art",
12320
+ "Clear Logo",
12321
+ "Colorized",
12322
+ "Complet",
12323
+ "Complete",
12324
+ "CONVERT",
12325
+ "Converted",
12326
+ "Cover",
12327
+ "Dirfix",
12328
+ "Disc Art",
12329
+ "DOCU",
12330
+ "Documentary",
12331
+ "DOKU",
12332
+ "Dolby Vision",
12333
+ "Dual",
12334
+ "Dual Audio",
12335
+ "East Coast Feed",
12336
+ "Ending Credits",
12337
+ "Extras",
12338
+ "Fan Subtitled",
12339
+ "Fanart",
12340
+ "Fansub",
12341
+ "Fast Subtitled",
12342
+ "Fastsub",
12343
+ "FHD",
12344
+ "Fix",
12345
+ "Fixed",
12346
+ "Full HD",
12347
+ "Half OU",
12348
+ "Half SBS",
12349
+ "Hardcoded Subtitles",
12350
+ "HC",
12351
+ "HD",
12352
+ "HDLight",
12353
+ "HDR10",
12354
+ "HFR",
12355
+ "High Frame Rate",
12356
+ "High Quality",
12357
+ "High Resolution",
12358
+ "HQ",
12359
+ "HR",
12360
+ "Hybrid",
12361
+ "Internal",
12362
+ "Landscape",
12363
+ "LD",
12364
+ "LDTV",
12365
+ "LiNE",
12366
+ "Line Audio",
12367
+ "Line Dubbed",
12368
+ "Logo",
12369
+ "Low Definition",
12370
+ "MD",
12371
+ "mHD",
12372
+ "Mic Dubbed",
12373
+ "Micro HD",
12374
+ "Mux",
12375
+ "Nfofix",
12376
+ "NTSC",
12377
+ "Oad",
12378
+ "OAR",
12379
+ "Oav",
12380
+ "Obfuscated",
12381
+ "Ona",
12382
+ "Open Matte",
12383
+ "Opening Credits",
12384
+ "Original Animated Video",
12385
+ "Original Animation DVD",
12386
+ "Original Aspect Ratio",
12387
+ "Original Net Animation",
12388
+ "Original Video",
12389
+ "OV",
12390
+ "Ova",
12391
+ "PAL",
12392
+ "postbot",
12393
+ "Poster",
12394
+ "Preair",
12395
+ "Proof",
12396
+ "Prooffix",
12397
+ "Proper",
12398
+ "PS Vita",
12399
+ "R5",
12400
+ "RC",
12401
+ "Read NFO",
12402
+ "Real",
12403
+ "Reencoded",
12404
+ "Region 5",
12405
+ "Region C",
12406
+ "Remux",
12407
+ "Repost",
12408
+ "Retail",
12409
+ "Rip",
12410
+ "Sample",
12411
+ "Scrambled",
12412
+ "Screener",
12413
+ "SDR",
12414
+ "SECAM",
12415
+ "Standard Dynamic Range",
12416
+ "Straight to Video",
12417
+ "STV",
12418
+ "Sync Fixed",
12419
+ "Thumbnail",
12420
+ "Trailer",
12421
+ "UHD",
12422
+ "Ultra HD",
12423
+ "Upscaled",
12424
+ "Variable Frame Rate",
12425
+ "VFR",
12426
+ "Virtual Reality",
12427
+ "Vita",
12428
+ "VO",
12429
+ "vost",
12430
+ "West Coast Feed",
12431
+ "Widescreen",
12432
+ "ws",
12433
+ "xpost",
12434
+ "XXX"
12435
+ ]
12436
+ },
12437
+ "part": {
12438
+ "type": [
12439
+ "number"
12440
+ ],
12441
+ "array": true,
12442
+ "scalar": true
12443
+ },
12444
+ "proper_count": {
12445
+ "type": [
12446
+ "number"
12447
+ ],
12448
+ "array": false,
12449
+ "scalar": true
12450
+ },
12451
+ "release_group": {
12452
+ "type": [
12453
+ "string"
12454
+ ],
12455
+ "array": false,
12456
+ "scalar": true
12457
+ },
12458
+ "screen_size": {
12459
+ "type": [
12460
+ "string"
12461
+ ],
12462
+ "array": false,
12463
+ "scalar": true,
12464
+ "enum": [
12465
+ "1080i",
12466
+ "1080p",
12467
+ "1440p",
12468
+ "1444x866",
12469
+ "2160p",
12470
+ "360p",
12471
+ "368p",
12472
+ "480p",
12473
+ "4k",
12474
+ "540p",
12475
+ "576p",
12476
+ "720p",
12477
+ "720x432",
12478
+ "960x544"
12479
+ ]
12480
+ },
12481
+ "season": {
12482
+ "type": [
12483
+ "number"
12484
+ ],
12485
+ "array": true,
12486
+ "scalar": true
12487
+ },
12488
+ "season_count": {
12489
+ "type": [
12490
+ "number"
12491
+ ],
12492
+ "array": false,
12493
+ "scalar": true
12494
+ },
12495
+ "size": {
12496
+ "type": [
12497
+ "string"
12498
+ ],
12499
+ "array": false,
12500
+ "scalar": true
12501
+ },
12502
+ "source": {
12503
+ "type": [
12504
+ "string"
12505
+ ],
12506
+ "array": false,
12507
+ "scalar": true,
12508
+ "enum": [
12509
+ "Analog HDTV",
12510
+ "Blu-ray",
12511
+ "Camera",
12512
+ "Digital Master",
12513
+ "Digital TV",
12514
+ "DVD",
12515
+ "HD Camera",
12516
+ "HD Telecine",
12517
+ "HD Telesync",
12518
+ "HD-DVD",
12519
+ "HDTV",
12520
+ "Pay-per-view",
12521
+ "Satellite",
12522
+ "Telecine",
12523
+ "Telesync",
12524
+ "TV",
12525
+ "Ultra HD Blu-ray",
12526
+ "Ultra HDTV",
12527
+ "VHS",
12528
+ "Video on Demand",
12529
+ "Web",
12530
+ "Workprint"
12531
+ ]
12532
+ },
12533
+ "streaming_service": {
12534
+ "type": [
12535
+ "string"
12536
+ ],
12537
+ "array": false,
12538
+ "scalar": true,
12539
+ "enum": [
12540
+ "4OD",
12541
+ "9Now",
12542
+ "9NOW",
12543
+ "A&E",
12544
+ "ABC",
12545
+ "ABC Australia",
12546
+ "Adult Swim",
12547
+ "AE",
12548
+ "AJAZ",
12549
+ "Al Jazeera English",
12550
+ "ALL4",
12551
+ "Amazon",
12552
+ "Amazon Prime",
12553
+ "AMBC",
12554
+ "AMC",
12555
+ "America's Test Kitchen",
12556
+ "AMZN",
12557
+ "AMZN-CBR",
12558
+ "Animal Planet",
12559
+ "AnimeLab",
12560
+ "ANLB",
12561
+ "ANPL",
12562
+ "AOL",
12563
+ "AppleTV",
12564
+ "APTV",
12565
+ "ARD",
12566
+ "AS",
12567
+ "ATK",
12568
+ "ATV+",
12569
+ "ATVP",
12570
+ "AUBC",
12571
+ "BBC iPlayer",
12572
+ "Binge",
12573
+ "BKPL",
12574
+ "Blackpills",
12575
+ "BLU",
12576
+ "BluTV",
12577
+ "BNGE",
12578
+ "BOOM",
12579
+ "Boomerang",
12580
+ "BRAV",
12581
+ "BravoTV",
12582
+ "Canal+",
12583
+ "Cartoon Network",
12584
+ "CBC",
12585
+ "CBS",
12586
+ "CC",
12587
+ "CCGC",
12588
+ "Channel 4",
12589
+ "CHGD",
12590
+ "CHRGD",
12591
+ "Cinemax",
12592
+ "CMAX",
12593
+ "CMT",
12594
+ "CN",
12595
+ "CNBC",
12596
+ "CNLP",
12597
+ "Comedians in Cars Getting Coffee",
12598
+ "Comedy Central",
12599
+ "Country Music Television",
12600
+ "CR",
12601
+ "Crackle",
12602
+ "CRAV",
12603
+ "Crave",
12604
+ "CRKL",
12605
+ "Crunchy Roll",
12606
+ "CSpan",
12607
+ "CSPN",
12608
+ "CTV",
12609
+ "CUR",
12610
+ "CuriosityStream",
12611
+ "CW",
12612
+ "CWS",
12613
+ "CWSeed",
12614
+ "Daisuki",
12615
+ "DC Universe",
12616
+ "DCU",
12617
+ "DDY",
12618
+ "Deadhouse Films",
12619
+ "DF",
12620
+ "DHF",
12621
+ "Digiturk Diledigin Yerde",
12622
+ "DISC",
12623
+ "Discovery",
12624
+ "Discovery Plus",
12625
+ "Disney",
12626
+ "Disney+",
12627
+ "DIY",
12628
+ "DIY Network",
12629
+ "Doc Club",
12630
+ "DOCC",
12631
+ "DPlay",
12632
+ "DPLY",
12633
+ "DramaFever",
12634
+ "DSCP",
12635
+ "DSKI",
12636
+ "DSNP",
12637
+ "DSNY",
12638
+ "E!",
12639
+ "El Trece",
12640
+ "ePix",
12641
+ "EPIX",
12642
+ "ESPN",
12643
+ "ESQ",
12644
+ "Esquire",
12645
+ "ETTV",
12646
+ "ETV",
12647
+ "Facebook Watch",
12648
+ "FAM",
12649
+ "Family",
12650
+ "Family Jr",
12651
+ "Fandor",
12652
+ "FANDOR",
12653
+ "FBWatch",
12654
+ "FJR",
12655
+ "FOOD",
12656
+ "Food Network",
12657
+ "Fox",
12658
+ "FOX",
12659
+ "Fox Premium",
12660
+ "FOXP",
12661
+ "Foxtel",
12662
+ "FP",
12663
+ "FREE",
12664
+ "Freeform",
12665
+ "FXTL",
12666
+ "FYI",
12667
+ "FYI Network",
12668
+ "Gaga",
12669
+ "GagaOOLala",
12670
+ "GC",
12671
+ "GLBL",
12672
+ "GLOB",
12673
+ "Global",
12674
+ "GloboSat Play",
12675
+ "Hallmark",
12676
+ "HBO",
12677
+ "HBO Go",
12678
+ "HBO Max",
12679
+ "HGTV",
12680
+ "HIST",
12681
+ "History",
12682
+ "HLMK",
12683
+ "HMAX",
12684
+ "hoichoi",
12685
+ "HoiChoi",
12686
+ "Hulu",
12687
+ "HULU",
12688
+ "ID",
12689
+ "IFC",
12690
+ "iflix",
12691
+ "IFX",
12692
+ "INA",
12693
+ "Investigation Discovery",
12694
+ "iP",
12695
+ "iQIYI",
12696
+ "iT",
12697
+ "iTunes",
12698
+ "ITV",
12699
+ "KNOW",
12700
+ "Knowledge Network",
12701
+ "LIFE",
12702
+ "Lifetime",
12703
+ "MBC",
12704
+ "MBCVOD",
12705
+ "MNBC",
12706
+ "Motor Trend OnDemand",
12707
+ "MSNBC",
12708
+ "MTOD",
12709
+ "MTV",
12710
+ "MUBI",
12711
+ "NATG",
12712
+ "National Audiovisual Institute",
12713
+ "National Film Board",
12714
+ "National Geographic",
12715
+ "NBA",
12716
+ "NBA TV",
12717
+ "NBC",
12718
+ "Netflix",
12719
+ "NF",
12720
+ "NFB",
12721
+ "NFL",
12722
+ "NFL Now",
12723
+ "NFLN",
12724
+ "NHL GameCenter",
12725
+ "NICK",
12726
+ "NICKAPP",
12727
+ "Nickelodeon",
12728
+ "Norsk Rikskringkasting",
12729
+ "NRK",
12730
+ "ODK",
12731
+ "OnDemandKorea",
12732
+ "Oprah Winfrey Network",
12733
+ "Opto",
12734
+ "OPTO",
12735
+ "OWN",
12736
+ "Paramount+",
12737
+ "ParamountPlus",
12738
+ "PBS",
12739
+ "PBS Kids",
12740
+ "PBSK",
12741
+ "PCOK",
12742
+ "Peacock",
12743
+ "Playstation Network",
12744
+ "PLUZ",
12745
+ "Pluzz",
12746
+ "PMNP",
12747
+ "PMT+",
12748
+ "PMTP",
12749
+ "POGO",
12750
+ "PokerGO",
12751
+ "PSN",
12752
+ "Rakuten TV",
12753
+ "RED",
12754
+ "RKTN",
12755
+ "ROKU",
12756
+ "RTE",
12757
+ "RTE One",
12758
+ "RUUTU",
12759
+ "SBS",
12760
+ "SCI",
12761
+ "Science Channel",
12762
+ "SeeSo",
12763
+ "SESO",
12764
+ "SHMI",
12765
+ "SHO",
12766
+ "Shomi",
12767
+ "Showtime",
12768
+ "SNET",
12769
+ "Sony",
12770
+ "SONY",
12771
+ "SPIK",
12772
+ "Spike",
12773
+ "Spike TV",
12774
+ "SPKE",
12775
+ "Sportsnet",
12776
+ "Sprout",
12777
+ "SPRT",
12778
+ "Stan",
12779
+ "STAN",
12780
+ "Starz",
12781
+ "STZ",
12782
+ "Sveriges Television",
12783
+ "SVT",
12784
+ "SwearNet",
12785
+ "SWER",
12786
+ "Syfy",
12787
+ "SYFY",
12788
+ "TBS",
12789
+ "TFou",
12790
+ "TFOU",
12791
+ "The CW",
12792
+ "The Roku Channel",
12793
+ "TLC",
12794
+ "TUBI",
12795
+ "TubiTV",
12796
+ "TV Land",
12797
+ "TV3",
12798
+ "TV3 Ireland",
12799
+ "TV4",
12800
+ "TV4 Sweeden",
12801
+ "TVING",
12802
+ "TVL",
12803
+ "TVNZ",
12804
+ "UFC",
12805
+ "UFC Fight Pass",
12806
+ "UKTV",
12807
+ "UNIV",
12808
+ "Univision",
12809
+ "USA Network",
12810
+ "USAN",
12811
+ "Velocity",
12812
+ "VH1",
12813
+ "VICE",
12814
+ "Viceland",
12815
+ "Viki",
12816
+ "VIKI",
12817
+ "Vimeo",
12818
+ "VLCT",
12819
+ "VMEO",
12820
+ "VRV",
12821
+ "W Network",
12822
+ "WatchMe",
12823
+ "WME",
12824
+ "WNET",
12825
+ "WWE Network",
12826
+ "WWEN",
12827
+ "XBOX",
12828
+ "Xbox Video",
12829
+ "Yahoo",
12830
+ "YHOO",
12831
+ "YouTube Red",
12832
+ "ZDF"
12833
+ ]
12834
+ },
12835
+ "subtitle_language": {
12836
+ "type": [
12837
+ "Language"
12838
+ ],
12839
+ "array": true,
12840
+ "scalar": true
12841
+ },
12842
+ "title": {
12843
+ "type": [
12844
+ "string"
12845
+ ],
12846
+ "array": false,
12847
+ "scalar": true
12848
+ },
12849
+ "type": {
12850
+ "type": [
12851
+ "string"
12852
+ ],
12853
+ "array": false,
12854
+ "scalar": true,
12855
+ "enum": [
12856
+ "episode",
12857
+ "movie"
12858
+ ]
12859
+ },
12860
+ "uuid": {
12861
+ "type": [
12862
+ "string"
12863
+ ],
12864
+ "array": false,
12865
+ "scalar": true
12866
+ },
12867
+ "version": {
12868
+ "type": [
12869
+ "number"
12870
+ ],
12871
+ "array": false,
12872
+ "scalar": true
12873
+ },
12874
+ "video_api": {
12875
+ "type": [
12876
+ "string"
12877
+ ],
12878
+ "array": false,
12879
+ "scalar": true,
12880
+ "enum": [
12881
+ "DXVA"
12882
+ ]
12883
+ },
12884
+ "video_bit_rate": {
12885
+ "type": [
12886
+ "string"
12887
+ ],
12888
+ "array": false,
12889
+ "scalar": true
12890
+ },
12891
+ "video_codec": {
12892
+ "type": [
12893
+ "string"
12894
+ ],
12895
+ "array": false,
12896
+ "scalar": true,
12897
+ "enum": [
12898
+ "DivX",
12899
+ "DVDivX",
12900
+ "H.263",
12901
+ "H.264",
12902
+ "H.265",
12903
+ "MPEG-2",
12904
+ "RealVideo",
12905
+ "VC-1",
12906
+ "VP7",
12907
+ "VP8",
12908
+ "VP80",
12909
+ "VP9",
12910
+ "Xvid",
12911
+ "XviD"
12912
+ ]
12913
+ },
12914
+ "video_profile": {
12915
+ "type": [
12916
+ "string"
12917
+ ],
12918
+ "array": true,
12919
+ "scalar": true,
12920
+ "enum": [
12921
+ "Advanced Video Codec High Definition",
12922
+ "Baseline",
12923
+ "BP",
12924
+ "EP",
12925
+ "Extended",
12926
+ "HEVC",
12927
+ "High",
12928
+ "High 10",
12929
+ "High 4:2:2",
12930
+ "High 4:4:4 Predictive",
12931
+ "High Efficiency Video Coding",
12932
+ "HiP",
12933
+ "HP",
12934
+ "Main",
12935
+ "MP",
12936
+ "SC",
12937
+ "Scalable Video Coding",
12938
+ "SVC",
12939
+ "XP"
12940
+ ]
12941
+ },
12942
+ "website": {
12943
+ "type": [
12944
+ "string"
12945
+ ],
12946
+ "array": false,
12947
+ "scalar": true
12948
+ },
12949
+ "year": {
12950
+ "type": [
12951
+ "number"
12952
+ ],
12953
+ "array": false,
12954
+ "scalar": true
12955
+ }
12956
+ };
10028
12957
  class GuessItException extends Error {
10029
12958
  constructor(string, options, cause) {
10030
12959
  const causeMsg = cause instanceof Error ? cause.message : String(cause);
@@ -10091,6 +13020,18 @@ class GuessItApi {
10091
13020
  !!mergedOptions["enforceList"] || !!mergedOptions["enforce_list"]
10092
13021
  );
10093
13022
  const result = Object.fromEntries(matchesDict);
13023
+ for (const key of ["language", "subtitle_language"]) {
13024
+ const v = result[key];
13025
+ if (!Array.isArray(v)) continue;
13026
+ const seen = /* @__PURE__ */ new Set();
13027
+ const deduped = v.filter((lang) => {
13028
+ const id = lang && typeof lang === "object" && "alpha3" in lang ? `${lang.alpha3}:${lang.country ?? ""}` : String(lang);
13029
+ if (seen.has(id)) return false;
13030
+ seen.add(id);
13031
+ return true;
13032
+ });
13033
+ result[key] = deduped.length === 1 ? deduped[0] : deduped;
13034
+ }
10094
13035
  if (mergedOptions["outputInputString"] || mergedOptions["output_input_string"]) {
10095
13036
  result["input_string"] = matches.inputString;
10096
13037
  }
@@ -10118,13 +13059,22 @@ class GuessItApi {
10118
13059
  }
10119
13060
  }
10120
13061
  }
10121
- const ordered = {};
13062
+ let ordered = {};
10122
13063
  for (const k of Object.keys(props).sort()) {
10123
13064
  ordered[k] = [...props[k]].sort((a, b) => String(a).localeCompare(String(b)));
10124
13065
  }
10125
13066
  const rb = this._rebulk;
10126
13067
  if (rb.customizeProperties) {
10127
- return rb.customizeProperties(ordered);
13068
+ ordered = rb.customizeProperties(ordered);
13069
+ }
13070
+ for (const [name, def] of Object.entries(GUESSIT_SCHEMA)) {
13071
+ const cur = Array.isArray(ordered[name]) ? ordered[name] : [];
13072
+ if (def.enum) {
13073
+ const merged = /* @__PURE__ */ new Set([...cur, ...def.enum]);
13074
+ ordered[name] = [...merged].sort((a, b) => String(a).localeCompare(String(b)));
13075
+ } else if (cur.length === 0) {
13076
+ ordered[name] = [null];
13077
+ }
10128
13078
  }
10129
13079
  return ordered;
10130
13080
  }
@@ -10152,6 +13102,7 @@ function configure(options, rulesBuilder, force = false) {
10152
13102
  function reset() {
10153
13103
  defaultApi.reset();
10154
13104
  }
13105
+ exports.GUESSIT_SCHEMA = GUESSIT_SCHEMA;
10155
13106
  exports.GuessItApi = GuessItApi;
10156
13107
  exports.GuessItException = GuessItException;
10157
13108
  exports.configure = configure;