pgsrip 0.2.1__tar.gz → 0.3.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/rules/corrupted-data.md +2 -2
  2. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/rules/ocr-batching.md +7 -2
  3. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/rules/rip-e2e-tests.md +2 -1
  4. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/settings.json +31 -1
  5. {pgsrip-0.2.1 → pgsrip-0.3.0}/.github/workflows/publish.yml +1 -1
  6. {pgsrip-0.2.1 → pgsrip-0.3.0}/.github/workflows/test.yml +11 -2
  7. pgsrip-0.3.0/CHANGELOG.md +414 -0
  8. {pgsrip-0.2.1 → pgsrip-0.3.0}/CONTRIBUTING.md +7 -1
  9. {pgsrip-0.2.1 → pgsrip-0.3.0}/Dockerfile +8 -3
  10. pgsrip-0.3.0/PKG-INFO +333 -0
  11. pgsrip-0.3.0/README.md +294 -0
  12. pgsrip-0.3.0/docs/architecture.md +87 -0
  13. pgsrip-0.3.0/docs/bug-reports.md +105 -0
  14. pgsrip-0.3.0/docs/corrupted_data.md +15 -0
  15. pgsrip-0.3.0/docs/images/before-after.png +0 -0
  16. pgsrip-0.3.0/docs/ocr_batching.md +98 -0
  17. {pgsrip-0.2.1 → pgsrip-0.3.0}/docs/rip-e2e.md +26 -23
  18. pgsrip-0.3.0/docs/usage.md +451 -0
  19. {pgsrip-0.2.1 → pgsrip-0.3.0}/docs/workflow.md +1 -1
  20. pgsrip-0.3.0/pgsrip/__init__.py +20 -0
  21. pgsrip-0.3.0/pgsrip/api.py +217 -0
  22. pgsrip-0.3.0/pgsrip/cli/__init__.py +731 -0
  23. pgsrip-0.3.0/pgsrip/cli/plugins.py +255 -0
  24. pgsrip-0.3.0/pgsrip/cue.py +40 -0
  25. pgsrip-0.3.0/pgsrip/diagnostics.py +103 -0
  26. pgsrip-0.3.0/pgsrip/engines/__init__.py +13 -0
  27. pgsrip-0.3.0/pgsrip/engines/auto.py +104 -0
  28. pgsrip-0.3.0/pgsrip/engines/base.py +79 -0
  29. pgsrip-0.3.0/pgsrip/engines/chain.py +78 -0
  30. pgsrip-0.3.0/pgsrip/engines/openai.py +309 -0
  31. pgsrip-0.3.0/pgsrip/engines/rapidocr.py +364 -0
  32. {pgsrip-0.2.1/pgsrip → pgsrip-0.3.0/pgsrip/engines}/tessdata.py +66 -75
  33. pgsrip-0.3.0/pgsrip/engines/tesseract.py +497 -0
  34. pgsrip-0.3.0/pgsrip/engines/tsv.py +73 -0
  35. pgsrip-0.3.0/pgsrip/errors.py +2 -0
  36. pgsrip-0.3.0/pgsrip/formats/__init__.py +0 -0
  37. pgsrip-0.3.0/pgsrip/formats/pgs.py +624 -0
  38. {pgsrip-0.2.1/pgsrip → pgsrip-0.3.0/pgsrip/formats}/scrub.py +25 -73
  39. pgsrip-0.3.0/pgsrip/media.py +277 -0
  40. {pgsrip-0.2.1 → pgsrip-0.3.0}/pgsrip/media_path.py +20 -30
  41. pgsrip-0.3.0/pgsrip/options.py +45 -0
  42. pgsrip-0.3.0/pgsrip/plugin.py +29 -0
  43. pgsrip-0.3.0/pgsrip/postprocessors/__init__.py +7 -0
  44. pgsrip-0.3.0/pgsrip/postprocessors/base.py +38 -0
  45. pgsrip-0.3.0/pgsrip/postprocessors/cleanit.py +69 -0
  46. pgsrip-0.3.0/pgsrip/sources/__init__.py +13 -0
  47. pgsrip-0.3.0/pgsrip/sources/base.py +87 -0
  48. pgsrip-0.3.0/pgsrip/sources/mkvtoolnix.py +59 -0
  49. pgsrip-0.3.0/pgsrip/sources/raw.py +23 -0
  50. {pgsrip-0.2.1 → pgsrip-0.3.0}/pgsrip/track_flags.py +20 -41
  51. pgsrip-0.3.0/pgsrip/utils.py +83 -0
  52. pgsrip-0.3.0/pgsrip/writers/__init__.py +5 -0
  53. pgsrip-0.3.0/pgsrip/writers/base.py +19 -0
  54. pgsrip-0.3.0/pgsrip/writers/srt.py +31 -0
  55. {pgsrip-0.2.1 → pgsrip-0.3.0}/pyproject.toml +20 -5
  56. pgsrip-0.3.0/tests/conftest.py +46 -0
  57. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/fabricate.py +51 -46
  58. pgsrip-0.3.0/tests/test_api.py +526 -0
  59. pgsrip-0.3.0/tests/test_cli.py +90 -0
  60. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/test_diagnostics.py +10 -9
  61. pgsrip-0.3.0/tests/test_engines.py +820 -0
  62. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/test_media.py +18 -21
  63. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/test_media_path.py +41 -29
  64. pgsrip-0.3.0/tests/test_openai.py +451 -0
  65. pgsrip-0.3.0/tests/test_pgs.py +169 -0
  66. pgsrip-0.3.0/tests/test_postprocess.py +312 -0
  67. pgsrip-0.3.0/tests/test_rapidocr.py +180 -0
  68. pgsrip-0.3.0/tests/test_rip_e2e.py +576 -0
  69. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/test_rip_e2e.yml +26 -1
  70. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/test_samples.py +31 -30
  71. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/test_scrub.py +65 -58
  72. pgsrip-0.3.0/tests/test_tessdata.py +295 -0
  73. pgsrip-0.2.1/tests/test_mkvtrack.py → pgsrip-0.3.0/tests/test_track.py +10 -6
  74. pgsrip-0.2.1/tests/test_mkvtrack.yml → pgsrip-0.3.0/tests/test_track.yml +0 -34
  75. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/test_track_flags.py +18 -18
  76. pgsrip-0.3.0/tests/test_utils.py +53 -0
  77. pgsrip-0.3.0/tests/test_writers.py +83 -0
  78. {pgsrip-0.2.1 → pgsrip-0.3.0}/uv.lock +405 -2
  79. pgsrip-0.2.1/CHANGELOG.md +0 -141
  80. pgsrip-0.2.1/PKG-INFO +0 -317
  81. pgsrip-0.2.1/README.md +0 -284
  82. pgsrip-0.2.1/docs/architecture.md +0 -20
  83. pgsrip-0.2.1/docs/corrupted_data.md +0 -7
  84. pgsrip-0.2.1/docs/ocr_batching.md +0 -26
  85. pgsrip-0.2.1/pgsrip/__init__.py +0 -19
  86. pgsrip-0.2.1/pgsrip/api.py +0 -24
  87. pgsrip-0.2.1/pgsrip/cli.py +0 -610
  88. pgsrip-0.2.1/pgsrip/core.py +0 -127
  89. pgsrip-0.2.1/pgsrip/diagnostics.py +0 -149
  90. pgsrip-0.2.1/pgsrip/media.py +0 -276
  91. pgsrip-0.2.1/pgsrip/mkv.py +0 -160
  92. pgsrip-0.2.1/pgsrip/options.py +0 -103
  93. pgsrip-0.2.1/pgsrip/pgs.py +0 -453
  94. pgsrip-0.2.1/pgsrip/ripper.py +0 -301
  95. pgsrip-0.2.1/pgsrip/sup.py +0 -20
  96. pgsrip-0.2.1/pgsrip/tsv.py +0 -72
  97. pgsrip-0.2.1/pgsrip/utils.py +0 -39
  98. pgsrip-0.2.1/tests/conftest.py +0 -23
  99. pgsrip-0.2.1/tests/test_cli.py +0 -12
  100. pgsrip-0.2.1/tests/test_core.py +0 -264
  101. pgsrip-0.2.1/tests/test_pgs.py +0 -75
  102. pgsrip-0.2.1/tests/test_rip_e2e.py +0 -330
  103. pgsrip-0.2.1/tests/test_tessdata.py +0 -240
  104. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/hooks/session_start.py +0 -0
  105. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/rules/architecture.md +0 -0
  106. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/rules/knowledge.md +0 -0
  107. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/rules/tests.md +0 -0
  108. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/rules/tooling.md +0 -0
  109. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/investigate/SKILL.md +0 -0
  110. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/investigate/templates/README.md +0 -0
  111. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/investigate/templates/findings.md +0 -0
  112. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/knowledge-audit/SKILL.md +0 -0
  113. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/plan/SKILL.md +0 -0
  114. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/plan/templates/plan.md +0 -0
  115. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/release/SKILL.md +0 -0
  116. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/resume/SKILL.md +0 -0
  117. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/ship/SKILL.md +0 -0
  118. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/spec/SKILL.md +0 -0
  119. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/spec/templates/spec.md +0 -0
  120. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/triage-issue/SKILL.md +0 -0
  121. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/writing-style/SKILL.md +0 -0
  122. {pgsrip-0.2.1 → pgsrip-0.3.0}/.claude/skills/writing-style/reference.md +0 -0
  123. {pgsrip-0.2.1 → pgsrip-0.3.0}/.dockerignore +0 -0
  124. {pgsrip-0.2.1 → pgsrip-0.3.0}/.github/ISSUE_TEMPLATE/bug_report.yml +0 -0
  125. {pgsrip-0.2.1 → pgsrip-0.3.0}/.github/ISSUE_TEMPLATE/config.yml +0 -0
  126. {pgsrip-0.2.1 → pgsrip-0.3.0}/.github/ISSUE_TEMPLATE/feature_request.yml +0 -0
  127. {pgsrip-0.2.1 → pgsrip-0.3.0}/.github/ISSUE_TEMPLATE/question.yml +0 -0
  128. {pgsrip-0.2.1 → pgsrip-0.3.0}/.github/dependabot.yml +0 -0
  129. {pgsrip-0.2.1 → pgsrip-0.3.0}/.github/pull_request_template.md +0 -0
  130. {pgsrip-0.2.1 → pgsrip-0.3.0}/.github/workflows/docker-publish.yml +0 -0
  131. {pgsrip-0.2.1 → pgsrip-0.3.0}/.gitignore +0 -0
  132. {pgsrip-0.2.1 → pgsrip-0.3.0}/.pre-commit-config.yaml +0 -0
  133. {pgsrip-0.2.1 → pgsrip-0.3.0}/CLAUDE.md +0 -0
  134. {pgsrip-0.2.1 → pgsrip-0.3.0}/LICENSE +0 -0
  135. {pgsrip-0.2.1 → pgsrip-0.3.0}/pgsrip/__main__.py +0 -0
  136. {pgsrip-0.2.1 → pgsrip-0.3.0}/scripts/check_knowledge.py +0 -0
  137. {pgsrip-0.2.1 → pgsrip-0.3.0}/scripts/test.sh +0 -0
  138. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/__init__.py +0 -0
  139. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/samples/README.md +0 -0
  140. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/samples/placeholder.en.sup +0 -0
  141. {pgsrip-0.2.1 → pgsrip-0.3.0}/tests/test_check_knowledge.py +0 -0
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  paths:
3
- - "pgsrip/pgs.py"
3
+ - "pgsrip/formats/pgs.py"
4
4
  - "pgsrip/media.py"
5
5
  ---
6
6
 
@@ -9,4 +9,4 @@ paths:
9
9
  Malformed PGS input is normal. Log and drop a bad item. Do not stop the whole rip. Do not change a
10
10
  graceful fallback into an error unless the user agrees.
11
11
 
12
- Read `docs/corrupted_data.md` before you change parsing, `auto_fix`, or the `None` handling.
12
+ Read `docs/corrupted_data.md` before you change parsing, `make_item`, or the `None` handling.
@@ -1,7 +1,9 @@
1
1
  ---
2
2
  paths:
3
- - "pgsrip/ripper.py"
4
- - "pgsrip/tsv.py"
3
+ - "pgsrip/engines/chain.py"
4
+ - "pgsrip/engines/openai.py"
5
+ - "pgsrip/engines/tesseract.py"
6
+ - "pgsrip/engines/tsv.py"
5
7
  ---
6
8
 
7
9
  # OCR batching
@@ -10,4 +12,7 @@ Keep the number of tesseract calls low. This is more important than simple code.
10
12
  into a few large composite images, about one for each worker. Each image is one `image_to_data` call, and
11
13
  the calls run in parallel.
12
14
 
15
+ The OpenAI-compatible engine is different. It sends one request for each text line of each item, on purpose.
16
+ One image never holds more than one item.
17
+
13
18
  Read `docs/ocr_batching.md` before you change the batching, the composite size, or the retry passes.
@@ -8,6 +8,7 @@ paths:
8
8
  # End-to-end rip tests
9
9
 
10
10
  The tests make media from parameters, rip it through the CLI, and check the `.srt` files. Tesseract is
11
- always a fake. MKVToolNix is a fake by default, and real with `--media-backend real`.
11
+ always a fake. MKVToolNix is a fake by default, and real with `--media-backend real`. A test of a writer
12
+ that the CLI does not have calls `api.rip` directly.
12
13
 
13
14
  Read `docs/rip-e2e.md` for the fabrication API and the backend model.
@@ -24,7 +24,37 @@
24
24
  "PowerShell(gh issue view *)",
25
25
  "PowerShell(gh issue list *)",
26
26
  "PowerShell(gh pr view *)",
27
- "PowerShell(gh label list *)"
27
+ "PowerShell(gh label list *)",
28
+ "Bash(podman logs *)",
29
+ "Bash(podman info *)",
30
+ "Bash(podman --version)",
31
+ "Bash(ffprobe *)",
32
+ "Bash(mediainfo --Output=JSON *)",
33
+ "Bash(tesseract --version)",
34
+ "Bash(mediainfo --version)",
35
+ "Bash(mkvmerge -i *)",
36
+ "PowerShell(podman logs *)",
37
+ "PowerShell(podman info *)",
38
+ "PowerShell(podman --version)",
39
+ "PowerShell(ffprobe *)",
40
+ "PowerShell(mediainfo --Output=JSON *)",
41
+ "PowerShell(tesseract --version)",
42
+ "PowerShell(mediainfo --version)",
43
+ "PowerShell(mkvmerge -i *)",
44
+ "PowerShell(Select-String *)",
45
+ "Bash(uv run pgsrip doctor)",
46
+ "Bash(uv run pgsrip rip --help)",
47
+ "Bash(uv run pgsrip scrub --help)",
48
+ "Bash(podman ps *)",
49
+ "Bash(uv pip list *)",
50
+ "PowerShell(uv run pgsrip doctor)",
51
+ "PowerShell(uv run pgsrip rip --help)",
52
+ "PowerShell(uv run pgsrip scrub --help)",
53
+ "PowerShell(podman ps *)",
54
+ "PowerShell(uv pip list *)",
55
+ "Bash(wsl -l *)",
56
+ "PowerShell(wsl -l *)",
57
+ "PowerShell(Select-Object *)"
28
58
  ]
29
59
  },
30
60
  "skillOverrides": {
@@ -15,7 +15,7 @@ jobs:
15
15
  - uses: actions/checkout@v7
16
16
 
17
17
  - name: Install uv
18
- uses: astral-sh/setup-uv@v10.1.0
18
+ uses: astral-sh/setup-uv@v10.2.0
19
19
  with:
20
20
  enable-cache: true
21
21
  python-version: "3.13"
@@ -12,12 +12,21 @@ jobs:
12
12
  strategy:
13
13
  matrix:
14
14
  python-version: ["3.11", "3.12", "3.13", "3.14"]
15
+ env:
16
+ # the RapidOCR model of the real-model tests
17
+ PGSRIP_RAPIDOCR_DIR: ${{ github.workspace }}/.rapidocr
15
18
  steps:
16
19
  - name: Check out the repo
17
20
  uses: actions/checkout@v7
18
21
 
22
+ - name: Cache the RapidOCR model
23
+ uses: actions/cache@v6
24
+ with:
25
+ path: .rapidocr
26
+ key: rapidocr-${{ hashFiles('uv.lock') }}
27
+
19
28
  - name: Install uv
20
- uses: astral-sh/setup-uv@v10.1.0
29
+ uses: astral-sh/setup-uv@v10.2.0
21
30
  with:
22
31
  enable-cache: true
23
32
  python-version: ${{ matrix.python-version }}
@@ -44,7 +53,7 @@ jobs:
44
53
  uses: actions/checkout@v7
45
54
 
46
55
  - name: Install uv
47
- uses: astral-sh/setup-uv@v10.1.0
56
+ uses: astral-sh/setup-uv@v10.2.0
48
57
  with:
49
58
  enable-cache: true
50
59
  python-version: "3.13"
@@ -0,0 +1,414 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0
4
+
5
+ **release date:** 2026-09-29
6
+
7
+ - New: `--engine openai` reads the subtitle images with a vision model
8
+ behind an OpenAI-compatible API, for example llama.cpp with GLM-OCR. The
9
+ `--openai-*` options, or the `openai` section of the configuration file,
10
+ set it up. This engine is experimental. Based on #148 by @socram8888
11
+ - Breaking: `-w/--max-workers` is now `-w/--workers`, and the
12
+ `max_workers` configuration key is now `workers`
13
+ - Breaking: `-v` lists all the ignored paths, and `-vv` also lists the
14
+ filtered-out paths. Before, it was `-vv` and `-vvv`
15
+ - Breaking: `scrub` names its copies with a free name `.track2`, `.track3`.
16
+ Before, it was `.track0`, `.track1`
17
+ - Breaking: pgsrip rips an MKV track with no language as `und`, like a
18
+ `.sup` file with no language. Before, it skipped the track
19
+ - New: `--tesseract-confidence` (0 to 100, default 65) sets the word
20
+ confidence of the first tesseract pass. `--tesseract-width` (10240 to
21
+ 31744, default 31744) sets the maximum width of the images that go to
22
+ tesseract
23
+ - New: `rip --help` shows the default of each engine and post-processor
24
+ option, and the environment variables `PGSRIP_TESSDATA_DIR`,
25
+ `PGSRIP_TESSDATA_REPO`, and `PGSRIP_RAPIDOCR_DIR`
26
+ - Changed: `--keep-temp-files` writes `null` in `cues.json` for a missing
27
+ time. Before, it wrote the text `None`
28
+ - Changed: `doctor` also shows the versions of appdirs and pyyaml
29
+ - Fixed: a second run does not rip the duplicate of a track that it ripped
30
+ before, for example `movie.en.track2.srt` next to `movie.en.srt`
31
+ - Fixed: 2 tracks of the same language that differ only in the default or
32
+ original flag do not write the same file. Without `--all`, pgsrip rips
33
+ only the first. With `--all`, the second is `.track2`. Before, with
34
+ `--force`, the second track replaced the file of the first
35
+ - Fixed: a corrupted display set is logged and dropped. Before, the whole
36
+ track failed. This applies to an unknown segment type, a display set with
37
+ no composition segment or with no palette, a value that does not exist,
38
+ and a composition or window segment that is too short
39
+ - Fixed: the palette of a subtitle image is the palette that its
40
+ composition segment names. Before, pgsrip joined all the palettes of the
41
+ display set
42
+ - Fixed: tesseract: a cue where tesseract finds no word goes to the next
43
+ pass and to the next engine, and the "not ripped" warning lists it.
44
+ Before, the cue was dropped with no message
45
+ - Fixed: tesseract: a subtitle image wider than the composite width does
46
+ not stop the rip of the track
47
+ - Fixed: `rip` and `scrub` exit with code 1 when the `--log-file` cannot be
48
+ opened
49
+ - Fixed: `scrub` exits with code 1 when a scrub fails, and when it finds no
50
+ media. Before, it exited with 0
51
+ - Fixed: `scrub` does not write a scrubbed file that pgsrip cannot read
52
+ back. It shows the error
53
+ - Fixed: `--age ''` is an error. Before, it was accepted and filtered
54
+ nothing
55
+ - Fixed: `--language` does not keep a media whose only track of the
56
+ language is disabled
57
+ - Fixed: `--debug` and `--log-file` log each line one time when a script
58
+ runs 2 commands in one process. The log file closes when the command ends
59
+ - Fixed: the help of `-a`, `-A`, `-f`, `--all`, and `--keep-temp-files` tells
60
+ what the option does
61
+ - Breaking: library: `pgsrip.core` merges into `pgsrip.api`. `pgsrip`
62
+ exports `scan`, `ScanResult`, `Skipped`, `pending`, `prepare`, `rip`,
63
+ `Options`, `Media`, `Subtitle`, `Workspace`, and `PgsripError`.
64
+ `from pgsrip import pgsrip` goes away
65
+ - Breaking: library: `scan_path` is now `scan`, and returns a
66
+ `ScanResult(media, filtered_out, ignored)`. Each skipped path is a
67
+ `Skipped(path, reason)`: `ScannedPath` and `get_reason` go away
68
+ - Breaking: library: `rip_pgs` is now `rip(subtitle, options)`. It raises
69
+ the error that stops the rip, in place of the `on_error` callback.
70
+ `rip(media)` goes away. Call `prepare(subtitles, options, reporter)`
71
+ before `rip`: it gets the OCR engines ready for the languages of the
72
+ subtitles. Without it, `rip` does not use RapidOCR
73
+ - Breaking: library: `Pgs` is now `Subtitle(track, source_path, output_base,
74
+ extraction, workspace)`. `Subtitle.read()` gives the PGS data. It does not
75
+ decode the data and has no `items`. `Pgs.pending_writers` is now
76
+ `pgsrip.api.pending_writers`
77
+ - Breaking: library: `Media.get_pgs_medias` is now
78
+ `Media.subtitles(options, workspace)`. The selection does not look at the
79
+ output files: `pgsrip.api.pending` does. `Media` and `Extraction` move
80
+ from `pgsrip.sources.base` to `pgsrip.media`. `Media.media_path` is now
81
+ `Media.path`
82
+ - Breaking: library: `Options` is a frozen dataclass of plain values. Its
83
+ fields have the names of the CLI options: `force` (was `overwrite`),
84
+ `all_tracks` (was `one_per_lang`, inverted), `with_flags` and
85
+ `without_flags` (were `include_flags` and `exclude_flags`). `languages` is
86
+ a `frozenset`. None in `engines`, `post_processors`, or `writers` means the
87
+ default. `Options` is not a context manager: `Workspace` (from
88
+ `pgsrip.media`) holds the temporary directory of the run, and
89
+ `Workspace(keep=True)` replaces `keep_temp_files`
90
+ - Breaking: library: `Track` has one `flags` field (a `TrackFlags`) in place
91
+ of one field for each flag, and no `external` field.
92
+ `TrackFlags.version` is now the boolean `TrackFlags.alternate`.
93
+ `TrackFlags.matches(with_flags, without_flags)`: the arguments were
94
+ `include` and `exclude`
95
+ - Breaking: library: `MediaPath.translate` is now `MediaPath.replace`, and
96
+ it also takes `base_path`. `MediaPath.m_age` is now `MediaPath.age`, and
97
+ `MediaPath.track_id` is now `MediaPath.track_number`
98
+ - Breaking: library: all the errors of pgsrip are a `PgsripError` (from
99
+ `pgsrip.errors`): `SourceError`, `CorruptDataError` (from
100
+ `pgsrip.formats.pgs`, for a track with no subtitle image, before a
101
+ `ValueError`), `OcrError`, `TessdataError`, and `ScrubError`. `Media`
102
+ raises `SourceError` (from `pgsrip.sources.base`) when it cannot read the
103
+ file: for an unsupported extension, when the tool is not installed, and
104
+ when the tool fails. `Source.missing` is now `Source.install_hint`
105
+ - Breaking: library: `pgsrip.formats.pgs` has new names. `PgsReader.decode`
106
+ and `PgsReader.read_segments` are now the functions `read_display_sets`
107
+ and `read_segments`. `BaseSegment` is now `Segment`, `Palette` is now
108
+ `PaletteEntry`, and `PgsSubtitleItem` (from `pgsrip.media`) is now `Item`.
109
+ `PgsSubtitleItem.create_items` is now `read_items`, and `Item.box` replaces
110
+ `shape`. `PgsImage` is a `NamedTuple`, with module functions in place of
111
+ its class methods. `pgsrip.utils.from_hex` is now
112
+ `pgsrip.formats.pgs.to_int`
113
+ - Breaking: library: `read_segments`, `read_display_sets`, `read_items`,
114
+ `scrub_data`, and `verify` take a `name` (a `str`) for their log
115
+ messages, not a `MediaPath`. `output_path` and `default_name` move from
116
+ `pgsrip.formats.scrub` to `pgsrip.cli`
117
+ - Breaking: library: names with no `get_` prefix: `tesseract_code`,
118
+ `required_codes`, and `config_arg` (in `pgsrip.engines.tessdata`).
119
+ `required_codes(languages)` has no `psm_value`, and `OSD_CODE` and
120
+ `OSD_PAGE_SEGMENTATION_MODES` go away. `is_writable` moves from
121
+ `pgsrip.engines.tessdata` to `pgsrip.utils`. `get_user_cache_dir` goes
122
+ away: `pgsrip.utils.cache_dir(name)` gives a directory in the user cache
123
+ directory of pgsrip, with appdirs
124
+ - Breaking: library: `TesseractEngine` has no `oem` and `psm` arguments, and
125
+ `TesseractEngineMode` and `TesseractPageSegmentationMode` go away: pgsrip
126
+ always uses `--oem 1 --psm 6`. `FullImage` is now `Composite`, and
127
+ `ImageArea` is now `Row`. `FullImage.data` is now `Composite.image`,
128
+ `FullImage.items` is now `Composite.placed`, and `ImageArea.shape` is now
129
+ `Row.box`. `TsvData` is now `TsvResult`, and `TsvDataItem` is now
130
+ `TsvWord`. `TsvWord.matches` and `TsvResult.select` take a `Box`
131
+ - Breaking: library: `TesseractEngine`, `Tessdata`, and `RapidOcrEngine` do
132
+ not read the environment variables. Only the command line reads them.
133
+ `Tessdata(directory=)` is now `Tessdata(data_dir=)`, and `Tessdata` has
134
+ no `timeout`. `Tessdata.ensure(codes, on_download)`: the second argument
135
+ was `reporter`. `RapidOcrEngine(directory=)` is now
136
+ `RapidOcrEngine(model_dir=)`, and `RapidOcrEngine.model_dir` (the
137
+ directory that it uses) is now `RapidOcrEngine.target_dir`
138
+ - Breaking: library: `RapidOcrEngine` fields `recognizers_by_language`,
139
+ `recognizers_by_model`, and `failed_models` (were `languages`,
140
+ `recognizers`, and `failed`). `ctc` is now `ctc_decode`
141
+ - Breaking: library: `ENGINES` and `ENGINE_ENTRY_POINTS` move from
142
+ `pgsrip.cli.plugins` to `pgsrip.engines`, `POST_PROCESSORS` and
143
+ `POST_PROCESSOR_ENTRY_POINTS` to `pgsrip.postprocessors`, `AUTO` and
144
+ `AUTO_ENGINES` to `pgsrip.engines.auto`. `check_auto()` is now
145
+ `AutoEngine.check(settings)`. `AutoEngine` needs its 2 engines, and
146
+ `AutoEngine.from_engines(tesseract, rapidocr)` checks their type
147
+ - Breaking: plug-in API: `OcrEngine.recognize(items, language, debug_dir)`
148
+ returns one `Reading(text, confidence, doubtful)` (from
149
+ `pgsrip.engines.base`) for each item. It does not change the items: `Item`
150
+ has no `text`, `doubtful`, `confidence`, and `place`. `debug_dir` is None
151
+ without `--keep-temp-files`. `PgsToSrtRipper` (`pgsrip.ripper`) is now the
152
+ function `read_cues(items, language, engines, debug_dir)` in
153
+ `pgsrip.engines.chain`. It returns the cues and the time of each engine
154
+ - Breaking: plug-in API: `Item` has plain values: `start`, `end`, `image`,
155
+ `x_offset`, and `y_offset` are never None. `read_items` makes the items:
156
+ `Item(index, start, end, image, x_offset, y_offset, name)`. `Item` has no
157
+ `media_path` and no `language`. `PgsSubtitleItem.auto_fix` and
158
+ `pgsrip.utils.pairwise` go away
159
+ - Breaking: plug-in API: `Cue` moves from `pgsrip.ripper` to `pgsrip.cue`.
160
+ `Cue.start` and `Cue.end` are `int`
161
+ - Breaking: plug-in API: `PostProcessor.process(cues, track)` and
162
+ `Writer.write(path, cues, track, encoding)` get the `Track` (id, name,
163
+ language, flags). Before, they were `process(pgs, cues)` and
164
+ `write(path, pgs, cues, encoding)`
165
+ - Breaking: plug-in API: `OcrEngineFactory.from_settings(settings)` has no
166
+ `workers` argument, like `PostProcessorFactory.from_settings`. An engine
167
+ that uses workers declares a `workers` option: with no value, it gets the
168
+ `-w` value. pgsrip does not add `--<engine>-workers` to the other
169
+ engines. The `check(settings)` classmethod is required for both kinds
170
+ - Breaking: plug-in API: an OCR engine factory raises `ValueError` for a
171
+ wrong setting, like a post-processor factory. Before, it was `OcrError`
172
+ - Fixed: library: a `Subtitle` releases its extracted track at the end of
173
+ its `with` block. A second `rip` of the same subtitle extracts the track
174
+ again. Before, it read a removed file. The next read of another track
175
+ does not extract a finished track again, and leaves no temporary
176
+ directory
177
+ - Fixed: library: after a rip, the environment of the process is the same as
178
+ before. Before, tesseract left `OMP_THREAD_LIMIT=1` in `os.environ`
179
+ - New: `--format` selects the output format. `srt` is the default and the
180
+ only format. Use it more than one time to write more than one file. When
181
+ the file of one format is missing, pgsrip writes only that file
182
+ - Breaking: `-A/--srt-age` is now `-A/--output-age`, and the `srt_age`
183
+ configuration key is now `output_age`
184
+ - Breaking: library: `Options(writers=[...])` sets the output writers. The
185
+ default is `[SrtWriter()]`, from `pgsrip.writers.srt`. `Options.srt_age` is
186
+ now `Options.output_age`, and `Pgs.srt_path` is now
187
+ `Subtitle.output_path(writer)`
188
+ - New: a chain of OCR engines. Use `--engine` more than one time. Each next
189
+ engine reads the cues that the engines before it could not read or are not
190
+ sure of. `--tesseract-threshold` (default 80) sets which tesseract cues go
191
+ to the next engine
192
+ - New: other packages can add an OCR engine with a `pgsrip.engines` entry
193
+ point. The engine declares its options: pgsrip adds them to `rip` as
194
+ `--<engine>-*` options and reads them from the `<engine>` section of the
195
+ configuration file. The engine tells the languages that it can read
196
+ (`supports`). The chain skips an engine that cannot read the language of
197
+ a track. When no engine can read it, the track fails
198
+ - New: tesseract cannot read a language when the tesseract program is not
199
+ found, or when its data is not installed and cannot be downloaded. A
200
+ failed download does not stop the downloads of the other languages
201
+ - New: the `rapidocr` OCR engine (`--engine rapidocr`). It reads the text
202
+ with the PaddleOCR models on ONNX Runtime, and needs no program on the
203
+ system. Install it with the `rapidocr` extra:
204
+ `pip install "pgsrip[rapidocr]"`. The extra needs ONNX Runtime wheels:
205
+ it does not install on musl Linux. It
206
+ downloads the model of each language before the rip starts. Options:
207
+ `--rapidocr-threshold`, `--rapidocr-model`, `--rapidocr-border`,
208
+ `--rapidocr-batch`, `--rapidocr-dir`, `--no-rapidocr-download` and
209
+ `--rapidocr-workers`
210
+ - Changed: the default OCR engine is `auto`. For each language, it uses
211
+ tesseract when tesseract can read the language, else RapidOCR. pgsrip
212
+ can now rip with no tesseract program on the system. `doctor` shows the
213
+ engine of auto. A missing tesseract is not a `doctor` failure when
214
+ RapidOCR can rip
215
+ - New: the Docker image has the RapidOCR PP-OCRv6 small model, in the
216
+ `/usr/src/rapidocr` volume (`PGSRIP_RAPIDOCR_DIR`)
217
+ - Fixed: `rip` exits with code 1 when a subtitle could not be ripped
218
+ - Fixed: when tesseract is not found, `rip` shows the warning one time only
219
+ - New: `doctor` shows the checks of every OCR engine. It accepts `--config`
220
+ and the `--<engine>-*` options
221
+ - New: `--tesseract-workers` sets the number of tesseract processes. It
222
+ overrides `-w/--workers` for tesseract only
223
+ - Breaking: the tessdata options of `rip` and `doctor` are now
224
+ `--tesseract-dir`, `--tesseract-repository` and `--no-tesseract-download`
225
+ - Breaking: library: `Options(engines=[...])` sets the OCR engines. The
226
+ `confidence`, `tesseract_*` and `max_workers` arguments of `Options` move
227
+ to `pgsrip.engines.tesseract.TesseractEngine`. The `tessdata_*` and
228
+ `download_tessdata` arguments move to `TesseractEngine(tessdata=Tessdata(...))`
229
+ - New: a configuration file with the default values of the `rip` options.
230
+ pgsrip reads `config.{json,yml,yaml}` in the user configuration folder,
231
+ `pgsrip.{json,yml,yaml}` in the current folder, and each `--config` file.
232
+ A section groups the options with the same prefix, e.g.
233
+ `tesseract: {threshold: 90}` for `--tesseract-threshold`
234
+ - Breaking: the cleanit rules file option `-c/--config` is now
235
+ `--cleanit-config`. `--config` is now the pgsrip configuration file
236
+ - New: a chain of post-processors changes the text after the OCR engines.
237
+ cleanit is the default post-processor. Use `--post-processor` more than
238
+ one time for a chain, and `--no-post-processor` to keep the text of the OCR
239
+ engines. Other packages can add a post-processor with a
240
+ `pgsrip.postprocessors` entry point
241
+ - New: `--cleanit-tag` is the long name of `-t/--tag`. The `cleanit` section
242
+ of the configuration file sets `config` and `tag`
243
+ - New: `--keep-temp-files` also keeps `ocr.json` and `cues.json`: the text,
244
+ the confidence and the engine of each cue, before and after the
245
+ post-processors
246
+ - Breaking: library: `Options(config_path=..., tags=...)` is now
247
+ `Options(post_processors=[CleanitPostProcessor(config_path, tags)])`, from
248
+ `pgsrip.postprocessors.cleanit`. `Options.config` and `Options.tags` are
249
+ removed. `read_cues` returns the cues, and the writers of
250
+ `pgsrip.writers` write the files
251
+ - Breaking: plug-ins: `pgsrip.ripper.EngineOption` is now
252
+ `pgsrip.plugin.PluginOption`
253
+ - Breaking: the modules move into sub-packages. Plug-ins import
254
+ `OcrEngine`, `OcrEngineFactory` and `OcrError` from `pgsrip.engines.base`.
255
+ `PostProcessor` and `PostProcessorFactory` from
256
+ `pgsrip.postprocessors.base`. The OCR engines are in `pgsrip.engines`, and
257
+ the post-processors are in `pgsrip.postprocessors`
258
+ - Breaking: library: `Mkv` and `Sup` are removed. Use
259
+ `Media('/path/mymedia.mkv')`: it finds the source that reads the file
260
+ - Changed: `--with` and `--without` also apply to `.sup` files. The flags
261
+ come from the file name, for example `mymedia.en.forced.sup`
262
+ - Changed: pgsrip extracts all the selected tracks of a file with one
263
+ `mkvextract` call. Before, each track read the full file again
264
+ - Fixed: a track that pgsrip did not rip left its temporary directory
265
+ - Changed: one temporary directory `pgsrip-XXXX` for each run, with one
266
+ directory for each track in it. Library: use
267
+ `with Workspace() as workspace:` to remove it at the end
268
+ - Changed: `-l/--language` looks only at the languages of the PGS tracks of
269
+ a media, not at the audio and video tracks. A media with no PGS track in
270
+ the selected languages is now filtered out, with its reason
271
+ - Fixed: a track with 20 or more cues that tesseract could not read made the
272
+ rip run forever
273
+ - Fixed: `pgsrip` requires click 8.5.0 or later, so `click.ParamType` stays
274
+ subscriptable
275
+
276
+ ## 0.2.1
277
+
278
+ **release date:** 2026-09-23
279
+
280
+ - Fix: a `.sup` or `.mks` file with a 3-letter language code in its name,
281
+ e.g. `movie.fre.sup`, failed with `FileNotFoundError` and was not ripped
282
+ - Fix: `pgsrip scrub` could write the scrubbed file over its source `.sup`
283
+ file. It now adds `.track0` to the name
284
+ - Fix: a long subtitle track with wide images failed with
285
+ `Image too large` and was not ripped
286
+ - Fix: a subtitle track with images split over 3 or more segments, or with
287
+ palette updates, failed with `0 is not a valid ObjectSequenceType` or
288
+ `IndexError` and was not ripped
289
+ - Rip faster: run several tesseract processes in parallel, decode the
290
+ subtitle images faster, and OCR only the part of each image that holds
291
+ text
292
+ - `-w/--max-workers` now sets the number of tesseract processes that run in
293
+ parallel. The default is the number of CPUs, at most 4
294
+
295
+ ## 0.2.0
296
+
297
+ **release date:** 2026-09-21
298
+
299
+ - Name subtitle tracks after their flags instead of an unstable counter,
300
+ e.g. `movie.en.sdh.srt`, `movie.pt-BR.forced.srt` instead of
301
+ `movie-1.en.srt`
302
+ - Add `--with`/`--without` to select tracks by flag (`forced`, `sdh`, `cc`,
303
+ `commentary`, `descriptive`, `full`, ...)
304
+ - Add `--one-per-language` to keep only one track per language, ignoring
305
+ flags
306
+ - `pgsrip scrub` names its output the same way as a ripped `.srt`
307
+ - Fix: a second subtitle track for an already-ripped language could be
308
+ skipped by mistake, because the overwrite check and the file actually
309
+ written did not agree on its name
310
+
311
+ ## 0.1.13
312
+
313
+ **release date:** 2026-09-20
314
+
315
+ - Add a `doctor` command to check the environment (tesseract, mkvtoolnix,
316
+ language data)
317
+ - Add a `scrub` command to share a subtitle sample without its images
318
+ - Add a `--log-file` option to write a full debug log
319
+ - Auto-download missing tesseract language data
320
+ - Report why a path is ignored or filtered out
321
+ - Tell the user how to report a subtitle that failed to rip
322
+ - Fix: upgrade cleanit to stop release tags being read as languages
323
+ - Fix: do not repeat the language in the scrubbed file name
324
+ - Migrate project tooling to uv, ruff, and strict mypy; support Python
325
+ 3.11 to 3.14
326
+
327
+ ## 0.1.12
328
+
329
+ **release date:** 2025-07-26
330
+
331
+ - Fix: `WindowDefinitionSegment` could have 0 windows
332
+ - Update supported Python versions
333
+ - Update dependencies
334
+
335
+ ## 0.1.11
336
+
337
+ **release date:** 2024-06-23
338
+
339
+ - Maintenance release: dependency updates only
340
+
341
+ ## 0.1.10
342
+
343
+ **release date:** 2024-06-22
344
+
345
+ - Publish arm64 Docker images
346
+ - Add setuptools as an explicit dependency
347
+ - Update dependencies
348
+
349
+ ## 0.1.9
350
+
351
+ **release date:** 2023-03-03
352
+
353
+ - Fix: display sets wrongly grouped together
354
+
355
+ ## 0.1.8
356
+
357
+ **release date:** 2023-02-12
358
+
359
+ - Improve OCR accuracy: add borders, increase gaps, and use PSM 6 for
360
+ uniform text block detection
361
+
362
+ ## 0.1.7
363
+
364
+ **release date:** 2023-02-12
365
+
366
+ - Fix: handle multi-part ODS segments
367
+ - Add an OCR engine mode option
368
+ - Increase text gap and improve debug files
369
+
370
+ ## 0.1.6
371
+
372
+ **release date:** 2023-02-05
373
+
374
+ - Fix the Docker image build
375
+
376
+ ## 0.1.5
377
+
378
+ **release date:** 2023-02-05
379
+
380
+ - Use the latest tesseract version whenever possible
381
+ - Add a `--version` option and report the tesseract version
382
+ - Add an option to keep temporary files after ripping
383
+ - Add Windows installation instructions
384
+
385
+ ## 0.1.4
386
+
387
+ **release date:** 2023-01-09
388
+
389
+ - Fix: wrong expected language passed to trakit
390
+
391
+ ## 0.1.3
392
+
393
+ **release date:** 2023-01-09
394
+
395
+ - Improve language detection using trakit
396
+
397
+ ## 0.1.2
398
+
399
+ **release date:** 2022-12-31
400
+
401
+ - Fix: confidence values are sometimes floats as strings
402
+
403
+ ## 0.1.1
404
+
405
+ **release date:** 2021-04-08
406
+
407
+ - Several fixes to make PGS parsing more resilient to errors and
408
+ corruption
409
+
410
+ ## 0.1
411
+
412
+ **release date:** 2021-03-21
413
+
414
+ - Initial release
@@ -21,9 +21,15 @@ too.
21
21
  - Keep the code small. See "Code: lazy senior dev" in `CLAUDE.md`.
22
22
  - Strict mypy: annotate every function.
23
23
  - Ruff formats the code (single quotes, 120-character lines). Do not format by hand against it.
24
- - Flat package layout: `pgsrip/`, not `src/pgsrip/`.
24
+ - No `src/` layout: the package is `pgsrip/`, with sub-packages.
25
25
  - Do not add tests with real subtitle content. See `tests/samples/README.md`.
26
26
 
27
+ ## Tests
28
+
29
+ `tests/test_rip_e2e.py` rips fabricated media from end to end through the CLI. It checks the `.srt` files that
30
+ it writes. By default, the tests use a fake MKVToolNix. Tesseract is always fake. `--media-backend real` or
31
+ `--media-backend both` runs the same scenarios with a real `mkvmerge`. See `docs/rip-e2e.md`.
32
+
27
33
  ## Branches
28
34
 
29
35
  - `fix/<issue>-<slug>`, `feat/<issue>-<slug>`, `chore/<slug>`. Example: `fix/135-pts-zero`.
@@ -51,7 +51,8 @@ ENV PYTHONFAULTHANDLER=1 \
51
51
  PIP_NO_CACHE_DIR=off \
52
52
  PIP_DISABLE_PIP_VERSION_CHECK=on \
53
53
  PIP_DEFAULT_TIMEOUT=100 \
54
- TESSDATA_PREFIX=/usr/src/tessdata
54
+ TESSDATA_PREFIX=/usr/src/tessdata \
55
+ PGSRIP_RAPIDOCR_DIR=/usr/src/rapidocr
55
56
 
56
57
  COPY --from=apt-keys /etc/apt/trusted.gpg.d/alex-p-ubuntu-tesseract-ocr5.gpg /etc/apt/trusted.gpg.d/
57
58
  COPY --from=apt-keys /usr/share/keyrings/gpg-pub-moritzbunkus.gpg /usr/share/keyrings/
@@ -67,10 +68,14 @@ RUN echo "deb https://notesalexp.org/tesseract-ocr5/trixie/ trixie main" >> /etc
67
68
  COPY --from=tesseract-image /data/tessdata ${TESSDATA_PREFIX}
68
69
  COPY --from=builder /app/dist /usr/src/dist
69
70
 
70
- RUN pip install /usr/src/dist/pgsrip-*.tar.gz
71
+ RUN pip install "$(ls /usr/src/dist/pgsrip-*.tar.gz)[rapidocr]"
72
+
73
+ # the PP-OCRv6 small model: the RapidOCR model of the Latin-script languages, Chinese and Japanese
74
+ RUN python -c "from babelfish import Language; from pgsrip.engines.rapidocr import RapidOcrEngine; \
75
+ engine = RapidOcrEngine(); engine.prepare([Language('eng')], print); assert engine.supports(Language('eng'))"
71
76
 
72
77
  WORKDIR /data
73
- VOLUME ${TESSDATA_PREFIX}
78
+ VOLUME ${TESSDATA_PREFIX} ${PGSRIP_RAPIDOCR_DIR}
74
79
 
75
80
  ENTRYPOINT ["pgsrip"]
76
81
  CMD ["--help"]