Add-on development: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
{{mininav|[[Development]]}}
{{mininav|[[Development]]}}
[[File:Wiki logo.png|150px|link=|left]]


This page summarizes the new addons system introduced in the Dharma release (v10) of XBMC.
Here you will find all the information you need to start writing Add-ons for XBMC.


XBMC has introduced an addons system.  This allows 3rd party developed enhancements to XBMC to be distributed to XBMC users direct from inside the XBMC interface.
We provide tutorials and guides as well as explanations of the structure of Add-ons.


The addons system is based on the plugin library [http://www.c-pluff.org c-pluff].
{{-}}
 
----
 
{{huge|'''[[General topics|{{color|black|General}}]]'''}}
 
{| width="100%"
== Anatomy of an addon ==
|- valign="top"
 
| width="33%" align="center" | {{Main page icon|image=Nuvola apps kthememgr.png|link=About Add-on Development}}
Each add-on is kept in it's own folder, and is described via an XML file named addon.xml.  In addition, some other files can also come with the add-on, namely icon.png, changelog.txt, and fanart.jpg.  These are all optional, though we encourage you to at least have icon.png.  All of these reside in the "root" of the folder that contains the add-on.  Additional data may be contained within a resources/ subfolder, such as language translations and descriptions of settings.
| width="33%" align="center" | {{Main page icon|image=Applications-development.svg|link=Add-on Structure}}
 
| width="33%" align="center" | {{Main page icon|image=Administration.png|link=Development Tools}}
 
|}
=== Directory Name ===
----
 
{{huge|'''[[Tutorials|{{color|black|Tutorials}}]]'''}}
Your directory name should follow this convention:
{| width="100%"
<addonType>[.<mediaType>].<yourPluginName>
|- valign="top"
 
| width="33%" align="center" | {{Main page icon|image=Translation - Noun project 987.svg|link=Hello World Tutorial}}
The name parts are case sensitive and must be in lower case. The dot character separates each
| width="33%" align="center" | {{Main page icon|image=IYY logo.png|link=Audio Tutorial}}
name part – you can use further dot's to separate things in your plugin name if you wish,
| width="33%" align="center" | {{Main page icon|image=Video.svg|link=Video Tutorial}}
alternatively you may use a hyphen (-). No other non-alphanumeric characters should be used.
|}
 
{| width="100%"
The addonType is one from the following list
|- valign="top"
 
| width="33%" align="center" | {{Main page icon|image=Programming-128.png‎|link=Program Tutorial}}
{| class="wikitable" border="1"
| width="33%" align="center" | {{Main page icon|image=Web-icon.png|link=Scraper Tutorial}}
! Addon Type Name !! Description
| width="33%" align="center" | {{Main page icon|image=HP-TV-icon.png|link=ScreenSaver Tutorial}}
|-
|}
| repository || A repository definition file that allows users to add new repositories to
----
the XBMC addon manager. Media type is not required.
{{huge|'''[[Advanced|{{color|black|Advanced}}]]'''}}
|-
{| width="100%"
| plugin || A plugin script or module that adds to the functionality of XBMC.
|- valign="top"
Plugins appear under the relevant media section of the main home menu.
| width="33%" align="center" | {{Main page icon|image=Book icon 1.png|link=Add-on Libraries}}
|-
| width="33%" align="center" | {{Main page icon|image=Network2.png|link=Add-on Repositories}}
| script || A runnable program file that will appear in the Program section of the
| width="33%" align="center" | {{Main page icon|image=Gnome-system-run.svg|link=Add-on Settings}}
main home menu.
|-
| skin  || An XBMC skin definition and its supporting script files. Media type is not required.
|}
|}
 
----
The mediaType is not required in all cases. The following table describes the available
{{huge|'''[[Advanced|{{color|black|Publishing}}]]'''}}
mediaTypes for the available addon types. Your addon may provide more than one mediaType if
{| width="100%"
you wish, whereby it will appear in more than one section. In most cases, however, a single
|- valign="top"
media type will suffice, and it may be preferable to have multiple addons each providing a single
| width="25%" align="center" | {{Main page icon|image=Document-properties.png|link=Submitting Add-ons}}
media type rather than one addon that tries to do it all.
| width="25%" align="center" | {{Main page icon|image=200px-Thumbs_up_font_awesome.svg.png‎|link=Add-on Rules}}
 
| width="25%" align="center" | {{Main page icon|image=Tape-Measure-128.png‎|link=Add-on Standards}}
 
{| class="wikitable" border="1"
! Addon !! Media Type Name!! Description
|-
| plugin || audio || A music addon that will appear in the main menu music
|-
| plugin || video || A video addon that will appear in the main menu video
|-
| plugin || picture || A picture addon that will appear in the main menu picture
|-
| plugin || weather || A weather addon that will appear in the main menu weather
|-
| script || module || A script plugin that will not appear under a category or
within the Addons manager, but provides support for other
addons
|-
| script|| service || A script that will be run at either login or startup
|}
|}
See section on [[Add-on development#addon.xml|addon.xml]] for further information
The plugin name is up to you, but beware that others haven't used it before you.
So for instance, if you are creating an addon that integrates the Gpodder software with XBMC
for audio podcasts you might name your directory;
plugin.audio.gpodder-xbmc3
If you are creating a screen scraper to present tv shows from MyGreatTv.com. It might be;
plugin.video.my-great-tv-com
A script to ping all your friends on twitter to tell them you are home might be called;
script.ping-twits-i-am-home
Having settled on your name create the directory under the .xbmc/addons directory.
== Directory structure ==
Your directory contains all the resources needed to operate your addon. The directory must be
considered read-only and should not be used for storing intersession or transient data. Other
mechanisms are available to do that (more later.)
The directory must contain the following files and directories.
    addon.py
    addon.xml
    changelog.txt
    fanart.jpg
    icon.png
    LICENSE.txt
    /resources
        settings.xml
        /language/
        /lib/
        /media/
Other files may be required to run your addon, if your addon becomes more complex.
It is also considered good practice to place various addon resources and support code modules in the /lib folder.
If those libs are more commonly used by different addons consider them to add as a separate script.module.foo
I.e. everything that shouldn't be in the root of your directory is considered a resource and should
be placed in that sub-directory or a sub-directory from /resources.
=== addon.py ===
This will contain your main addon python code. It may be named differently as you will define this python file in addon.xml as your main script file.
=== addon.xml ===
The addon.xml tells XBMC
:* what the addon provides
:* what the addon relies on to work
:* what script to run when it is fired up (if it is meant to be started.)
More information on formatting can be found here: [[addon.xml]]
=== changelog.txt ===
A text file that contains a description of each release change that you make to the system. This is
displayed in the XBMC addon installation/update system. Recommended format is to have it
sorted by version in descending order, with a simple description as to the major changes (new
functionality, big fixes etc,) in each version. (In the author's opinion, too many addons skip this
piece of information making it difficult for users to determine whether a particular problem that
they may have been having has been fixed or not.)
=== icon.png ===
This used to to be displayed in various parts of XBMC.
In order to keep a coherent look and give the skinner a good idea how the icons of the add-ons look, we have defined the following rules:
* The icon size must be 256x256 pixels.
* File format is PNG.
* Background must be 100% solid. That doesn't mean one color, it also can be a gradient or a low contrast texture. Just make sure there is no transparency.
* Keep the logo as simple a possible, no exaggerated 3D effects or high contrast textures.
* Use a padding of at least 25px for your logo (not the background!). Excepted are large text logos (see icon for themoviedb.org).
* Keep text to a minimum. However, a text logo along with the graphical logo is recommended in order to easily recognize the addon.
* Don't mix logos with XBMC's logo, it's obvious that we're talking about XBMC here.
* Don't add borders or any overlays, that's the skinner's job. However, if borders are an element of your logo, make sure there is enough padding.
* It is suggested that a logo on a plain background (non-transparent) is best in many situations
(e.g. for addons that retrieve media from an online service, use that service's logo [as long as
you are free to do so]).
=== fanart.jpg ===
This helps to keep XBMC graphically rich when browsing and using addons.
Some simple guidelines:
* It should be 16:9 aspect ratio
* It is intended for the background, so should be simple and without text where reasonable.
* We recommend a 1280x720 JPG image.  It should certainly be no larger than 1920x1080.
* We recommend keeping it as small as is reasonable with respect to file-size.  Remember that hundreds of thousands of users are going to be downloading this.
=== LICENSE.txt ===
see [[Official add-on repository#Repository guidelines|repository guidelines]]
=== /resources/settings.xml ===
An XML file that defines the user-configurable settings used by the addon. The file defines the names and types of the settings, and how they should appear in the settings dialog for the addon. For more information about the format see [[Addon Settings]].
=== /resources/language/ ===
'''Translation tools:'''
* [[Language support]]
* [[Translation System]]
* Convert .xml to .po: [https://github.com/alanwww1/xbmc-xml2po xbmc-xml2po]
* Check for .po files: [https://github.com/alanwww1/xbmc-checkpo xbmc-checkpo]
* Utility for keeping XBMC upstream language files and the language files hosted on transifex.com in sync: [https://github.com/alanwww1/xbmc-txupdate xbmc-txupdate]
'''String ID range:'''
* strings 30000 thru 30999 reserved for plugins and plugin settings
* strings 31000 thru 31999 reserved for skins
* strings 32000 thru 32999 reserved for scripts
* strings 33000 thru 33999 reserved for common strings used in add-ons
'''strings.po'''
{{note|strings.xml will possibly be deprecated after the release of Frodo/Gotham. Frodo and Gotham will still be backwards compatible with .xml}}
=== /resources/lib/ ===
Put any module definitions or third party software libraries into this directory.
=== /resources/data/ ===
Store any other static data structures your application requires here. Examples might be
XLT/XSD files or static XML files that contain lookup tables etc.
=== /resources/media/ ===
store any static media (picture, audio, video etc.) files in this directory.
Remember, the above is a recommended outline for your addon – if you need fewer or more
directories to organise your work, just change it. Skins are addons that will require more directories than this.
== Getting started ==
Following pages will explain in more depth to get started. Provinding examples, background information and useful links.
* [[Python development]]
* [[Skinning]]
== See also ==
* [[Add-ons]]
* [[:Category:All add-ons]]
* [[3rd party add-on repositories]]
'''Development:'''
* [[Add-on development]]
* [[Addon Settings]]
* [[Python development]]
* [[Skinning]]
* [[Add-on repositories]]
* [[Official add-on repository]]
[[Category:Settings]]
[[Category:Add-ons]]
[[Category:Addon Development]]
[[Category:Skin Development]]
[[Category:Development]]

Revision as of 09:56, 5 December 2013

Home icon grey.png   ▶ Development ▶ Add-on development
Wiki logo.png

Here you will find all the information you need to start writing Add-ons for XBMC.

We provide tutorials and guides as well as explanations of the structure of Add-ons.



General

icon
About Add-on Development
icon
Add-on Structure
icon
Development Tools

Tutorials

icon
Hello World Tutorial
Audio Tutorial
icon
Video Tutorial
icon
Program Tutorial
icon
Scraper Tutorial
icon
ScreenSaver Tutorial

Advanced

icon
Add-on Libraries
icon
Add-on Repositories
icon
Add-on Settings

Publishing

icon
Submitting Add-ons
icon
Add-on Rules
icon
Add-on Standards