opensubtitles-client

opensubtitles API & command line subtitles downloader

npm install opensubtitles-client
6 downloads in the last day
47 downloads in the last week
228 downloads in the last month

NPM Opensubtitles package

Build Status Donate

Divhide

Install

After have installed node.js, run the following:

npm install opensubtitles-client -g

Command line

subtitler <file|directory|seachText> 
    --lang eng|pob|... 
    -n <numberOfSubtitlesToDownload> 
    --download 
    --retries <numberOfRetries> 
    --retryIn <secondsToRetry>

if a file or directory is provided -- download is activated by default

if free text is provided -- performs a query into opensubtitles with it!

--lang The language to search ( be sure to check here )

-n specifies the number of subtitles to list or download if (--download is specified)

--download Flag to download the results. The downloaded result will have the same same as the file if it can, working well with TV players, etc...

--retries The number of retries in API error

--retryIn The seconds to wait before the next retry

Languages

//Portuguese
-lang por 

//Brazilian
-lang pob 

//English
-lang eng

 //French
-lang fre

//Spanish
-lang spa

Check the languages table on here. Or the languages aliases on here.

Examples

Download subtitles for a file, automatically naming the subtitle file to be the same as the movie.

subtitler Cars.avi -lang eng

Search for subtitles (limit 5):

subtitler Cars -lang eng --n 5

Search and download to the current directory the first 5 subtitles:

subtitler Cars -lang eng -n 5 --download

Javascript API:

Login - get the login token from the opensubtitle service

opensubtitles.api.login()
    .done(function(token){
        // got the auth token
    });

Search - search for subtitles

opensubtitles.api.search(token, lang, text)
    .done(
        functions(results){
            //got the search results
        }
    );

Search - search subtitles for a movie file

opensubtitles.api.searchForFile(login, lang, movieFilePath);
    .done(
        functions(results){
            //got the search results
        }
    );

Logout - opensubtitles session logout ( please be nice! )

opensubtitles.api.logout(login);

Events

opensubtitles.api.on("login", functions(token){});
opensubtitles.api.on("search", functions(results){});
opensubtitles.api.on("error", functions(e){});

opensubtitles.downloader.on("downloading", function(info){});
opensubtitles.downloader.on("downloaded", function(info){});

Integration with rtorrent

After rtorrent download is finish you can automatically use subtitler to download it's subtitles. You just have to do the following:

On .rtorrent.rc add:

system.method.set_key =event.download.finished,move_complete,"execute=subtitler,$d.get_base_path="

This way the subtitler command will receive the downloaded path has argument and will try to download the subtitles.

Checkout my blogpost on:

Why this package was created!

Integration with Rtorrent

Visit www.divhide.com for more informations, contacts and news about Web Development.

See other blog posts at blog.divhide.com.

Thanks for all your code contributions!

Oscar Brito

npm loves you