srtranslator


Namesrtranslator JSON
Version 0.3.9 PyPI version JSON
download
home_pagehttps://github.com/sinedie/SRTranslator
SummaryTraslate a .SRT file using any custom translator
upload_time2024-10-17 01:39:32
maintainerNone
docs_urlNone
authorEAR
requires_python>=3.6
licenseFREE
keywords python srt languages translator subtitles
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SRTranslator

## Install

[PyPI](https://pypi.org/project/srtranslator/)

```bash
pip install srtranslator
```

## Usage in Blender

[tin2tin](https://github.com/tin2tin) has made this [blender addon](https://github.com/tin2tin/import_subtitles). Check it out.

## Usage from script

Import stuff

```python
import os

# SRT File
from srtranslator import SrtFile
# ASS File
from srtranslator import AssFile

from srtranslator.translators.deepl_api import DeeplApi
from srtranslator.translators.deepl_scrap import DeeplTranslator
from srtranslator.translators.translatepy import TranslatePy
from srtranslator.translators.pydeeplx import PyDeepLX
```

Initialize translator. It can be any translator, even your own, check the docs, there are instructions per translator and how to create your own.

```python
translator = DeeplTranslator() # or TranslatePy() or DeeplApi(api_key) or DeepLX()
```

Load, translate and save. For multiple recursive files in folder, check `examples folder`

```python
filepath = "./filepath/to/srt"

# SRT File
sub = SrtFile(filepath)
# ASS File
sub = AssFile(filepath)

# Translate
sub.translate(translator, "en", "es")

# Making the result subtitles prettier
sub.wrap_lines()

sub.save(f"{os.path.splitext(filepath)[0]}_translated.srt")
```

Quit translator

```python
translator.quit()
```

## Usage from GUI

[Last release](https://github.com/sinedie/SRTranslator/releases/tag/v0.3.7) has installers for the official srtranslatorGUI on windows (.msi) and linux (.deb, .flatpak)

#### Package from source

In folder srtranslatorGUI there is a briefcase/toga GUI implementation in top of the translator core. You could create your own binary with:

```
cd srtranslatorGUI
pip install briefcase
briefcase create
briefcase build
briefcase package
```

Binaries found in ```dist``` folder

#### Alternatives
[KryptoST](https://github.com/KryptoST) has made a graphical user interface. You can check it out [here](https://github.com/KryptoST/SRTranslatorGUI)

## Usage command line

```bash
# SRT file
python -m srtranslator ./filepath/to/srt -i SRC_LANG -o DEST_LANG

# ASS file
python -m srtranslator ./filepath/to/ass -i SRC_LANG -o DEST_LANG
```

## Advanced usage

```
usage: __main__.py [-h] [-i SRC_LANG] [-o DEST_LANG] [-v] [-vv] [-s] [-w WRAP_LIMIT] [-t {deepl-scrap,translatepy,deepl-api,pydeeplx}] [--auth AUTH] path

Translate an .STR and .ASS file

positional arguments:
  path                  File to translate

options:
  -h, --help            show this help message and exit
  -i SRC_LANG, --src-lang SRC_LANG
                        Source language. Default: auto
  -o DEST_LANG, --dest-lang DEST_LANG
                        Destination language. Default: es (spanish)
  -v, --verbose         Increase output verbosity
  -vv, --debug          Increase output verbosity for debugging
  -s, --show-browser    Show browser window
  -w WRAP_LIMIT, --wrap-limit WRAP_LIMIT
                        Number of characters -including spaces- to wrap a line of text. Default: 50
  -t {deepl-scrap,translatepy,deepl-api}, --translator {deepl-scrap,translatepy,deepl-api,pydeeplx}
                        Built-in translator to use
  --auth AUTH           Api key if needed on translator
  --proxies             Use proxy by default for pydeeplx
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/sinedie/SRTranslator",
    "name": "srtranslator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "python, srt, languages, translator, subtitles",
    "author": "EAR",
    "author_email": "sinedie@protonmail.com",
    "download_url": "https://files.pythonhosted.org/packages/30/c3/741ec95bf92cb40723eb739201d52976c26f77c19a783dab34512bd6400e/srtranslator-0.3.9.tar.gz",
    "platform": null,
    "description": "# SRTranslator\n\n## Install\n\n[PyPI](https://pypi.org/project/srtranslator/)\n\n```bash\npip install srtranslator\n```\n\n## Usage in Blender\n\n[tin2tin](https://github.com/tin2tin) has made this [blender addon](https://github.com/tin2tin/import_subtitles). Check it out.\n\n## Usage from script\n\nImport stuff\n\n```python\nimport os\n\n# SRT File\nfrom srtranslator import SrtFile\n# ASS File\nfrom srtranslator import AssFile\n\nfrom srtranslator.translators.deepl_api import DeeplApi\nfrom srtranslator.translators.deepl_scrap import DeeplTranslator\nfrom srtranslator.translators.translatepy import TranslatePy\nfrom srtranslator.translators.pydeeplx import PyDeepLX\n```\n\nInitialize translator. It can be any translator, even your own, check the docs, there are instructions per translator and how to create your own.\n\n```python\ntranslator = DeeplTranslator() # or TranslatePy() or DeeplApi(api_key) or DeepLX()\n```\n\nLoad, translate and save. For multiple recursive files in folder, check `examples folder`\n\n```python\nfilepath = \"./filepath/to/srt\"\n\n# SRT File\nsub = SrtFile(filepath)\n# ASS File\nsub = AssFile(filepath)\n\n# Translate\nsub.translate(translator, \"en\", \"es\")\n\n# Making the result subtitles prettier\nsub.wrap_lines()\n\nsub.save(f\"{os.path.splitext(filepath)[0]}_translated.srt\")\n```\n\nQuit translator\n\n```python\ntranslator.quit()\n```\n\n## Usage from GUI\n\n[Last release](https://github.com/sinedie/SRTranslator/releases/tag/v0.3.7) has installers for the official srtranslatorGUI on windows (.msi) and linux (.deb, .flatpak)\n\n#### Package from source\n\nIn folder srtranslatorGUI there is a briefcase/toga GUI implementation in top of the translator core. You could create your own binary with:\n\n```\ncd srtranslatorGUI\npip install briefcase\nbriefcase create\nbriefcase build\nbriefcase package\n```\n\nBinaries found in ```dist``` folder\n\n#### Alternatives\n[KryptoST](https://github.com/KryptoST) has made a graphical user interface. You can check it out [here](https://github.com/KryptoST/SRTranslatorGUI)\n\n## Usage command line\n\n```bash\n# SRT file\npython -m srtranslator ./filepath/to/srt -i SRC_LANG -o DEST_LANG\n\n# ASS file\npython -m srtranslator ./filepath/to/ass -i SRC_LANG -o DEST_LANG\n```\n\n## Advanced usage\n\n```\nusage: __main__.py [-h] [-i SRC_LANG] [-o DEST_LANG] [-v] [-vv] [-s] [-w WRAP_LIMIT] [-t {deepl-scrap,translatepy,deepl-api,pydeeplx}] [--auth AUTH] path\n\nTranslate an .STR and .ASS file\n\npositional arguments:\n  path                  File to translate\n\noptions:\n  -h, --help            show this help message and exit\n  -i SRC_LANG, --src-lang SRC_LANG\n                        Source language. Default: auto\n  -o DEST_LANG, --dest-lang DEST_LANG\n                        Destination language. Default: es (spanish)\n  -v, --verbose         Increase output verbosity\n  -vv, --debug          Increase output verbosity for debugging\n  -s, --show-browser    Show browser window\n  -w WRAP_LIMIT, --wrap-limit WRAP_LIMIT\n                        Number of characters -including spaces- to wrap a line of text. Default: 50\n  -t {deepl-scrap,translatepy,deepl-api}, --translator {deepl-scrap,translatepy,deepl-api,pydeeplx}\n                        Built-in translator to use\n  --auth AUTH           Api key if needed on translator\n  --proxies             Use proxy by default for pydeeplx\n```\n",
    "bugtrack_url": null,
    "license": "FREE",
    "summary": "Traslate a .SRT file using any custom translator",
    "version": "0.3.9",
    "project_urls": {
        "Homepage": "https://github.com/sinedie/SRTranslator"
    },
    "split_keywords": [
        "python",
        " srt",
        " languages",
        " translator",
        " subtitles"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eff8228d5521e25333b7ba9afed739729976f32ad2508ce89dfd6bacf2d32aba",
                "md5": "de079c7089196c20970a8ccdacac75da",
                "sha256": "e0d0742f1927127de40d39a93eb645cb20cc7c9d7a875e26a4f79989681b6c48"
            },
            "downloads": -1,
            "filename": "srtranslator-0.3.9-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "de079c7089196c20970a8ccdacac75da",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 15226,
            "upload_time": "2024-10-17T01:39:31",
            "upload_time_iso_8601": "2024-10-17T01:39:31.430887Z",
            "url": "https://files.pythonhosted.org/packages/ef/f8/228d5521e25333b7ba9afed739729976f32ad2508ce89dfd6bacf2d32aba/srtranslator-0.3.9-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "30c3741ec95bf92cb40723eb739201d52976c26f77c19a783dab34512bd6400e",
                "md5": "b9f65d661d0033999ec7284d63436169",
                "sha256": "d29124e592ef8ad1d459dea8d5ab7e12c044dca7e4748d4ce19d9e33045b3b3f"
            },
            "downloads": -1,
            "filename": "srtranslator-0.3.9.tar.gz",
            "has_sig": false,
            "md5_digest": "b9f65d661d0033999ec7284d63436169",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 12108,
            "upload_time": "2024-10-17T01:39:32",
            "upload_time_iso_8601": "2024-10-17T01:39:32.587408Z",
            "url": "https://files.pythonhosted.org/packages/30/c3/741ec95bf92cb40723eb739201d52976c26f77c19a783dab34512bd6400e/srtranslator-0.3.9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-17 01:39:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "sinedie",
    "github_project": "SRTranslator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "srtranslator"
}
        
EAR
Elapsed time: 0.33851s