Filter SDH entries and more from .srt files
Project description
subtitle-filter
Filter .srt
subtitle files to remove SDH (Deaf or Hard-of-Hearing) entries and other tags.
Installation
pip install subtitle-filter
Usage
subtitle-filter
can be used either as a script or a module.
By default, this module filters the following (in order):
- Removes font tags and text contained within, e.g.
<font color="#DF01D7">Hey\</font>
is removed. - Removes subtitle entries containing only asterisks:
*
. - Removes subtitle lines containing
♪
or#
. - Removes sound effects: text contained with and including parenthesis
(BANG)
, asterisks*whisper*
, brackets[boom]
, and text contained within forward slashes/POW/
. - Replaces names with dashes, e.g.
GARY: Hey
orGary: Hey
to- Hey
. - Removes author tags e.g.
XoXo Subtitles by PwnedDude967 XoXo
. - Fixes erroneous comma spacing, e.g.
Hey , what's up? Nothing,my man
toHey, what's up? Nothing, my man
. - Removes lone symbols such as
?
,-
,#
,_
. - Remove leading dashes
-
if there is only one line present.
Script Usage
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.
Module Usage
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,
)
Issues & Requests
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file subtitle_filter-1.5.0.tar.gz
.
File metadata
- Download URL: subtitle_filter-1.5.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6994738b48a5dcf39532521c8a105f21f345760e0e1299028f3abcdcf332e4f7 |
|
MD5 | 1586772049ba038c5b4773cb02950600 |
|
BLAKE2b-256 | 156a34a3205895c1c9b64e48d4a8f02edc8f7aadc8592daa5f0074fdf1b9a4a4 |
File details
Details for the file subtitle_filter-1.5.0-py3-none-any.whl
.
File metadata
- Download URL: subtitle_filter-1.5.0-py3-none-any.whl
- Upload date:
- Size: 8.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.9.19
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b506315be64870fba2e6894a70d76389407ce58c325fdf05129e0530f0a0f5b |
|
MD5 | d2af0b607bd95fd8f26e0d56b24db881 |
|
BLAKE2b-256 | 1040c5d138e1f302b25240678943422a646feea52bab1f594c669c101c5e5070 |