subtitle-filter


Namesubtitle-filter JSON
Version 1.5.0 PyPI version JSON
download
home_pagehttps://github.com/mattlyon93/filter-subs
SummaryFilter SDH entries and more from .srt files
upload_time2024-08-01 22:42:49
maintainerNone
docs_urlNone
authorMatt Lyon
requires_python>=3.5
licenseMIT License
keywords subtitle sdh hard-of-hearing filter movie tv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            # subtitle-filter

[![PyPI version](https://badge.fury.io/py/subtitle-filter.svg)](https://badge.fury.io/py/subtitle-filter)

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

## Installation

```bash
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 only asterisks: `*`.
3. Removes subtitle lines containing `♪` or `#`.
4. Removes sound effects: text contained with and including parenthesis `(BANG)`, asterisks `*whisper*`, brackets `[boom]`, and text contained within forward slashes `/POW/`.
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 `?`, `-`, `#`, `_`.
9. Remove leading dashes `-` if there is only one line present.

### Script Usage

Bring up the help display:

```bash
filter-subtitles.py -h
```

Filter a subtitle in place (overwrites original subtitle) with default options.

```bash
filter-subtitles.py -s /path/to/sub.srt
```

Instead of saving to disk, print the output.

```bash
filter-subtitles.py -s /path/to/sub.srt -p
```

Save the output to a different filepath.

```bash
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

```python
from subtitle_filter import Subtitles

subs = Subtitles('/path/to/sub.srt')
subs.filter()
subs.save()
```

Instead of saving to disk, print the output.

```python
subs.print()
```

Save the output to a different filepath.

```python
subs.save('/path/to/newsub.srt')
```

Use custom filter flags.

```python
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.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mattlyon93/filter-subs",
    "name": "subtitle-filter",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": null,
    "keywords": "subtitle, SDH, hard-of-hearing, filter, movie, tv",
    "author": "Matt Lyon",
    "author_email": "matthewlyon18@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/15/6a/34a3205895c1c9b64e48d4a8f02edc8f7aadc8592daa5f0074fdf1b9a4a4/subtitle_filter-1.5.0.tar.gz",
    "platform": null,
    "description": "# subtitle-filter\n\n[![PyPI version](https://badge.fury.io/py/subtitle-filter.svg)](https://badge.fury.io/py/subtitle-filter)\n\nFilter `.srt` subtitle files to remove SDH (Deaf or Hard-of-Hearing) entries and other tags.\n\n## Installation\n\n```bash\npip install subtitle-filter\n```\n\n## Usage\n\n`subtitle-filter` can be used either as a script or a module.\n\nBy default, this module filters the following (in order):\n\n1. Removes font tags and text contained within, e.g. `<font color=\"#DF01D7\">Hey\\</font>` is removed.\n2. Removes subtitle entries containing only asterisks: `*`.\n3. Removes subtitle lines containing `\u266a` or `#`.\n4. Removes sound effects: text contained with and including parenthesis `(BANG)`, asterisks `*whisper*`, brackets `[boom]`, and text contained within forward slashes `/POW/`.\n5. Replaces names with dashes, e.g. `GARY: Hey` or `Gary: Hey` to `- Hey`.\n6. Removes author tags e.g. `XoXo Subtitles by PwnedDude967 XoXo`.\n7. Fixes erroneous comma spacing, e.g. `Hey , what's up? Nothing,my man` to `Hey, what's up? Nothing, my man`.\n8. Removes lone symbols such as `?`, `-`, `#`, `_`.\n9. Remove leading dashes `-` if there is only one line present.\n\n### Script Usage\n\nBring up the help display:\n\n```bash\nfilter-subtitles.py -h\n```\n\nFilter a subtitle in place (overwrites original subtitle) with default options.\n\n```bash\nfilter-subtitles.py -s /path/to/sub.srt\n```\n\nInstead of saving to disk, print the output.\n\n```bash\nfilter-subtitles.py -s /path/to/sub.srt -p\n```\n\nSave the output to a different filepath.\n\n```bash\nfilter-subtitles.py -s /path/to/sub.srt -o /path/to/outsub.srt\n```\n\nCustom filter flags.\n\n```\n--keep-fonts          Do not remove font tags and text contained within.\n--keep-ast            Do not remove subtitles containing asterisks: (*).\n--keep-music          Do not lines containing 1 or more \"\u266a\" symbols.\n--keep-effects        Do not remove text between and including parenthesis\n                        () or brackets []\n--keep-names          Do not replace names in CAPITALS with \"-\" tags\n--keep-author         Do not remove author tags, eg. Subtitles by some guy.\n--keep-lone-dashes    Do not remove the dash if only one dashed line is present.\n--keep-commas         Do not fix comma spacings.\n```\n\n### Module Usage\n\nFilter a subtitle in place (overwrites original subtitle) with default options\n\n```python\nfrom subtitle_filter import Subtitles\n\nsubs = Subtitles('/path/to/sub.srt')\nsubs.filter()\nsubs.save()\n```\n\nInstead of saving to disk, print the output.\n\n```python\nsubs.print()\n```\n\nSave the output to a different filepath.\n\n```python\nsubs.save('/path/to/newsub.srt')\n```\n\nUse custom filter flags.\n\n```python\nsubs.filter(\n    rm_fonts=True,\n    rm_ast=False,\n    rm_music=True,\n    rm_effects=True,\n    rm_names=False,\n    rm_author=False,\n)\n```\n\n### Issues & Requests\n\nIf you spot any issues with the filtered subtitles, or would like to request new features, please create an issue on GitHub and provide examples.\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "Filter SDH entries and more from .srt files",
    "version": "1.5.0",
    "project_urls": {
        "Download": "https://github.com/mattlyon93/filter-subs/archive/v1.5.0.tar.gz",
        "Homepage": "https://github.com/mattlyon93/filter-subs"
    },
    "split_keywords": [
        "subtitle",
        " sdh",
        " hard-of-hearing",
        " filter",
        " movie",
        " tv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1040c5d138e1f302b25240678943422a646feea52bab1f594c669c101c5e5070",
                "md5": "d2af0b607bd95fd8f26e0d56b24db881",
                "sha256": "6b506315be64870fba2e6894a70d76389407ce58c325fdf05129e0530f0a0f5b"
            },
            "downloads": -1,
            "filename": "subtitle_filter-1.5.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "d2af0b607bd95fd8f26e0d56b24db881",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 8346,
            "upload_time": "2024-08-01T22:42:47",
            "upload_time_iso_8601": "2024-08-01T22:42:47.787018Z",
            "url": "https://files.pythonhosted.org/packages/10/40/c5d138e1f302b25240678943422a646feea52bab1f594c669c101c5e5070/subtitle_filter-1.5.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "156a34a3205895c1c9b64e48d4a8f02edc8f7aadc8592daa5f0074fdf1b9a4a4",
                "md5": "1586772049ba038c5b4773cb02950600",
                "sha256": "6994738b48a5dcf39532521c8a105f21f345760e0e1299028f3abcdcf332e4f7"
            },
            "downloads": -1,
            "filename": "subtitle_filter-1.5.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1586772049ba038c5b4773cb02950600",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 8464,
            "upload_time": "2024-08-01T22:42:49",
            "upload_time_iso_8601": "2024-08-01T22:42:49.359644Z",
            "url": "https://files.pythonhosted.org/packages/15/6a/34a3205895c1c9b64e48d4a8f02edc8f7aadc8592daa5f0074fdf1b9a4a4/subtitle_filter-1.5.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-01 22:42:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mattlyon93",
    "github_project": "filter-subs",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "lcname": "subtitle-filter"
}
        
Elapsed time: 0.77383s