-
Notifications
You must be signed in to change notification settings - Fork 1
Custom AKL plugin
Here we go through how to create a custom plugin for AKL. We assume you already know all the basics about how to code with python, how to create kodi addons and how to work with git. On this page we only go in to the specifics about the needed code, so if not prepared, start here.
A good example is the default plugin for AKL. Get the code here. We will refer to this codebase.
As noted before on the main page about extending AKL, you will need to have a dependency on the script.module.akl package in kodi. For this you will need to add the import line with a reference to the package in your addon.xml.
<addon id="script.akl.defaults" name="Advanced Kodi Launcher: Default plugins" version="0.0.4" provider-name="chrisism">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.akl" version="1.0.2"/>
</requires>
...
Also to make python a bit easier, you can import the package with pip into your local dev environment. Read the documentation here.
All the plugins work like a normal addon, so they will have a entrypoint as an addon. AKL uses that same entrypoint to call the plugin and will provide the plugin with specific arguments. Based on those arguments the plugin addon can decide what to do. Although the actual implementation of the default.py is all up to you, we recommend the setup as you can see here.
So the plugins are executed through normal script executions from Kodi. Communication back to AKL can be done by calling the micro HTTP server that AKL keeps alive in the background.
Addons are called with the following arguments:
-
--type : Called plugin type. Options are:
- LAUNCHER
- SCANNER
- SCRAPER
-
--cmd : Command or operation to execute. Options are:
- launch : Launch a ROM
- scan : Scan for items
- scrape : Scrape data for given ROM or collection
- configure : Configure a launcher/scanner (which depends on --type parameter)
- --server_host : Host IP/address of the micro webserver.
- --server_port : Port of the micro webserver.
- --rom_id : ROM ID to identify the ROM/game we are applying.
- --romcollection_id : ROM Collection ID to identify the collection we are executing.
- --akl_addon_id: Addon configuration ID, to identify a specific previously stored configuration. Empty if new.
- --settings : Additional specific run setting.
The --type argument is there so you can build a single addon which can be used for multiple plugin types. You can make one that launches, but also scans.
Depending if the item selected in AKL is a single ROM or a whole collection, either the rom_id or the rom_collection_id will be provided. For instance you can scrape a single game or you can scrape all of games in a complete collection.
The server host and port are there for the HTTP communication with the AKL instance. This will mostly be done by the base classes of the launchers, scanners and scrapers.
Each addon can have it's own configuration or settings. The settings for each addon can be found in the settings.xml file. For a plugin addon it is the same. We also use the settings file of AKL plugins to recognize them when we scan through available addons in kodi. So it is mandatory to have the following settings in your plugin's settings file. Notice that settings are made hidden by setting the level on 4.
<setting id="akl.enabled" type="boolean" label="Enable as AKL plugin" help="">
<level>4</level>
<default>true</default>
<control type="toggle"/>
</setting>
<setting id="akl.plugin_types" type="string" label="AKL plugin type(s)" help="">
<level>4</level>
<default>LAUNCHER|SCANNER</default>
</setting>
akl.enabled This is a simple boolean flag that should always be set on 'true'. This is the main flag to recognize a plugin addon.
akl.plugin_types With this setting you can determine the type of plugins the addon supports. You can choose from LAUNCHER, SCANNER or SCRAPER. It is possible to support multiple types. In that case you will need to separate the types with a | symbol.
More settings are available but depend on the type of plugin you are making. Further details will be covered in the specific pages you can see under the next paragraph.
What you will actually do when the addon receives the previous arguments is all up to you. However, we do have some base classes ready that covers the most basic stuff and helps you to quickly come up with the actual operation you want to do.
Read more here: