Subliminal is a python library / command line tool to search and download subtitles.
Various video players like Totem or VLC (with the VLSub extension) already support downloading subtitles from OpenSubtitles based on the video name or hash, but Subliminal supports multiple subtitle websites: Addic7ed, BierDopje, OpenSubtitles, SubsWiki, Subtitulos, TheSubDB and TvSubtitles, so there are better chances for downloading working subtitles that match your video.
Subliminal uses video hashes and the "guessit" library to extract information from the filename / path to make sure the correct subtitles are downloaded. Further more, the tool uses a library called "enzyme" to detect embedded subtitles and avoid duplicates.
To install Subliminal in Ubuntu, use the following commands:
sudo apt-get install git-core python-pip sudo pip install beautifulsoup4 guessit requests enzyme html5lib lxml cd && git clone https://github.com/Diaoul/subliminal.git cd subliminal sudo python setup.py install
Now, to download subtitles, you can either use a file path, filename or folder path. Here's an example:
This will download the subtitle in the current folder, if you want to download them into the video folder "cd" to that directory firstly.
subliminal -l en The.Big.Bang.Theory.S05E18.HDTV.x264-LOL.mp4
"-l" sets the subtitle language, "en" (English) in the example above.
For more on how to use subliminal, run this command in a terminal:
Thanks to Tamps for the tip!