opensubtitlescom


Nameopensubtitlescom JSON
Version 0.1.4 PyPI version JSON
download
home_page
SummaryOpenSubtitles.com new REST API
upload_time2023-12-20 12:32:46
maintainer
docs_urlNone
author
requires_python>=3.7
licenseThe MIT License Copyright (c) 2023-present Omer Duskin Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords opensubtitles
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python OpenSubtitles.com API Wrapper

![GitHub](https://img.shields.io/github/license/dusking/opensubtitles-com)
![PyPI](https://img.shields.io/pypi/v/opensubtitlescom)
![Python](https://img.shields.io/pypi/pyversions/opensubtitlescom)

A Python wrapper for the OpenSubtitles REST API, providing easy access to subtitle data.
This library allows you to interact with OpenSubtitles.com programmatically,
making it simple to search for and download subtitles for your favorite movies and TV shows.

## Installation

You can install the package using `pip` directly from PyPI or by cloning the repository from GitHub.

**Install from PyPI:**

```bash
pip install opensubtitlescom
```

**Install from GitHub (latest development version):**

```bash
pip install git+ssh://git@github.com/dusking/opensubtitles-com.git --upgrade
```

## Usage

Using this wrapper is straightforward.
It follows the OpenSubtitles API documentation closely and converts responses into Python objects.
Here's an example of how to use it:

```python
from opensubtitlescom import OpenSubtitles

# Initialize the OpenSubtitles client
subtitles = OpenSubtitles(MY_API_KEY, "MyApp v1.0.0")

# Log in (retrieve auth token)
subtitles.login(MY_USERNAME, MY_PASSWORD)

# Search for subtitles
response = subtitles.search(query="breaking bad", season_number=1, episode_number=1, languages="en")

# Convert the response to a Python dictionary
response_dict = response.to_dict()
print(response_dict)

# Convert the response to a Json format
response_json = response.to_json()
print(response_json)

# Get first response subtitles
srt = subtitles.download_and_parse(response.data[0])
```

Here's another simple example:
```python
# Get latest uploaded subtitles
latest_uploads = subtitles.discover_latest()

# Convert the response to a Python dictionary
latest_uploads_dict = latest_uploads.to_dict()
```

For more information on available methods and options,
refer to the [OpenSubtitles API documentation](https://api.opensubtitles.com/).

## Using the CLI

The library is accessible through the CLI, offering various options.
To view all available commands, use the following:

```bash
$> ost -h
positional arguments:
  {set-cred,show-cred,search,download}
    set-cred            Set the username and password in the config file.
    show-cred           Show the username and password in the config file.
    search              Search for subtitles by various criteria.
    download            Download a subtitle by file-id or movie-hash.

optional arguments:
  -h, --help            show this help message and exit
  --config CONFIG       Path to the configuration file
  -v, --verbose         Increase verbosity level
```

Before executing CLI commands, set your opensubtitles user credentials using the set-cred command:

```bash
$> ost set-cred
Enter your username (leave blank to keep existing):
Enter your password (leave blank to keep existing):
Credentials set successfully
```

Credentials are stored in the configuration file.
Now you can use CLI commands. For instance, to search for subtitles:

```bash
$> ost search --query "The Matrix"
+----+---------------------------+----------+---------+------------------------------------------------------------------------+
| #  | title                     | imdb-id  | file-id | file-name                                                              |
+----+---------------------------+----------+---------+------------------------------------------------------------------------+
| 1  | The Matrix                | 133093   | 4461104 | The.Matrix.1999.720p.HDDVD.DTS.x264-ESiR.ENG                           |
| 2  | The Matrix                | 133093   | 4477776 | The.Matrix.1999.Subtitles.YIFY                                         |
| 3  | The Matrix                | 133093   | 4465191 | The.Matrix.1999.BluRay.1080p.x264.DTS-WiKi.ENG                         |
| 4  | The Matrix                | 133093   | 4483524 | The.Matrix.1999.1080p.BrRip.x264.YIFY.en                               |
| 5  | The Matrix                | 133093   | 4480638 | The.Matrix.1999.1080p.BluRay.x264-CtrlHD.eng-sdh                       |
```

To download subtitles, use the download command with the specified file-id:

```bash
$> ost download --file-id 4461104
```

You can easily download subtitles for a local file using the CLI.
The command will automatically search for the hash and download the first result. For example:

```bash
$> ost download --file mymovie.mp4
```

This command will download the subtitle for "mymovie.mp4" and save it as "mymovie.srt".

## Running Tests

To execute the unit tests, use the following command:

```
$ python -m unittest
```

Make sure you have the necessary dependencies installed and a valid Python environment set up before running the tests.

## Contributing

Contributions to this project are welcome. If you'd like to contribute, please follow these guidelines:

1. Open an issue to discuss your proposed changes before submitting a pull request.
2. Ensure that your code adheres to the project's coding standards.
3. Write tests for your code and make sure existing tests pass.
4. Document your changes thoroughly, including updating this README if necessary.

Thank you for your interest in improving this project!

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "opensubtitlescom",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "opensubtitles",
    "author": "",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/f4/87/0208a88528f1167b198fc353a07b0479079f4c94c1733127a9b35aa52a0b/opensubtitlescom-0.1.4.tar.gz",
    "platform": null,
    "description": "# Python OpenSubtitles.com API Wrapper\n\n![GitHub](https://img.shields.io/github/license/dusking/opensubtitles-com)\n![PyPI](https://img.shields.io/pypi/v/opensubtitlescom)\n![Python](https://img.shields.io/pypi/pyversions/opensubtitlescom)\n\nA Python wrapper for the OpenSubtitles REST API, providing easy access to subtitle data.\nThis library allows you to interact with OpenSubtitles.com programmatically,\nmaking it simple to search for and download subtitles for your favorite movies and TV shows.\n\n## Installation\n\nYou can install the package using `pip` directly from PyPI or by cloning the repository from GitHub.\n\n**Install from PyPI:**\n\n```bash\npip install opensubtitlescom\n```\n\n**Install from GitHub (latest development version):**\n\n```bash\npip install git+ssh://git@github.com/dusking/opensubtitles-com.git --upgrade\n```\n\n## Usage\n\nUsing this wrapper is straightforward.\nIt follows the OpenSubtitles API documentation closely and converts responses into Python objects.\nHere's an example of how to use it:\n\n```python\nfrom opensubtitlescom import OpenSubtitles\n\n# Initialize the OpenSubtitles client\nsubtitles = OpenSubtitles(MY_API_KEY, \"MyApp v1.0.0\")\n\n# Log in (retrieve auth token)\nsubtitles.login(MY_USERNAME, MY_PASSWORD)\n\n# Search for subtitles\nresponse = subtitles.search(query=\"breaking bad\", season_number=1, episode_number=1, languages=\"en\")\n\n# Convert the response to a Python dictionary\nresponse_dict = response.to_dict()\nprint(response_dict)\n\n# Convert the response to a Json format\nresponse_json = response.to_json()\nprint(response_json)\n\n# Get first response subtitles\nsrt = subtitles.download_and_parse(response.data[0])\n```\n\nHere's another simple example:\n```python\n# Get latest uploaded subtitles\nlatest_uploads = subtitles.discover_latest()\n\n# Convert the response to a Python dictionary\nlatest_uploads_dict = latest_uploads.to_dict()\n```\n\nFor more information on available methods and options,\nrefer to the [OpenSubtitles API documentation](https://api.opensubtitles.com/).\n\n## Using the CLI\n\nThe library is accessible through the CLI, offering various options.\nTo view all available commands, use the following:\n\n```bash\n$> ost -h\npositional arguments:\n  {set-cred,show-cred,search,download}\n    set-cred            Set the username and password in the config file.\n    show-cred           Show the username and password in the config file.\n    search              Search for subtitles by various criteria.\n    download            Download a subtitle by file-id or movie-hash.\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --config CONFIG       Path to the configuration file\n  -v, --verbose         Increase verbosity level\n```\n\nBefore executing CLI commands, set your opensubtitles user credentials using the set-cred command:\n\n```bash\n$> ost set-cred\nEnter your username (leave blank to keep existing):\nEnter your password (leave blank to keep existing):\nCredentials set successfully\n```\n\nCredentials are stored in the configuration file.\nNow you can use CLI commands. For instance, to search for subtitles:\n\n```bash\n$> ost search --query \"The Matrix\"\n+----+---------------------------+----------+---------+------------------------------------------------------------------------+\n| #  | title                     | imdb-id  | file-id | file-name                                                              |\n+----+---------------------------+----------+---------+------------------------------------------------------------------------+\n| 1  | The Matrix                | 133093   | 4461104 | The.Matrix.1999.720p.HDDVD.DTS.x264-ESiR.ENG                           |\n| 2  | The Matrix                | 133093   | 4477776 | The.Matrix.1999.Subtitles.YIFY                                         |\n| 3  | The Matrix                | 133093   | 4465191 | The.Matrix.1999.BluRay.1080p.x264.DTS-WiKi.ENG                         |\n| 4  | The Matrix                | 133093   | 4483524 | The.Matrix.1999.1080p.BrRip.x264.YIFY.en                               |\n| 5  | The Matrix                | 133093   | 4480638 | The.Matrix.1999.1080p.BluRay.x264-CtrlHD.eng-sdh                       |\n```\n\nTo download subtitles, use the download command with the specified file-id:\n\n```bash\n$> ost download --file-id 4461104\n```\n\nYou can easily download subtitles for a local file using the CLI.\nThe command will automatically search for the hash and download the first result. For example:\n\n```bash\n$> ost download --file mymovie.mp4\n```\n\nThis command will download the subtitle for \"mymovie.mp4\" and save it as \"mymovie.srt\".\n\n## Running Tests\n\nTo execute the unit tests, use the following command:\n\n```\n$ python -m unittest\n```\n\nMake sure you have the necessary dependencies installed and a valid Python environment set up before running the tests.\n\n## Contributing\n\nContributions to this project are welcome. If you'd like to contribute, please follow these guidelines:\n\n1. Open an issue to discuss your proposed changes before submitting a pull request.\n2. Ensure that your code adheres to the project's coding standards.\n3. Write tests for your code and make sure existing tests pass.\n4. Document your changes thoroughly, including updating this README if necessary.\n\nThank you for your interest in improving this project!\n",
    "bugtrack_url": null,
    "license": "The MIT License  Copyright (c) 2023-present Omer Duskin  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "OpenSubtitles.com new REST API",
    "version": "0.1.4",
    "project_urls": {
        "Bug Reports": "https://github.com/dusking/opensubtitles-com/issues",
        "Homepage": "https://github.com/dusking/opensubtitles-com",
        "Source": "https://github.com/dusking/opensubtitles-com.git"
    },
    "split_keywords": [
        "opensubtitles"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a550fc902a0f13f521b7afff65be1b8ea5bf54bf78dff822879ef0b271854037",
                "md5": "7e13e3083644428ea3dd0c0c57b3ef4a",
                "sha256": "aaf3a7c60868c09430c4b62007c93d44be08c900c74416cd4adcbd5e267217c0"
            },
            "downloads": -1,
            "filename": "opensubtitlescom-0.1.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "7e13e3083644428ea3dd0c0c57b3ef4a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 30283,
            "upload_time": "2023-12-20T12:32:44",
            "upload_time_iso_8601": "2023-12-20T12:32:44.464025Z",
            "url": "https://files.pythonhosted.org/packages/a5/50/fc902a0f13f521b7afff65be1b8ea5bf54bf78dff822879ef0b271854037/opensubtitlescom-0.1.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f4870208a88528f1167b198fc353a07b0479079f4c94c1733127a9b35aa52a0b",
                "md5": "1dd39dd2836aec93242b2c7053ea4c45",
                "sha256": "8f3812f8851f487bd022dd61f9e195e18ea9abf4dca1a7e87d7f565cf7efbfb6"
            },
            "downloads": -1,
            "filename": "opensubtitlescom-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "1dd39dd2836aec93242b2c7053ea4c45",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 28321,
            "upload_time": "2023-12-20T12:32:46",
            "upload_time_iso_8601": "2023-12-20T12:32:46.292476Z",
            "url": "https://files.pythonhosted.org/packages/f4/87/0208a88528f1167b198fc353a07b0479079f4c94c1733127a9b35aa52a0b/opensubtitlescom-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-12-20 12:32:46",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "dusking",
    "github_project": "opensubtitles-com",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "opensubtitlescom"
}
        
Elapsed time: 0.20995s