Simple module to access to the OpenSubtitles.org subtitles database. This class is a wrapper for the common methods used by the OpenSubtitles API.
The package is released in pypi, you can simply install it with:
$ pip install python-opensubtitles
If you want to install the latest version from this repo:
$ pip install -e git+https://github.com/agonzalezro/python-opensubtitles#egg=python-opensubtitles
If you want to run the tests:
$ python -m unittest
Note: I am using python 3, previous versions might not catch all the tests.
TL;DR; version to download a subtitle:
from pythonopensubtitles.opensubtitles import OpenSubtitles
from pythonopensubtitles.utils import File
ost = OpenSubtitles()
ost.login('xxx', 'xxx')
f = File('/full/path/to/the/movie')
data = ost.search_subtitles([{'sublanguageid': 'all', 'moviehash': f.get_hash(), 'moviebytesize': f.size}])
id_subtitle_file = data[0].get('IDSubtitleFile')
ost.download_subtitles([id_subtitle_file], output_directory='/tmp', extension='srt')
If you want to see more info you can take a look to the old doctest
s on the
APPENDIX.md file.
Probably you will not need to run this, but just FTR:
$ # Edit setup.py to change the version
$ pip install twine
$ python3 setup.py sdist bdist_wheel
$ python3 -m twine upload dist/*
The previous command will upload a release to PyPI.