Skip to main content

Filter SDH entries and more from .srt files

Project description

subtitle-filter

PyPI version

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

  1. Removes font tags and text contained within, e.g. <font color="#DF01D7">Hey\</font> is removed.
  2. Removes subtitle entries containing asterisks: *.
  3. Removes subtitle lines containing or #.
  4. Removes sound effects: text contained with and including parenthesis (BANG) and brackets [boom].
  5. Replaces names with dashes, e.g. GARY: Hey or Gary: Hey to - Hey.
  6. Removes author tags e.g. XoXo Subtitles by PwnedDude967 XoXo.
  7. Fixes erroneous comma spacing, e.g. Hey , what's up? Nothing,my man to Hey, what's up? Nothing, my man.
  8. Removes lone symbols such as ?, -, #, _.

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.

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

If you spot any issues with the filtered subtitles, or would like to request new features, please create an issue on GitHub.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

subtitle-filter-1.4.4.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subtitle_filter-1.4.4-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file subtitle-filter-1.4.4.tar.gz.

File metadata

  • Download URL: subtitle-filter-1.4.4.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for subtitle-filter-1.4.4.tar.gz
Algorithm Hash digest
SHA256 7f414532de7ffc54ea3129f9ee1528c642feabbc8c5d5836bdddb47a98165158
MD5 9d667de5cc95c201b8a70bacf9fea731
BLAKE2b-256 39960f20b5563a6e7d126d29b0a95579a3b83477809b9511232d0bb3ce9f65bb

See more details on using hashes here.

File details

Details for the file subtitle_filter-1.4.4-py3-none-any.whl.

File metadata

File hashes

Hashes for subtitle_filter-1.4.4-py3-none-any.whl
Algorithm Hash digest
SHA256 6d806a6dcd1989e2c97f4142281393f89a0e2e83b1d72192f28e239a4cc5ca8e
MD5 47920aff8abe09ef41ab9b5510ecaf3b
BLAKE2b-256 0086a54138ccba97f5ae6e02a9059b2479ea9f731103431952ab5b3741695431

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page