Add-on introduction

From Official Kodi Wiki
Jump to: navigation, search
Home icon grey.png   ▶ Development ▶ Add-on development ▶ Add-on introduction

1 Introduction

1.1 Purpose

• to provide a guide for would be Kodi Python plugin addon script developers • to provide the skeleton frameworks to enable script developers to get up and running quickly • to provide links to authoritative sources of information for script developers


1.2 Caveats

• This document does not try to teach you how to program in Python • This document does not cover developing for the core Kodi system


1.3 Conventions

Any commands that you need to type at a terminal are shown thus; sudo apt-get install xbmc Any program examples, i.e. code that you will type in is shown thus; import urllib,urllib2,re,xbmcplugin,xbmcgui

  1. TV DASH - by You 2008.

def CATEGORIES(): addDir(,,1,) addDir( ,,1,)


1.4 Prerequisites

The first two of these are really nice to haves. If you are not a programmer, there is nothing to stop you giving it a go, it'll just take a bit longer is all. • Some knowledge of application development, particularly in a GUI environment • Knowledge of Python scripting • Installed version of Kodi 10 (Dharma) minimum – you do not need the development source version


1.5 First Steps

The development user This document assumes for the purposes of illustration, that the user that you installed Kodi with is 'xbmc' and that that user has all rights to the /home/xbmc directory. Please bear this in mind if you installed under a different user name on your box. In addition you may want to set up another user on the Kodi server that you will use to login as the developer. This user should have sudo rights on a Linux based system. This is your development user. Your development environment You need to consider how you want to work whilst programming. Three options are given in order of preference.


1.6 Local working on your PC

Using a separate development environment is by far the easiest and preferred method of development. You will need to install Kodi on your local machine and run it there. In some senses this is not a bad idea as you can install a plain vanilla Kodi and concentrate on developing and testing your addon in isolation, moving it to your 'production' machine for final integration testing and thence on into the wild. In this case you can install XBMC1 as your normal logged on user and you shouldn't need to worry about file permissions etc. You can run XBMC in a window to see the results of your work. (Go to System Settings - System Settings – Video Output and set Display Mode to Windowed.) Having a dual screen set-up can be very beneficial in this scenario.


1.7 Local working on the Kodi server

This scenario is similar to working on a local machine except that you will need to install a window manager (Linux machines), run Kodi in a window and connect a keyboard and mouse to the machine (there are some nice wireless keyboards with touchpads about, Toshiba among others do one.) Otherwise the set-up is the same as for a local PC installation.


1.8 Remote working to an Kodi server

In this scenario you are going to use your Kodi server to run your code on, but use another machine to do the coding from. You need to be able to access the server from the local machine. Running Kodi under windows? - share the xbmc user directory and set permissions for your development user to read and write to the directory and its subdirectories Running Kodi under Linux? - Perhaps the easiest way to do this is to set the file permissions on /home/xbmc to allow the group to read and write, enrol your development user name in the xbmc group. Set the sticky bits for the xbmc user and group so that all new files are owned by the xbmc user /group irrespective of who creates them; sudo chmod -R u+s /home/xbmc/.xbmc 1 Fedora users can use a Dharma repository. See http://forums.fedoraforum.org/showthread.php?t=229121 sudo chmod -R g+rws /home/xbmc/.xbmc sudo useradd -G xbmc your_dev_user_name Then logon via ssh (or sftp) from your working machine. Alternatively, install Samba and set up the shares so that you can access your Kodi installation as any user. Ref to Samba docs In either OS, set up permanent mappings from your working machine to the Kodi server so that your editors etc, can see the files


1.9 IDE's

An integrated development environment is a good place to start when coding in any language. Check out the following link for a list of free and non free offerings. Look out for ones that support not only Python scripting, but also XML editing and in particular, local and remote debugging; as someone once said – Professional programmers use a debugger! http://wiki.python.org/moin/IntegratedDevelopmentEnvironments See what other people are using at http://stackoverflow.com/questions/81584

1.10 Editors

If you don't/can't use an IDE, then check http://wiki.python.org/moin/PythonEditors for a list of editors that support Python in some way. And don't forget you can use any simple editor such as Nano or Gedit in Linux, ? In Windows, ? In Mac to edit python source code Access to documentation It's a really good idea to have a web browser set up so that you have all the documentation you need at your finger tips. So go ahead and download another browser that is different to your normal one (e.g. I use Firefox for everyday stuff and Chrome as my Developers reference library,) or at least set up a group of tabs in your regular browser that you can fire up when you are developing. See the reference section at the end of this document for sites you will want to have at hand.

Notepad++ is a recommended editor.

Files should be saved as UTF-8 without BOM


1.11 Access to documentation

It's a really good idea to have a web browser set up so that you have all the documentation you need at your finger tips. So go ahead and download another browser that is different to your normal one (e.g. I use Firefox for everyday stuff and Chrome as my Developers reference library,) or at least set up a group of tabs in your regular browser that you can fire up when you are developing. See the reference section at the end of this document for sites you will want to have at hand.


1.12 See also

Development: