vankasteelj / opensubtitles-api

nodejs opensubtitles.org api wrapper for downloading and uploading subtitles in multiple langs
110 stars 33 forks source link

SearchSubtitles protocol changed? #34

Closed corwin-of-amber closed 6 years ago

corwin-of-amber commented 6 years ago

Searching used to work flawlessly until yesterday. Then I debugged it a little and found that the response data returned from OS.SearchSubtitles (invoked in index.js:86) is no longer an array; instead it is an object with keys '0', '1', etc.

As a result, no subtitles are ever returned by OpenSubtitles.search. This is visible when observing the value returned at tests.js:34.

I am using xmlrpc@1.3.2, which seems to have not changed for two years.

When I change index.js:86 to (notice Object.values near the end of the line):

  return this.api.SearchSubtitles(this.credentials.status.token, [op]).then(result => subs = subs.concat(Object.values(result.data)))

Then everything works well again.

DONSA commented 6 years ago

I've just found the same problem too. Will you create a pull request? Do you want me to do it?

corwin-of-amber commented 6 years ago

I am really wondering what changed though? Because according to the OpenSubtitles documentation it should return an "array" element in the XML-RPC response: http://trac.opensubtitles.org/projects/opensubtitles/wiki/XmlRpcSearchSubtitles

What if this is a temporary bug in the OpenSubtitles API service?

Anyway, I think it is a bit of an overkill to make a fork just for this one line temporary-or-not fix. It's all yours :)

corwin-of-amber commented 6 years ago

I looked into the XML that is returned from SearchSubtitles and I can confirm that it is now a <struct> rather than an <array>:

<?xml version="1.0" encoding="utf-8"?>
<methodResponse>
   <params>
      <param>
        <value>
          <struct>
             <member><name>status</name><value><string>200 OK</string></value></member>
             <member>
               <name>data</name>
               <value>
                 <struct>        <!-- here -->
                   <member>
                     <name>13</name>
                     <value>
                       <struct>
                         <member>
                           <name>MatchedBy</name>
                           <value><string>moviehash</string></value></member>
...
vankasteelj commented 6 years ago

If it's undocumented, it stinks. I'll email Opensubtitles to make sure the change is permanent. Thanks :)

opensubtitles commented 6 years ago

it was error from our side, sorry for that. We tried to sort accordind SCORE DESC, but it keeps indexes. Fixed.

vankasteelj commented 6 years ago

There you have it, thank you all :)