Filter .srt
subtitle files to remove SDH (Deaf or Hard-of-Hearing) entries and other tags.
pip install subtitle-filter
subtitle-filter
can be used either as a script or a module.
By default, this module filters the following (in order):
<font color="#DF01D7">Hey\</font>
is removed.*
.♪
or #
.(BANG)
, asterisks *whisper*
, brackets [boom]
, and text contained within forward slashes /POW/
.GARY: Hey
or Gary: Hey
to - Hey
.XoXo Subtitles by PwnedDude967 XoXo
.Hey , what's up? Nothing,my man
to Hey, what's up? Nothing, my man
.?
, -
, #
, _
.-
if there is only one line present.Bring up the help display:
filter-subtitles.py -h
Filter a subtitle in place (overwrites original subtitle) with default options.
filter-subtitles.py -s /path/to/sub.srt
Instead of saving to disk, print the output.
filter-subtitles.py -s /path/to/sub.srt -p
Save the output to a different filepath.
filter-subtitles.py -s /path/to/sub.srt -o /path/to/outsub.srt
Custom filter flags.
--keep-fonts Do not remove font tags and text contained within.
--keep-ast Do not remove subtitles containing asterisks: (*).
--keep-music Do not lines containing 1 or more "♪" symbols.
--keep-effects Do not remove text between and including parenthesis
() or brackets []
--keep-names Do not replace names in CAPITALS with "-" tags
--keep-author Do not remove author tags, eg. Subtitles by some guy.
--keep-lone-dashes Do not remove the dash if only one dashed line is present.
--keep-commas Do not fix comma spacings.
Filter a subtitle in place (overwrites original subtitle) with default options
from subtitle_filter import Subtitles
subs = Subtitles('/path/to/sub.srt')
subs.filter()
subs.save()
Instead of saving to disk, print the output.
subs.print()
Save the output to a different filepath.
subs.save('/path/to/newsub.srt')
Use custom filter flags.
subs.filter(
rm_fonts=True,
rm_ast=False,
rm_music=True,
rm_effects=True,
rm_names=False,
rm_author=False,
)
If you spot any issues with the filtered subtitles, or would like to request new features, please create an issue on GitHub and provide examples.