Archive:Eden API changes

From Official Kodi Wiki
Revision as of 17:24, 17 April 2011 by >Theuni
Jump to navigation Jump to search

Eden will represent the first repository update, and as a result we have taken the opportunity to change the API for several subsystems. Any add-ons that are submitted for inclusion in Eden-pre and Eden will require compatibility with the new APIs.

The Eden-pre repository will be created soon, while the APIs may still change somewhat. When the APIs are frozen, the final Eden repository will open and final API compatibility will be enforced.

Be sure to read the Official Repository Guidlines before submitting a pull request.

Scripts and Plugins

XBMC now uses an external version of Python rather than a self-built one. This brings many benefits but means that some plugins/scripts will have to change slightly. In order to be considered for inclusion in the Eden repository, the following must be true.

  • The version of the xbmc.python api is now 1.9. Your script or plugin will be required to reflect this dependency before it will be accepted into the eden-pre repository. The final Eden api will be 2.0. Setting the xbmc.python api dependency greater than 1.0 triggers the enforcement of several deprecations. See the Backwards-compat section below.
  • You can no longer assume that "os.getcwd" will return the root directory of the add-on. In-fact, the usage of cwd is highly discouraged and may be deprecated all together in future releases.
  • Do not use 'special://' paths with os python module functionality (file or directory create/delete/access/read/write/stat/etc). You should translate any paths that may be prefixed this way using xbmc.translatePath(path) or use the new xbmcvfs module.
  • Newer python (2.5 and up) includes a sqlite module as part of the python distribution. You should import sqlite3 instead of the former use of pysqlite2. An acceptable import that will allow the same python code to work in both eden and previous versions would be:
try:
    from sqlite3 import dbapi2 as sqlite
    logFile.info("Loading sqlite3 as DB engine")
except:
    from pysqlite2 import dbapi2 as sqlite
    logFile.info("Loading pysqlite2 as DB engine")
  • Direct use of sqlite/mysql to access XBMC's databases is HIGHLY discouraged and may be rejected. Use a properly abstracted interface like JSONRPC instead.

Backwards Compatibility

If your add-on depends on xbmc.python version 1.0 or less, backwards-compatibly mode is enabled (note: as it says above, if this is the case it will not be accepted into the eden repository). This was done in an effort to try to keep out-of-date addons working.

Certain deprecated functions like os.getcwd() will produce a warning in backwards-compatibility mode, whereas they will fail outright otherwise. Add-ons with this enabled will not be accepted into the Eden repo, they should instead be updated.

Skins

For now, see the discussion on the forum. Docs coming soon.

JSON-RPC

This interface has been almost entirely redone for Eden, and is still a work in progress.

General changes (Implementation)

The whole implementation of the JSON-RPC server has been refactored to be compliant with the JSON-RPC 2.0 specification. These changes involve:

  • Client-side announcements (methods can be called without the "id" field which will result in the execution of the method without returning a response)
  • Bulk requests (multiple method calls can be sent as an array in a single json rpc request; all methods are executed and the response contains all responses of the bulk request in an array)
  • Default JSON output in compact format (Advanced Settings option to disable compact json output)
  • support for by-value OR by-position parameters
  • "params" must always be an array (by-position) or an object (by-value) but never a simple type

API changes

For now, see the discussion on the forum. Docs coming soon.

Scrapers

No major API changes at this time.