Skip to content

OpenSubtitles is a simple PHP console application to download subtitles from Opensubtitles.org

License

Notifications You must be signed in to change notification settings

stelgenhof/opensubtitles

OpenSubtitles Downloader

OpenSubtitles Downloader is a simple PHP console application to download subtitles from Opensubtitles.org. Just provide the IMDB Movie ID, and it will download all subtitles for the specified languages.

Note: This project is maintained on Gitlab, and mirrored (as read-only) on GitHub. Please submit any issues, merge requests, etc. on Gitlab.

System Requirements

You need PHP >= 7.4 to use OpenSubtitles Downloader but the latest stable version of PHP is recommended. In addition, the following PHP extensions are needed:

  • mbstring
  • intl
  • simplexml
  • iconv
  • xmlrpc
  • zlib

Also, you need an OpenSubtitles developer account. Please follow the instructions here: OpenSubtitles Developer Information.

Installation

Install OpenSubtitles Downloader by cloning this repository:

$ git clone https://gitlab.com/stelgenhof/opensubtitles.git

Configuration

For the OpenSubtitles Downloader to run correctly, the configuration variables in the .env need to be populated with the correct values:

  • OPEN_SUBTITLES_USER_AGENT The user agent string provided by OpenSubtitles. A temporary test user agent can be used, but it is strongly recommended applying for one.
  • OPEN_SUBTITLES_USERNAME Your OpenSubtitles username.
  • OPEN_SUBTITLES_PASSWORD Your OpenSubtitles password.
  • OPEN_SUBTITLES_TARGET_ENCODING The targeted encoding. OpenSubtitles Downloader will transcode the subtitles if they contain foreign characters. Usually UTF-8 as a value should work fine.
  • OPEN_SUBTITLES_LANGUAGES A (comma delimited) list of language codes for the preferred translations.

Please check the OpenSubtitles.org webpage for more information on how to obtain a user account and a application user agent.

Basic Usage

$ ./opensubtitles [IMDB Movie Number]

The downloaded subtitles will be saved in the subtitles directory in a subdirectory named with the title of movie. For subtitles files that are not encoded in UTF-8, these will be automatically converted to UTF-8 (if possible).

Contributing

Contributions are encouraged and welcome; I am always happy to get feedback or pull requests on GitLab :) Create Issues for bugs and new features and comment on the ones you are interested in.

Please refer to the Contributing Guidelines for more details.

If you enjoy what I am making, an extra cup of coffee is very much appreciated :). Your support helps me to put more time into Open-Source Software projects like this.

Buy Me A Coffee

Disclaimer

Please feel free to use, modify, hack this script as you like. It is not perfect, but does the trick for now :). Consult the LICENSE file that comes with this program for more details regarding its license.