3

I am creating a software for downloading movie subtitles using OpenSubtitle API in Python.

The API implements XML-RPC protocol. According to API documentation, to download a subtitle from site database, the following method is used:

array DownloadSubtitles( $token, array($IDSubtitleFile, $IDSubtitleFile,...) )

Its output is:

[data] => Array
    (
        [0] => Array
            (
                [idsubtitlefile] => 10
                [data] => MQ0KMDA6MDA6MzgsMzAwIC0tPiAwMDowMDo0MSwwMDA...
            )
        [1] => Array
            (
                [idsubtitlefile] => 20
                [data] => MQ0KMDA6MDA6MjYsMjgzIC0tPiAwMD...
            )

Where [idsubtitlefile] is subtitle_id and [data] is subtitle byte in base64 and gzip form.

The problems I am facing is, whenever I download a subtitle:

idsubtitlefile='513de0ea27d63b9d631d769a492d72dc'
token='a1t49trievitmjda4ija7dif44'
xmlrpclib.DownloadSubtitles(token,[(idsubtitlefile)] )

I get a result like this:

[{'data': 'H4sIAAAAAAAAAwMAAAAAAAAAAAA=',\      
   'idsubtitlefile':'513de0ea27d63b9d631d769a492d72dc'}] 

Here, the data value is supposed to be base64 encoded binary subtitle data, but how can so little data be the subtitle.

I think somehow the data has to be download from server in chunks, or perhaps I am missing something.

1
  • 1
    The response you received is essentially a compressed empty file. I wouldn't expect there to be any more chunks, both from the response you received nor the API documentation. Commented Jan 12, 2014 at 13:00

1 Answer 1

3
+25

Just to amplify @Martijn's comment a little - the response is indeed an empty file, which you can verify using code like this:

>>> raw = 'H4sIAAAAAAAAAwMAAAAAAAAAAAA='
>>> import base64
>>> decoded = base64.b64decode(raw)
>>> import zlib
>>> decompressed_data=zlib.decompress(decoded, 16+zlib.MAX_WBITS)
>>> print decompressed_data

>>> len(decompressed_data)
0

There is nothing to suggest anything more is required of you based on the API doc. Can you retry with an example that is known to have a subtitle? Are you checking for errors? http://trac.opensubtitles.org/projects/opensubtitles/wiki/XmlRpcStatusCode

EDIT: There are some open source Python API users listed here in case they are helpful: http://trac.opensubtitles.org/projects/opensubtitles/wiki/ProgramsUsingAPI

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.