2021-08-29 09:48:54 -04:00
# fsub
2021-11-14 13:49:35 -05:00
`fsub` is a Python script for cleaning, editing and fixing a SubRip (.srt) file
2021-08-29 09:48:54 -04:00
2021-11-14 16:06:21 -05:00
# Installation
Through Python's pip:
```
pip install fsub
```
2021-08-29 09:48:54 -04:00
# Usage
2021-11-14 13:49:35 -05:00
```
Fix, edit and clean SubRip (.srt) files.
positional arguments:
2021-11-15 17:30:59 -05:00
file list of input files (they all must be SubRip files)
2021-11-14 13:49:35 -05:00
optional arguments:
2021-11-15 17:30:59 -05:00
-h, --help show this help message and exit
2021-11-17 18:45:38 -05:00
-f F, --config F use F as the config file (by default, on Unix it is:
"$HOME/.config/fsubrc"; on Windows it is: "%APPDATA%\fsubrc")
-r, --replace edit files in-place (--join will delete joined files too), instead of the
default behavior of outputing results into files prefixed with "out-"
-p, --stdout dump results to stdout, and do not edit nor write any file
processing:
Flags that specify an action to be taken. Many may be specified.
2021-11-15 17:30:59 -05:00
-c, --clean remove subtitles matching regular expressions listed in the config file
(this is the default behavior if no other flag is passed)
-s MS, --shift MS shift all subtitles by MS milliseconds, which may be positive or negative
-n, --no-html strip HTML tags from subtitles content
-j, --join join all files into the first, shifting their time accordingly
2021-11-17 18:45:38 -05:00
-u, --cut-out cut the specified section from the file(s) into new files
sectioning:
Flags that specify a section to work in. They accept either a subtitle number or a time
stamp in the SubRip format ("< hours > :< minutes > :< seconds > ,< milliseconds > ", where hours,
minutes, seconds are 2-zero padded while milliseconds is 3-zero padded). fsub will not
modify subtitles outside this range, except while joining the files.
-b B, --begin B specify section beginning (inclusive)
-e E, --end E specify section end (inclusive)
2021-11-15 16:17:30 -05:00
```
# Testing
2021-11-15 16:19:14 -05:00
In the project's root directory, run all the tests with:
2021-11-15 16:17:30 -05:00
```
python -m unittest tests
```
Or, just the unit/integration tests:
```
python -m unittest tests.unit
python -m unittest tests.integration
2021-11-14 13:49:35 -05:00
```
2021-08-29 09:48:54 -04:00
# Features
- Fixes subtitle numbering
2021-11-14 13:49:35 -05:00
- Converts files to UTF-8 encoding
- Validates file structure
2021-11-14 18:32:35 -05:00
- May remove subtitles containing lines that match any regular expression listed in the config file (by default on Unix: `$HOME/.config/fsubrc` ; on Windows: `%APPDATA%\fsubrc` )
2021-11-14 13:49:35 -05:00
- May shift the time of all subtitles
- May strip HTML
2021-11-15 16:19:14 -05:00
- May join files together
2021-11-15 17:30:59 -05:00
- May edit files in-place