Skip to main content

Filter SDH entries and more from .srt files

Project description

filter-subtitles

Build Status Coverage Status

Filter .srt subtitle files to remove SDH (Deaf or Hard-of-Hearing) entries and other tags.

Installation

pip install filter-subtitles

Usage

filter-subtitles can be used either as a script or a module.

By default, this module filters the following (in order):

  1. Removes font tags e.g. <font color="#DF01D7">(GUN COCKS)\</font>.
  2. Removes subtitle entries containing asterisks: *.
  3. Removes music tags and text contained within two music tags.
  4. Removes sound effects: text contained with and including parenthesis (BANG) and brackets [boom].
  5. Replaces capitalized names with dashes, e.g. GARY: Hey to - Hey.
  6. Removes author tags such as XoXo Subtitles by PwnedDude967 XoXo.

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 from subtitles.
--keep-ast            Do not remove subtitles containing asterisks: (*).
--keep-music          Do not remove "♪" symbols and text contained within
                        two "♪" 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 (overw.rites 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,
)

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.0.0.tar.gz (5.5 kB view hashes)

Uploaded Source

Supported by

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