Forum rules
Under no circumstances is spamming or advertising of any kind allowed. Do not post any abusive, obscene, vulgar, slanderous, hateful, threatening, sexually-orientated or any other material that may violate others security. Profanity or any kind of insolent behavior to other members (regardless of rank) will not be tolerated. Remember, what you don’t find offensive can be offensive to other members. Please treat each other with the kind of reverence you’d expect from other members.
Failure to comply with any of the above will result in users being banned without notice. If any further details are needed, contact: “The team” using the link at the bottom of the forum page. Thank you.
watdafox
Posts: 27
Joined: Fri Aug 07, 2015 3:13 am

nodejs "opensubtitles-api" on NPM

Fri Oct 09, 2015 2:14 am

Hello all,

Just this little message to present you a node module I found for Opensubtitles, using Javascript. It's called "opensubtitles-api", and it's available:

- on https://www.npmjs.com/package/opensubtitles-api
- or

Code: Select all

npm install opensubtitles-api
It allows you to use all calls to OpenSubtitles, but has also some exciting features, as:
- Gather all data you have on a video-file and the module will send you the best matching subtitle.
- Upload a subtitle simply by giving the path to the video & to the subtitle (and IMDB if available)
- Calculate hash & moviebytesize

More features will come in the future. All of the calls are promises, and you can profit of both js Objects in responses and comprehensive debug error messages. But best of all, it's under GPL-3.0, so it's free & open-source.

If you have extra hands, come take a look at the source and help us develop this further.
Last edited by watdafox on Sun Nov 15, 2015 9:13 pm, edited 1 time in total.

User avatar
oss
Site Admin
Posts: 5884
Joined: Sat Feb 25, 2006 11:26 pm
Contact: Website

Re: Introducing Node.JS "opensubtitles-api" on NPM

Sat Oct 10, 2015 6:39 am

Thanks, I think it will be widely used. Just some notes:

Code: Select all

OpenSubtitles.search({ sublanguageid: 'fr', // Can be an array.join, 'all', or be omitted.
we are using 3 language codes, so instead 'fr' it is 'fre' - you can add link to http://www.loc.gov/standards/iso639-2/php/code_list.php - ISO 639-2 (plus some own codes, such POB and some for Chinese)

Also, please link to www.opensubtitles.org and specially to trac.opensubtitles.org - write in docs, users should register THEIR user agent first.

Would be also nice to have example how to get moviehash from commandline.

good work, I hope you will add some more methods, so we can make this as official Node.js wrapper

watdafox
Posts: 27
Joined: Fri Aug 07, 2015 3:13 am

Re: Introducing Node.JS "opensubtitles-api" on NPM

Sat Oct 10, 2015 7:30 pm

Thanks for the 3 letter thing, I must have missed it.

But everything else you say is already there:
- link to opensubtitles
- link to trac
- useragent needed notice
- example on moviehash
- all methods are already supported through the extended 'OpenSubtitles.api.<method>' call

User avatar
oss
Site Admin
Posts: 5884
Joined: Sat Feb 25, 2006 11:26 pm
Contact: Website

Re: Introducing Node.JS "opensubtitles-api" on NPM

Sun Oct 11, 2015 9:03 pm

you are right, now it looks much better.

Questions:

- can you change HTTP user agent ? If yes, please use as HTTP user agent your library name with version.
- for commandline usage, I was thinking in commandline (bash,sh...) something like:

Code: Select all

opensubtitles-api -h <path-to-file>
would print the hash for movie file for example.
- we support HTTPS on API, so you can optionally set it
- the best would be, if user can set the api server, such as 'https://api.opensubtitles.org/xml-rpc' - in that case, I can use it also locally for local devel server

I will add this lib to the http://trac.opensubtitles.org/projects/ ... msUsingAPI

watdafox
Posts: 27
Joined: Fri Aug 07, 2015 3:13 am

Re: Introducing Node.JS "opensubtitles-api" on NPM

Mon Oct 12, 2015 1:38 am

The http useragent is the one provided when requiring the module, as the docs on trac say.

HTTPS is waaaaay too slow. I've tested it and it was terrible. When it gets better, I'll remake it use https, it's an easy change.

An option to use your own endpoint could be added.
Last edited by watdafox on Sun Nov 15, 2015 9:13 pm, edited 1 time in total.

User avatar
oss
Site Admin
Posts: 5884
Joined: Sat Feb 25, 2006 11:26 pm
Contact: Website

Re: Introducing Node.JS "opensubtitles-api" on NPM

Mon Oct 12, 2015 9:15 am

OK, there are two user agents, one is HTTP (standard) useragent, and one is XML-RPC user agent.

Developers request XML-RPC UA, it would be good if you can set HTTP useragent to your library version. So it will be something like

HTTP UA: opensubtitles-api v1.2.0
XML-RPC UA: <requested UA by developer>

It is good in the future I can track also this, so I will know, they are using your lib.

CLI - OK.

HTTPS is slow ? Do you have some debug data for it ? So we can improve and set it up properly, if something is problem (didnt know)

Endpoint - great.

watdafox
Posts: 27
Joined: Fri Aug 07, 2015 3:13 am

Re: Introducing Node.JS "opensubtitles-api" on NPM

Mon Oct 12, 2015 10:28 pm

OK, there are two user agents, one is HTTP (standard) useragent, and one is XML-RPC user agent.

Developers request XML-RPC UA, it would be good if you can set HTTP useragent to your library version. So it will be something like

HTTP UA: opensubtitles-api v1.2.0
XML-RPC UA: <requested UA by developer>
Mmmmh, I didn't knew that. So the developper's UA is only used upon LogIn then? And all calls are made with HTTP UA? Just to confirm I understand correctly.
HTTPS is slow ? Do you have some debug data for it ? So we can improve and set it up properly, if something is problem (didnt know)
I don't, but I could try to generate some. Thing is it was working great with the 1st implementation of HTTPS, then a few days later, it was really slow (I don't remember specifics... maybe it even timed out or so). So it was changed back to HTTP and it was working again.
Last edited by watdafox on Sun Nov 15, 2015 9:14 pm, edited 2 times in total.

User avatar
oss
Site Admin
Posts: 5884
Joined: Sat Feb 25, 2006 11:26 pm
Contact: Website

Re: Introducing Node.JS "opensubtitles-api" on NPM

Tue Oct 13, 2015 7:04 am

Hi,

yes, HTTP user agent is basically ignored and it can be set to whatever string, it is not used - so in this situations, it is great to set it up to library/wrapper version and then users of wrapper just set own UA with us. Then we can see what exactly is going on (they are using their UA, but code is based on your wrapper). When LogIn is made, UA is stored in session, so with others methods, where is used Token, we know it is that UA...

HTTPS - please try.

Javascript people - currently no JS people :)

watdafox
Posts: 27
Joined: Fri Aug 07, 2015 3:13 am

Re: Introducing Node.JS "opensubtitles-api" on NPM

Tue Oct 13, 2015 9:06 pm

- custom endpoint added (defaults to http://api.opensubtitles.org:80/xml-rpc)
- UA added
- added test for calls

Here's the results of the tests, case is "search https + search http for TBBT 1x01 all langs" (should be 161 results in 32langs):

Code: Select all

1: https: 2182ms http: 1033ms 2: https: 1396ms http: 1028ms 3: https: 1610ms http: 1150ms 4: https: 1452ms http: 1126ms 5: ERROR: Unknown XML-RPC tag 'TITLE' 6: https: 1367ms http: 1050ms
The milliseconds are calculated before each search and after response is recieved.
Notice the Error, it happens about 1 every 20 requests in my tests.

Https is slower but I haven't encountered "so slow it's unusable" speeds like I had about a month ago.
Last edited by watdafox on Sun Nov 15, 2015 9:15 pm, edited 1 time in total.

User avatar
oss
Site Admin
Posts: 5884
Joined: Sat Feb 25, 2006 11:26 pm
Contact: Website

Re: Introducing Node.JS "opensubtitles-api" on NPM

Wed Oct 14, 2015 6:48 am

- endpoint - coool, exactly should be like that
- UA - great
- HTTPS - yeah first call (1) is quite slow, I think it is because SSL handshake ? - others are quite OK in my option, so make it default to HTTP, but possible to change to HTTPS (using endpoint config)
- when you get (5) what is HTTP STATUS and content ?

watdafox
Posts: 27
Joined: Fri Aug 07, 2015 3:13 am

Re: Introducing Node.JS "opensubtitles-api" on NPM

Wed Oct 14, 2015 5:23 pm

I have been unable to reproduce the error today on more than 100 tests (~300 calls).

I had another error, that doesn't seem to prevent the fetch anyway:
Status is: 200 - OK
Content: "Invalid XML-RPC message"
Body: http://hastebin.com/napabozube.xml (yes, that is the end of the response)

But if I recall correctly, the error "invalid tag 'TITLE" happens when the response is something about VARNISH CACHE SERVER (Guru Mediation). I believe it's the XMLRPC module unable to read the error, maybe your answer to say there's somehting wrong with cache is full HTML instead of XML.

User avatar
oss
Site Admin
Posts: 5884
Joined: Sat Feb 25, 2006 11:26 pm
Contact: Website

Re: Introducing Node.JS "opensubtitles-api" on NPM

Wed Oct 14, 2015 9:21 pm

Yeah Varnish Guru is when something is really wrong, dont have much control about that.

That other response, it stops in the middle, it is like connection was reset, strange also.

Return to “Developing”

Who is online

Users browsing this forum: No registered users and 4 guests