Changes between Initial Version and Version 1 of XMLRPC


Ignore:
Timestamp:
Jul 14, 2008, 8:06:44 AM (16 years ago)
Author:
os
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • XMLRPC

    v1 v1  
     1= Introduction to OSDb =
     2[[PageOutline(2, XMLRPC API Methods)]]
     3[[PageOutline(1, Table of Contents)]]
     4
     5
     6We decided use [http://www.xmlrpc.com/ XMLRPC] (see [http://www.xmlrpc.com/spec spec] and [http://www.xmlrpc.com/directory/1568/implementations imeplementations]) as default API for [http://www.opensubtitles.org opensubtitles.org]. It supports many methods, so there should not be a problem code some nice applications and services.
     7
     8[http://en.wikipedia.org/wiki/XML-RPC Wikipedia]:
     9XML-RPC is a very simple protocol, defining only a handful of data types and commands, and the entire description can be printed on two pages of paper. This is in stark contrast to most RPC systems, where the standards documents often run into the hundreds of pages and require considerable software support in order to be used.
     10
     11= Instructions =
     12
     13 * All developing tests do on: http://dev.opensubtitles.org/xml-rpc
     14 * Main server is: http://www.opensubtitles.org/xml-rpc
     15 * Before developing and if you use this API let us know, we assign useragent to you, empty useragent will not work
     16 * If you use language, check [http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes ISO639], use '''pb/pob''' for Portuguese (Brazil) - [http://www.opensubtitles.org/addons/export_languages.php Download OS languages table dump]
     17
     18= XMLRPC methods =
     19
     20== !ServerInfo ==
     21'''array !ServerInfo( )'''
     22This simple function returns basic server info, it could be used for ping or telling server info to client.
     23
     24Example output:
     25{{{
     26subs_downloads : 66149885
     27movies_aka : 58111
     28users_loggedin : 30
     29users_online_program : 184
     30seconds : 0.007
     31users_max_alltime : 2163
     32xmlrpc_version : 0.1
     33movies_total : 34628
     34total_subtitles_languages : 50
     35application : OpenSuber v0.2
     36contact : admin@opensubtitles.org
     37last_update_strings : {'el': '2007-02-03 21:36:17', 'en': '2007-02-03 21:36:14', ... }
     38users_online_total : 1271
     39xmlrpc_url : http://www.opensubtitles.com/xml-rpc
     40users_registered : 421100
     41subs_subtitle_files : 558001
     42website_url : http://www.opensubtitles.com
     43}}}
     44
     45'''Fields explanation:'''
     46All field are self-explained
     47
     48----
     49
     50== !LogIn ==
     51'''array !LogIn( $username, $password, $language, $useragent )'''
     52This will login user. This function should be called always when starting talking with server. It returns '''token''', which must be used in later communication. If user has no account, blank username and password should be OK. As language - use [http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes ISO639] 2 letter code and later communication will be done in this language if applicable (error codes and so on). Note: when username and password is blank, status is 200 OK, because we want allow anonymous users too. Useragent cannot be empty string.
     53
     54Example output:
     55{{{
     56   [token] => c8af602fe83c5404966c25da33d8bbaf
     57   [status] => 200 OK
     58   [seconds] => 0.338
     59}}}
     60
     61'''Fields explanation:'''
     62 * token => this token string (session id) must be used in later communication
     63 * status => status code
     64 * seconds => how long time takes this process on server
     65
     66----
     67
     68== !LogOut ==
     69'''string !LogOut( $token )'''
     70This will logout user (ends session id). Good call this function is before ending (closing) clients program.
     71
     72Example output:
     73{{{
     74    [status] => 200 OK
     75    [seconds] => 0.055
     76}}}
     77
     78'''Fields explanation:'''
     79All field are self-explained
     80
     81----
     82
     83== !SearchSubtitles ==
     84'''array !SearchSubtitles( $token, array(array('sublanguageid' => $sublanguageid, 'moviehash' => $moviehash, 'moviebytesize' => $moviesize, ''imdbid => $imdbid'' ),array(...)))'''
     85
     86This function returns information about found subtitles. It is designed making multiple search at once. Note - result is always grupped by !MovieHash, !MovieByteSize, !SubLanguageID, !IDSubMovieFile, sorted by seencount descending, max results is 250. When nothing is found, 'data' is empty. If sublanguageid is empty, or have value 'all' - it search in every sublanguage. Also, imdbid parameter is '''optional''', when used, it is not needed define moviehash and moviebytesize, so you can search subtitle database with imdbid only. Also remember you can not combine imdbid and moviehash searching in one request. Some data (!IDSubMovieFile, !MovieHash, !MovieByteSize, !MovieTimeMS) are missing in output when searching by imdbid.
     87
     88Example output:
     89{{{
     90    [data] => Array
     91        (
     92            [0] => Array
     93                (
     94                    [IDSubMovieFile] => 739
     95                    [MovieHash] => 09a2c497663259cb
     96                    [MovieByteSize] => 733589504
     97                    [MovieTimeMS] => 0
     98                    [MovieFrames] => 0
     99                    [IDSubtitleFile] => 963
     100                    [SubFileName] => Night Watch (Nochnoj Dozor) (2004) [1 of 2].srt
     101                    [SubActualCD] => 1
     102                    [SubSize] => 30677
     103                    [SubHash] => 6c2bdbb308760205146cb2807dfc32f6
     104                    [IDSubtitle] => 771
     105                    [UserID] => 37047
     106                    [SubLanguageID] => eng
     107                    [SubFormat] => srt
     108                    [SubSumCD] => 2
     109                    [SubAuthorComment] =>
     110                    [SubAddDate] => 2005-05-23 07:47:04
     111                    [SubBad] => 0
     112                    [SubRating] => 0.0
     113                    [SubDownloadsCnt] => 315
     114                    [MovieReleaseName] => AxxO
     115                    [IDMovie] => 516
     116                    [IDMovieImdb] => 403358
     117                    [MovieName] => Nochnoy dozor
     118                    [MovieNameEng] => Night Watch
     119                    [MovieYear] => 2004
     120                    [MovieImdbRating] => 6.3
     121                    [UserNickName] => onefox
     122                    [ISO639] => en
     123                    [LanguageName] => English
     124                    [SubDownloadLink] => http://www.opensubtitles.org/download/file/963.gz
     125                    [ZipDownloadLink] => http://www.opensubtitles.org/en/download/sub/771
     126                )
     127            [1] => Array
     128                (
     129                    [IDSubMovieFile] => 740
     130                    [MovieHash] => 1dab7c63893d0d81
     131                    [MovieByteSize] => 733919232
     132                    [MovieTimeMS] => 0
     133                    [MovieFrames] => 0
     134                    [IDSubtitleFile] => 964
     135                    [SubFileName] => Night Watch (Nochnoj Dozor) (2004) [2 of 2].srt
     136                    [SubActualCD] => 2
     137                    [SubSize] => 39074
     138                    [SubHash] => 021d7bf5480f97d8e0a28f0b0f03b28d
     139                    [IDSubtitle] => 771
     140                    [UserID] => 37047
     141                    [SubLanguageID] => eng
     142                    [SubFormat] => srt
     143                    [SubSumCD] => 2
     144                    [SubAuthorComment] =>
     145                    [SubAddDate] => 2005-05-23 07:47:04
     146                    [SubBad] => 0
     147                    [SubRating] => 0.0
     148                    [SubDownloadsCnt] => 315
     149                    [MovieReleaseName] => Diamond
     150                    [IDMovie] => 516
     151                    [IDMovieImdb] => 403358
     152                    [MovieName] => Nochnoy dozor
     153                    [MovieNameEng] => Night Watch
     154                    [MovieYear] => 2004
     155                    [MovieImdbRating] => 6.3
     156                    [UserNickName] => onefox
     157                    [ISO639] => en
     158                    [LanguageName] => English
     159                    [SubDownloadLink] => http://www.opensubtitles.org/download/file/964.gz
     160                    [ZipDownloadLink] => http://www.opensubtitles.org/en/download/sub/771
     161                )
     162        )
     163    [seconds] => 2.378
     164}}}
     165
     166'''Fields explanation:'''
     167All field are self-explained. Note: it returns array with two keys. In first key is array of arrays of found subtitles, in second key is number of seconds as usual.
     168
     169'''NOTE''' The field '!MovieFrames' isn't being send from the server. Make this field optional or just remove it.
     170
     171----
     172
     173== !SearchToMail ==
     174'''array !SearchToMail( $token, array( $sublanguageid, $sublanguageid, ...), array( array( 'moviehash' => $moviehash, 'moviesize' => $moviesize), array( 'moviehash' => $moviehash, 'moviesize' => $moviesize), ...) )''''
     175
     176This is possible only for logged-in users. Scenario: user have directory with movies, for which he cannot find subtitles. With this function he subscribe to possible results, when someone else will upload matching subtitles. Once a day (or week...based on users profile) will system send subtitle link by mail to user. *Note for developers*: if it is possible, send moviehashes and moviesizes only for first CD in set (for example movie on two CDs), because users will receive duplicated mails (one for first cd and one for second cd)
     177
     178Example output:
     179{{{
     180    [status] => 200 OK
     181    [seconds] => 1.211
     182}}}
     183
     184'''Fields explanation:'''
     185if no '''sublanguageid''' is given (first array is empty), it means system will try to find subtitles in all languages.
     186
     187----
     188
     189== !CheckSubHash ==
     190'''array !CheckSubHash( $token, array($subhash, $subhash, ...) )'''
     191
     192This method returns !IDSubtitleFile, if Subtitle Hash exists in database. If not exists, it returns '0'.
     193
     194Example output:
     195{{{
     196    [status] => 200 OK
     197    [data] => Array
     198        (
     199            [a9672c89bc3f5438f820f06bab708067] => 1
     200            [0ca1f1e42cfb58c1345e149f98ac3aec] => 3
     201            [11111111111111111111111111111111] => 0
     202        )
     203    [seconds] => 0.009
     204}}}
     205
     206'''Fields explanation:'''
     207Array in data contains $subhash => $idsubtitlefile
     208
     209----
     210
     211== !CheckMovieHash ==
     212'''array !CheckMovieHash( $token, array($moviehash, $moviehash, ...) )'''
     213
     214This method returns !MovieImdbID, !MovieName, !MovieYear, if available for each $moviehash.
     215
     216Example output:
     217{{{
     218    [data] => Array
     219        (
     220            [dab462412773581c] => Array
     221                (
     222                    [MovieImdbID] => 133152
     223                    [MovieName] => Planet of the Apes
     224                    [MovieYear] => 2001
     225                )
     226            [ae34f157eefc093c] => Array
     227                (
     228                    [MovieImdbID] => 288477
     229                    [MovieName] => Ghost Ship
     230                    [MovieYear] => 2002
     231                )
     232            [abcdefg123211222] => Array
     233                (
     234                )
     235        )
     236    [seconds] => 0.046
     237}}}
     238
     239'''Fields explanation:'''
     240Array in data contains $moviehash => array()
     241
     242----
     243
     244== !TryUploadSubtitles ==
     245'''array !TryUploadSubtitles( $token, array('cd1' => array('subhash' => $submd5hash, 'subfilename' => $subfilename, 'moviehash' => $moviehash, 'moviebytesize' => $moviesize, 'movietimems' => $movietimems, 'movieframes' => $movieframes, 'moviefps' => $moviefps, 'moviefilename' => $moviefilename), 'cd2' => array(...) ) )'''
     246
     247This function needs to be called '''before''' !UploadSubtitles(), because it is possible subtitles already exists on server. It takes 2 parameters, second parameter is array of information for subtitles to be uploaded, minimum cd1 is required. Mandatory fields are: subhash (md5 of subtitles), subfilename, [wiki:HashSourceCodes moviehash], moviebytesize, moviefilename. It returns "alreadyindb" when subtitles already exists in database. When they do not exists, !SearchSubtitles() is called, and API is looking for existing subtitles based on !MovieHash/!MovieSize. If some results are found, information is returned in "data" key as !SearchSubtitles() return structure. This is good for uploading - user should have imdbid field already filled.
     248
     249
     250Example output when '''subtitles already exists''' in database:
     251{{{
     252    [alreadyindb] => 1
     253    [data] => Array
     254        (
     255            [IDSubtitle] => 1
     256            [SubLanguageID] => eng
     257            [IDMovieImdb] => 103644
     258            [MovieName] => AlienÂł
     259            [MovieYear] => 1992
     260            [MoviefilenameWasAlreadyInDb] => 0
     261            [HashWasAlreadyInDb] => 1
     262        )
     263    [seconds] => 0.078
     264}}}
     265
     266'''!MoviefilenameWasAlreadyInDb''' - if 0, it means new moviefilename was inserted to database. '''!HashWasAlreadyInDb''' - if 0, it means new !MovieHash was inserted to database.
     267
     268Example output when '''subtitles are not''' in database:
     269{{{
     270(moviesize and moviehash exists in db, but not subhash, on client side should be filled !IDMovieImdb from this info)
     271    [alreadyindb] => 0
     272    [data] => Array
     273        (
     274            [0] => Array
     275                (
     276                    [IDSubMovieFile] => 739
     277                    [MovieHash] => 09a2c497663259cb
     278                    [MovieByteSize] => 733589504
     279                    [MovieTimeMS] => 0
     280                    [MovieFrames] => 0
     281                    [IDSubtitleFile] => 963
     282                    [SubFileName] => Night Watch (Nochnoj Dozor) (2004) [1 of 2].srt
     283                    [SubActualCD] => 1
     284                    [SubSize] => 30677
     285                    [SubHash] => 6c2bdbb308760205146cb2807dfc32f6
     286                    [IDSubtitle] => 771
     287                    [UserID] => 37047
     288                    [SubLanguageID] => eng
     289                    [SubFormat] => srt
     290                    [SubSumCD] => 2
     291                    [SubAuthorComment] =>
     292                    [SubAddDate] => 2005-05-23 07:47:04
     293                    [SubBad] => 0
     294                    [SubRating] => 0.0
     295                    [SubDownloadsCnt] => 315
     296                    [IDMovie] => 516
     297                    [IDMovieImdb] => 403358
     298                    [MovieName] => Nochnoy dozor
     299                    [MovieNameEng] => Night Watch
     300                    [MovieYear] => 2004
     301                    [MovieImdbRating] => 6.3
     302                    [UserNickName] => onefox
     303                    [ISO639] => en
     304                    [LanguageName] => English
     305                    [SubDownloadLink] => http://www.opensubtitles.org/en/download/file/963.gz
     306                )
     307        )
     308    [seconds] => 0.132
     309}}}
     310
     311'''Fields explanation:'''
     312All field are self-explained.
     313
     314----
     315
     316== !UploadSubtitles ==
     317'''array !UploadSubtitles( $token,array( 'baseinfo' => array ( 'idmovieimdb' => $idmovieimdb, 'moviereleasename' => $scene_releasename, 'movieaka' => $aka_in_subtitle_language, 'sublanguageid' => $sublanguageid, 'subauthorcomment' => $author_comment ), 'cd1' => array( 'subhash' => $md5subhash, 'subfilename' => $subfilename, 'moviehash' => $moviehash, 'moviebytesize' => $moviebytesize, 'movietimems' => $movietimems, 'moviefps' => $moviefps, 'movieframes' => $movieframes, 'moviefilename' => $moviefilename, 'subcontent' => $subtitlecontent ), 'cd2' => array (...) ) )'''
     318
     319This function have to be called after !TryUploadSubtitles(). Many information are same, important part is '''subcontent'''. It should be gzip-ed (without header) and must be base64 encoded.
     320
     321Example output:
     322{{{
     323    [status] => 200 OK
     324    [data] => http://www.opensubtitles.org/subtitles/123456
     325    [seconds] => 1.171
     326}}}
     327
     328'''Fields explanation:'''
     329data is absolute link to subtitles.
     330
     331----
     332
     333== !DownloadSubtitles ==
     334'''array !DownloadSubtitles( $token, array($IDSubtitleFile, $IDSubtitleFile,...) )'''
     335
     336Returns BASE64 encoded gzipped !IDSubtitleFile(s). You need to BASE64 decode and ungzip 'data' to get its contents.
     337
     338Example output:
     339{{{
     340    [status] => 200 OK
     341    [data] => Array
     342        (
     343            [0] => Array
     344                (
     345                    [idsubtitlefile] => 10
     346                    [data] => MQ0KMDA6MDA6MzgsMzAwIC0tPiAwMDowMDo0MSwwMDA...
     347                )
     348            [1] => Array
     349                (
     350                    [idsubtitlefile] => 20
     351                    [data] => MQ0KMDA6MDA6MjYsMjgzIC0tPiAwMD...
     352                )
     353    [seconds] => 0.397
     354}}}
     355
     356'''Fields explanation:'''
     357All field are self-explained.
     358
     359----
     360
     361== !ReportWrongMovieHash ==
     362'''array !ReportWrongMovieHash( $token, $IDSubMovieFile )'''
     363
     364This method is needed to report bad hash, e.g. subtitles are right for this movie file, but they are de-synchornized - for other version/release. With this method number of reports is counted in db, and after some number, hash will be automatically deleted from database.
     365
     366Example output:
     367{{{
     368    [status] => 200 OK
     369    [seconds] => 0.115
     370}}}
     371
     372'''Fields explanation:'''
     373All field are self-explained.
     374
     375
     376== !GetSubLanguages ==
     377'''array !GetSubLanguages( $language = 'en' )'''
     378
     379Returns list of allowed subtitle languages, default is english language. Use [http://www.loc.gov/standards/iso639-2/php/code_list.php ISO639-1] (2 characters code)
     380
     381Example output:
     382{{{
     383    [data] => Array
     384        (
     385            [0] => Array
     386                (
     387                    [SubLanguageID] => alb
     388                    [LanguageName] => Albanian
     389                    [ISO639] => sq
     390                )
     391            [1] => Array
     392                (
     393                    [SubLanguageID] => ara
     394                    [LanguageName] => Arabic
     395                    [ISO639] => ar
     396                )
     397            ...
     398    [seconds] => 0.043
     399}}}
     400
     401'''Fields explanation:'''
     402data - array of enabled subtitle languages. !SubLanguageID - iso639-2 3 characters code of language. !LanguageName - translated language name. ISO639 - ISO639-1 2 characters code.
     403
     404== !GetAvailableTranslations ==
     405'''array !GetAvailableTranslations( $token, $program )'''
     406
     407Returns array of available translations for a program. In array you can find date of last created string and number of strings. Current supported programs are 'subdownloader' and 'oscar'
     408
     409Example output:
     410{{{
     411    [status] => 200 OK
     412    [data] => Array
     413        (
     414            [en] => Array
     415                (
     416                    [LastCreated] => 2007-02-03 21:36:14
     417                    [StringsNo] => 438
     418                )
     419            [ar] => Array
     420                (
     421                    [LastCreated] => 2007-02-26 11:32:20
     422                    [StringsNo] => 438
     423                )
     424            ...
     425    [seconds] => 0.486
     426}}}
     427 
     428'''Fields explanation:'''
     429All field are self-explained.
     430
     431----
     432
     433== !GetTranslation ==
     434'''array !GetTranslation( $token, $iso639, $format, $program )'''
     435
     436Returns base64 encoded strings for language ($iso639) in some $format (mo, po, txt, xml). Use [http://www.loc.gov/standards/iso639-2/php/code_list.php ISO639-1] (2 characters code), $program should be 'subdownloader' or 'oscar'
     437
     438Example output:
     439{{{
     440    [status] => 200 OK
     441    [data] => bXNnaWQgIiINCm1zZ3N0ciAiIg0KIlByb2plY3QtSWQtVmVyc2lvbjogT3BlblN1YnRp...
     442    [seconds] => 0.192
     443}}}
     444 
     445'''Fields explanation:'''
     446data - base64 encoded contents
     447
     448== SearchMoviesOnIMDB ==
     449'''array SearchMoviesOnIMDB( $token, $query )'''
     450
     451Returns array of movies, which was found on imdb.com, query is first fixed for some strings (deleted dvdrip and so on)
     452
     453Example output for 'troy':
     454{{{
     455    [status] => 200 OK
     456    [data] => Array
     457        (
     458            [0] => Array
     459                (
     460                    [id] => 0332452
     461                    [title] => Troy (2004)
     462                )
     463
     464            [1] => Array
     465                (
     466                    [id] => 0340477
     467                    [title] => Helen of Troy (2003) (TV)
     468                )
     469            ...
     470    [seconds] => 0.441
     471}}}
     472 
     473'''Fields explanation:'''
     474title - title of movie, id - imdbid
     475
     476
     477== GetIMDBMovieDetails ==
     478'''array GetIMDBMovieDetails( $token, $imdbid )'''
     479
     480Returns array, info for $imdbid from [http://www.imdb.com www.imdb.com].
     481
     482Example output for '0480011':
     483{{{
     484    [status] => 200 OK
     485    [data] => Array
     486       (
     487            [cast] => Array
     488                (
     489                    [_0000096] => Gillian Anderson
     490                    [_0245705] => Danny Dyer
     491                    ...
     492                )
     493            [rating] => 5.9
     494            [cover] => http://ia.imdb.com/media/imdb/01/I/48/24/52/10m.jpg
     495            [id] => 0480011
     496            [votes] => 919
     497            [title] => Straightheads
     498            [aka] => Array
     499                (
     500                    [0] => Closure (USA) (DVD title)
     501                )
     502
     503            [year] => 2007           
     504            ...
     505       )
     506    [seconds] => 0.441
     507}}}
     508 
     509'''Fields explanation:'''
     510All fields are self-explained.
     511
     512
     513== !AutoUpdate ==
     514'''array !AutoUpdate ( $program_name )'''
     515
     516This function returns latest version with info for $program_name
     517
     518Example output:
     519{{{
     520    [version] => 1.2.3
     521    [url_windows] => http://forja.rediris.es/frs/download.php/123/subdownloader1.2.3.exe
     522    [url_linux] => http://forja.rediris.es/frs/download.php/124/SubDownloader1.2.3.src.zip
     523    [comments] => MultiUpload CDs supported(more than 2CDs)|Lots of bugs fixed
     524    [status] => 200 OK
     525
     526If $program_name is invalid it returns:
     527    [status] => 408 Invalid parameters
     528}}}
     529
     530'''Fields explanation:'''
     531All field are self-explained.
     532
     533== !NoOperation ==
     534'''array !NoOperation( $token )'''
     535
     536This function should be called each 15 minutes after last request to xmlrpc. It is used for not expiring current session. It also returns if current $token is registered.
     537
     538Example output when token is registered:
     539{{{
     540    [status] => 200 OK
     541    [seconds] => 0.055
     542}}}
     543When it is not registered, in client should be called !LogIn() again. Example of response:
     544{{{
     545    [status] => 406 No session
     546    [seconds] => 0.061
     547}}}
     548
     549'''Fields explanation:'''
     550All field are self-explained.
     551
     552----
     553
     554= Status codes =
     555
     556'''Successful 2xx'''
     557 * 200 OK
     558 * 206 Partial content; message
     559
     560'''Errors 4xx'''
     561 * 401 Unauthorized
     562 * 402 Subtitles has invalid format
     563 * 403 !SubHashes (content and sent subhash) are not same!
     564 * 404 Subtitles has invalid language!
     565 * 405 Not all mandatory parameters was specified
     566 * 406 No session
     567 * 407 Download limit reached
     568 * 408 Invalid parameters
     569 * 409 Method not found
     570 * 410 Other or unknown error
     571 * 411 Empty or invalid useragent