doc:appunti:software:kodi_addon
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
doc:appunti:software:kodi_addon [2019/09/12 15:02] – [Localization] niccolo | doc:appunti:software:kodi_addon [2023/05/26 15:02] – [How to start an external program from Kodi] niccolo | ||
---|---|---|---|
Line 140: | Line 140: | ||
===== Localization ===== | ===== Localization ===== | ||
- | Localization of a Kodi add-on takes place in several | + | Localization of a Kodi add-on takes place in several |
<code xml> | <code xml> | ||
Line 151: | Line 151: | ||
</ | </ | ||
- | Besides the **%%< | + | Besides the **%%< |
- | Then you will need to localize **text strings** used into **Python code** and into **XML files** (e.g. addon.xml, settings.xml, | + | Then you will need to localize **text strings** used into **Python code** and into **XML files** (e.g. //addon.xml//, //settings.xml//, etc.). For each language you intend to support, |
- | * **resources/ | + | * **resources/ |
* **resources/ | * **resources/ | ||
- | **NOTICE**: Kodi documentation says to use here the **// | + | **NOTICE**: Kodi documentation says to use here the **// |
Every file begins with a preamble: | Every file begins with a preamble: | ||
Line 198: | Line 198: | ||
</ | </ | ||
- | Notice that **msgid** is the original, untranslated English text. The **msgstr** is the localized version and **msgctxt** is an unique ID for that string. | + | Notice that **msgid** is the original, untranslated English text. The **msgstr** is the localized version and **msgctxt** is an unique ID for each string. |
- | The **english version will be used by default** | + | If a localization is missing, the **british |
< | < | ||
Line 218: | Line 218: | ||
Beware of this: | Beware of this: | ||
- | * According | + | * If you **update a .po file** you have to **restart Kodi** to re-read it, restarting the add-on is not sufficient. |
- | * If a string contains a **double quote**, it must be escaped with a **backslash**. | + | * For **scripts add-ons**, according |
- | * FIXME If a string | + | * If a string contains a **double quote**, it must be escaped with a **backslash**. Notice that //C syntax// is applied, so backslash is used as the escape character. |
+ | * For better reading | ||
+ | * For more info see **[[https:// | ||
Finally we have to change the **Python code**, substituting the strings with a function call and the string ID: | Finally we have to change the **Python code**, substituting the strings with a function call and the string ID: | ||
Line 259: | Line 261: | ||
</ | </ | ||
</ | </ | ||
+ | |||
+ | ===== Change Regional Settings ===== | ||
+ | |||
+ | Regional default for Kodi is **English**, | ||
+ | |||
+ | When you **change regional settings** in Kodi (Settings => ...) - if the choosen set is not already installed - the system tries to download the appropriate archive. In our test case (**Kodi 17.6** on the **Raspberry Pi**, Debian Stretch 9.3) the download URL is something like this: | ||
+ | |||
+ | < | ||
+ | http:// | ||
+ | </ | ||
+ | |||
+ | Unfortunately the above md5 file does not exists, so the installation of the requested resource fails. You have to download the zip file manually and follow the procedure to install an add-on from a zip file. The installation will create the directory **/ | ||
+ | |||
+ | ===== Cannot execute a graphical external program ===== | ||
+ | |||
+ | After many hours of trying and failing, it turned out that **it is not possibile to start an external program** from Kodi and use the **graphic display**; at least it is not possible if Kodi is **running without a full windowing system** (e.g. X11). | ||
+ | |||
+ | When Kodi is installed on the **Raspberry Pi** using the **RaspiOS** operating system (based on Debian GNU/Linux 11 Bullseye), the program is started by the binary program **%%kodi.bin%%** using the argument **%%--standalone%%**. | ||
+ | |||
+ | **kodi-standalone** on the Raspberry Pi uses the GBM (Generic Buffer Management) windowing system to draw its graphics via the Mesa (an open source implementation of the OpenGL API). Other platforms supported by kodi-standalone are X11 and Wayland. You can see the following line into the **kodi.log**: | ||
+ | |||
+ | < | ||
+ | INFO < | ||
+ | </ | ||
+ | |||
+ | GBM/KMS only supports one "DRM master" | ||
+ | |||
+ | You can verify if it is possibile to lanuch a simple graphical program like **kmscube** (from the homonymous Debian package). Just execute the command: | ||
+ | |||
+ | <code bash> | ||
+ | # / | ||
+ | kmscube -D / | ||
+ | </ | ||
+ | |||
+ | If Kodi is not running the kmscube runs nicely, but if Kodi is running (you can launch the program using '' | ||
+ | |||
+ | < | ||
+ | failed to set mode: Permission denied | ||
+ | </ | ||
+ | |||
+ | If you use '' | ||
+ | |||
+ | < | ||
+ | ioctl(3, DRM_IOCTL_MODE_SETCRTC, | ||
+ | </ | ||
+ | |||
+ | ==== How to start an external program from Kodi ==== | ||
+ | |||
+ | I tried (but failed) to start a Python graphical program from Kodi. Because there is not an X11 windowing system, I tried **Pygame** with the drivers **directfb**, | ||
+ | |||
+ | To execute an external program from my add-on video plugin, I used the following two methods. The first one just starts an external Python script when the code is executed: | ||
+ | |||
+ | <code python> | ||
+ | # This works only for a Python script. | ||
+ | # Notice " | ||
+ | xbmc.executescript(' | ||
+ | </ | ||
+ | |||
+ | This second method will add a context menu item to the add-on '' | ||
+ | |||
+ | <code python> | ||
+ | # Add a context menu item to the add-on xbmcgui.ListItem object. | ||
+ | # This works only for a Python script. | ||
+ | li.addContextMenuItems([(' | ||
+ | </ | ||
+ | |||
+ | A third method should be the following, but I did not tried it: | ||
+ | |||
+ | <code python> | ||
+ | xbmc.executebuiltin(' | ||
+ | </ | ||
+ | |||
+ | Other non-tested code to execute plugins or scripts: | ||
+ | |||
+ | <code python> | ||
+ | xbmc.executebuiltin(' | ||
+ | xbmc.executebuiltin(' | ||
+ | xbmc.executebuiltin(' | ||
+ | </ | ||
+ | |||
+ | * **[[https:// | ||
+ | * **[[https:// | ||
+ | * **[[https:// | ||
+ | * **[[https:// | ||
+ | * **[[https:// | ||
+ | * **[[https:// | ||
+ | * **[[https:// | ||
===== Web References ===== | ===== Web References ===== |
doc/appunti/software/kodi_addon.txt · Last modified: 2023/05/26 15:05 by niccolo