Skip to main content

fsub

fsub is a Python script for cleaning, editing and fixing a SubRip (.srt) file

Installation

Through Python's pip:

pip install fsub

Usage

usage: fsub [-h] [-f F] [-c] [-s MS] [-n] [-j] [-u] [-r | -p] [-b B] [-e E] file [file ...]

Fix, edit and clean SubRip (.srt) files.

positional arguments:
  file               list of input files (they all must be SubRip files)

optional arguments:
  -h, --help         show this help message and exit
  -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.

  -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
  -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)

Testing

In the project's root directory, run all the tests with:

python -m unittest tests

Or, just the unit/integration tests:

python -m unittest tests.unit
python -m unittest tests.integration

Scripted API

An example of calling the program from Python:

import fsub

fsub.run('-c', 'test.srt')

Features

  • Fixes subtitle numbering
  • Converts files to UTF-8 encoding
  • Validates file structure
  • 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)
  • May shift the time of all subtitles
  • May strip HTML
  • May join files together
  • May edit files in-place
  • May cut sections out

Release files for fsub 1.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fsub 1.0.4
File Size Uploaded
fsub-1.0.4.tar.gz 19.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fsub 1.0.4
File Interpreter ABI Platform
fsub-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 38.7 kB

Release files / fsub-1.0.4.tar.gz

Download URL fsub-1.0.4.tar.gz
Size 19.2 kB
Tags Source
SHA-256 checksum
How to use checksums
638687d9fe1123419d3095d82f636bcef95042f7ed9e2efe3124ca7d6bde6c3d
BLAKE2b-256 checksum
How to use checksums
9fe862e13f8d34fa520de21b95ea83bf1c60dc20da133e5cb0f7507a8d649070
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.7

Release files / fsub-1.0.4-py3-none-any.whl

Download URL fsub-1.0.4-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
21a5b398551cba5296567a954c7265d36dce8a87e2505c0318efe279dbe040e4
BLAKE2b-256 checksum
How to use checksums
2ec71506021a6fcbfa58c738caa82ef811e5d08371046fc168229fd9baffa103
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.7

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page