doc:appunti:software:kodi_execute_script
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| doc:appunti:software:kodi_execute_script [2023/06/05 11:09] – [Executing a script from a Kodi plugin add-on] niccolo | doc:appunti:software:kodi_execute_script [2023/06/05 12:26] (current) – [Executing something from a plugin add-on] niccolo | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Executing a script from a Kodi plugin add-on ====== | ====== Executing a script from a Kodi plugin add-on ====== | ||
| - | As explained into the article | + | In trying to present my collection of images with a custom slideshow from Koid, I have tried different approaches. The first was to define an **[[kodi_external_player|external player]]**, the second was to create |
| - | If you want, it is possibile to customize the action associated to a **ListItem** (a media element shown into the plugin directory), overriding the default player. It is possible to launch | + | The first two methods failed because [[kodi_addon# |
| - | === Executing an external Python program === | + | ===== Executing something from a plugin add-on ===== |
| + | |||
| + | As explained into the article **[[kodi_addon]]** it is possible to create **script add-ons** or **plugin add-ons** using Python. A **plugin add-on** is simply a container of media elements generally organized as a directory, **without specific playing capabilities**. The play of a content is generally delegated to the **native Kodi players** (video, audio or pictures). | ||
| + | |||
| + | Starting with Kodi 19 Matrix it is possible tu use the embedded Python 3 as the programming language for plugins and scripts. | ||
| + | |||
| + | When a plugin add-on is invoked, it produces a **directory listing** where **some elements are sub-folders** and others are **playable items**. If the user selects a sub-folder, the plugin is called again and it produces another listing. If instead the user selects a playable item, the appropriate Kodi player is called. | ||
| + | |||
| + | It is possibile to customize the action associated to a playable **ListItem** (the playable media element shown into the plugin directory), overriding the default player; so it is possible to launch a generic external Python program or run a Kodi script add-on. To obtain this you must tag the ListItem as '' | ||
| + | |||
| + | |||
| + | |||
| + | ==== Executing an external Python program | ||
| This statement executes a **Python script** (it must be Python) that resides on the filesystem. The **%%special:// | This statement executes a **Python script** (it must be Python) that resides on the filesystem. The **%%special:// | ||
| Line 18: | Line 30: | ||
| li = xbmcgui.ListItem(label=' | li = xbmcgui.ListItem(label=' | ||
| li.addContextMenuItems([(' | li.addContextMenuItems([(' | ||
| + | </ | ||
| + | |||
| + | ==== Executing a Kodi script add-on ==== | ||
| + | |||
| + | Because an external program cannot use the graphic display, I had to rely on a Kodi script add-on to execute the slideshow. | ||
| + | |||
| + | The Python 3 code that I used into the plugin add-on is the following: | ||
| + | |||
| + | <code python> | ||
| + | from urllib.parse import urlencode | ||
| + | query = urlencode({' | ||
| + | run_addon = ' | ||
| + | xbmc.executebuiltin(run_addon) | ||
| </ | </ | ||
doc/appunti/software/kodi_execute_script.1685956153.txt.gz · Last modified: by niccolo
