Kodi Add-ons are extensions that can be run from inside the Kodi GUI.
They are usually written by third party developers and, if the add-on does not breach any rules or policies for inclusion into the official Kodi repository, it can published to our official repository if submitted by the add-on developer. Add-ons can also be published in other repositories or as stand alone zip files anywhere on the internet. Examples of Add-ons include video website streams, scrapers, skins and scripts.
Kodi Add-ons are typically written in python. There are also binary addons used for applications like PVR, Inputstreams, AudioEncoders, Screensavers etc.
Each time a new version of Kodi is released we add new features which may lead to a break compatibility. It is up to the author to update their add-on to remain compatible.
Add-on system (v19+ Matrix)
Add-ons are of three types:
- System add-ons - Installed by kodi, add-ons of this type can only ever be updated by the system.
- Official repository add-ons - Add-ons contained in the official kodi repository. This repository list is compiled into Kodi.
- Private repository add-ons - Add-ons loaded from a private repository. In order to be able to install private repositories and add-ons the setting System->Add-ons->Unknown Sources must be enabled.
By default Official repository add-ons will only auto update from the official repositories. In the case of beta repos the setting System->Add-ons->Update official add-ons from must be set to Any repositories to allow an official add-on to be auto updated to a later version from a private repository.
Add-ons installed from private repositories can only be auto updated from their own repository, or from an official repository. If the same add-on is contained in two different private repositories and the version installed is from one of those repositories the only way to install the other version is via the Update button in the add-on info UI.
Addon system using python
Kodi includes a built-in Python interpreter that allows users to develop add-ons (scripts and plugins) that interface easily and cleanly with the Kodi dashboard. These add-ons can extend the functionality of Kodi without requiring extensive programming experience or ability. While you may not feel comfortable browsing the Kodi source code and submitting patches (or even bug reports), you can learn how to write a script or plugin with just a few hours' practice, using the information available in these pages.
This page is intended as an introduction to Kodi Python for new developers, and a quick reference for more experienced programmers. If you're not interested in programming, you might want to visit this page for information about installing and using Python add-ons as an end user.
The very latest Kodi python API documentation "PyDocs" with classes and functions is automatically generated from XBMC's source code and can be found here (not all functions are available in previous versions): https://codedocs.xyz/xbmc/xbmc/group__python.html (for Kodi 17.x Krypton and onwards)
Python plugins versus scripts
Please do not confuse "Plugins" and "Scripts". It is very important to understand the difference between them before you start coding your addon. Unlike Scripts (which can basically perform any action), Plugins do not really provide new functionality to Kodi, instead what they do is provide a directory listing (for instance, like your movie library) to Kodi. This listing can contain folders as well as files. When a user clicks on a folder, kodi will run the plugin again to retrieve another listing. If a file is clicked, kodi will either play the file directly or call the addon to retrieve a playable url.
Another difference is that scripts can create their own gui (skin) while plugins can't. Plugin listings are presented in the current skin.
Do not try to mix and match script and plugin functionality as that will only give you weird error messages.
If you're new to Python programming (or just new to Kodi Python), the easiest way to get started is with a script. The traditional Hello World program, written as an Kodi Python script, would look like this:
That's the same code you would enter at the Python command line, because Kodi runs a full-featured, standard Python interpreter (for more information concerning the current version number and included modules see the environment details below). If you're already familiar with Python programming, the only new challenge is learning the custom modules that allow you to gather information from Kodi and manipulate the Graphical User Interface (GUI).
There are some excellent tutorials available to introduce you to Kodi scripting (and Python in general).
While scripts offer you flexibility and full control over the Kodi GUI, plugins allow you to quickly and consistently present information to the user through the standard Kodi menu structure.
When a user launches a plugin, the plugin generates a list of menu items and hands them to Kodi to draw on the screen (regardless of screen resolution, skin, or any other user setting). While plugin developers lose some amount of control over the presentation, they no longer have to make up their own UIs, or worry about creating a usable look and feel across multiple displays.
Plugins are most commonly used to scrape websites for links to streaming videos, displaying the video list in Kodi just like it would movie files on the local hard drive.
While the three custom libraries give you control over the Kodi GUI, you'll eventually want to be able to interact with other parts of the system. Much of Kodi's functionality is exposed to Python, one way or another. These are some of the systems you can use to make your Python add-ons more useful.
A must read for developers is style guide for writing python. This contains the do's and dont's when starting to write code.
List of built-in functions
You can call any of the Kodi Built-in Commands using the function xbmc.executebuiltin().
Kodi databases (media metadata libraries)
Kodi uses Music and Video Libraries, stored in a SQL (SQLite) database, to store massive amounts of additional meta data concerning local media files (assuming the user has enabled the libraries and chosen the right Content and scraper for each of his sources). Although there's no direct access from Python to the Kodi Database, you can gain access to the databases from Python through the JSON-RPC_API. Read more about that here.
Kodi uses InfoLabels to display media file information (such as Artist and Album for a song, or Title and Cast list for a movie or TV show). This information shows up in the browsing menu (when using Library Mode), as well as in the Now Playing details when the media player is active.
You can get the currently-playing InfoLabel using the getInfoLabel function in xbmc. You can also set the InfoLabel information for any menu items you create in a plugin, making a much more versatile user experience.
- See: InfoLabels
Other Python pages
There are several other pages in the Kodi Online Manual dedicated to Python development. You can find a comprehensive list by clicking "Python" in the Categories list at the bottom of any Python page. Definitely check out following pages with tons of great sample code.
- Python debugging
- Python Problems
- Add-on unicode paths
General Python info
Useful modules for scraping websites
From Kodi Forum
|WindowXML GUI Toolkit (replaces GUIBuilder for XBMC Python scripts for GUI coding)
|[HOW-TO] Write GUI settings for XBMC Python plugins and scripts
|Tips for coding Python scripts / plugins compatible with Linux, Mac, Windows AND X-box
|[GUIDE] How to add a login function to your add-on
|[RELEASE] Googlejson - Python interface for Google searches
|[RELEASE] Repository Preparer (update to addons_xml_generator.py)
Kodi comes with Python 2.7
Migration to Python 3
Out of Date
- With the release of Eden 11.0, some functions are out of date. Please view http://kodi.wiki/view/Eden_API_changes for the latest on incorporating Python scripts.
- With the release of Frodo 12.0, some functions are out of date. Please view http://kodi.wiki/view/Frodo_API_changes for the latest on incorporating Python scripts.
- With the release of Gotham 13.0, some functions are out of date. Please view http://kodi.wiki/view/Gotham_API_changes for the latest on incorporating Python scripts.
- With the release of Helix 14.0, some functions are out of date. Please view http://kodi.wiki/view/Helix_API_changes for the latest on incorporating Python scripts.
- With the release of Isengard 15.0, some functions are out of date. Please view http://kodi.wiki/view/Isengard_API_changes for the latest on incorporating Python scripts.
- With the release of Jarvis 16.0, some functions are out of date. Please view http://kodi.wiki/view/Jarvis_API_changes for the latest on incorporating Python scripts.
|Return to top