Skip to content

Skin Tools and Helpers

jurialmunkey edited this page Sep 12, 2024 · 18 revisions

Search Term History (Script)

SkinVariables allows for storing a history of search terms in a Skin.String or Window.Property

Add Search Term

RunScript(script.skinvariables,add_skinstring_history=SKINSTRING,value=SEARCHTERM)

Replace SKINSTRING with the name of the Skin.String(SKINSTRING) to be used.
Replace SEARCHTERM with the value to put into the search history.

If a term already exists in the history, it is moved to the first position.

Optional Params

Param Description
use_window_prop Use a Window.Property() instead of a Skin.String().
Useful if you do not want the search history to persist after closing Kodi.
window_id=ID Specify the ID of the Window(ID).Property() when use_window_prop is enabled.
By default the current window will be used.
toggle Remove the search term if it exists instead of moving to first position.
Useful to create menus where multiple terms are toggled.
separator=' / ' Specify the separator to be used for the search history.
By default a pipe | character is used to avoid conflicts with Kodi's default / slash character

📚 To retrieve the search history in a container list, see the string splitter method below.

String Splitter (Container)

Splits a string into a list of ListItems where ListItem.Label contains the split term. The infolabel= can be any infolabel that would go inside $INFO[]

plugin://script.skinvariables/?info=get_split_string&infolabel=Skin.String(SKINSTRING)

Optional Params

Param Description
&separator=' / ' Specify a different separator than the default | pipe symbol.
Useful if you want to split an infolabel from a listitem such as ListItem.Genre
&values=TEXT Alternative to infolabel= if you want to specify text directly.
Useful if you want to use $VAR[] instead of an infolabel.

💡 Example: Split Genres into a List

plugin://script.skinvariables/?info=get_split_string&infolabel=ListItem.Genre&separator=' / '

📝 Use optional params window_prop= and window_id= to set output to Window(WINDOW_ID).Property(WINDOW_PROP.X)

Get List of Container ListItem Infolabels (Container)

Gets all unique values for the specified container IDs as a List of ListItems. Multiple container IDs can be specified by separating with a +

plugin://script.skinvariables/?info=get_container_labels&containers=CONTAINERID&infolabel=INFOLABEL&numitems=$INFO[Container(ID).NumItems]

💡 Example: List all studios for all items in containers 5001 and 5002

plugin://script.skinvariables/?info=get_container_labels&containers=5001+5002&infolabel=Studio&numitems=$INFO[Container(5001).NumItems]+$INFO[Container(5002).NumItems]

❗ Important: The "numitems=" param is not used internally but must be supplied to trick Kodi into refreshing the container by changing the content path when the parent container changes. The value can be anything which will change when you need the container to update.

📚 Use RunPlugin if onclick is preferred

<onclick>RunPlugin(plugin://script.skinvariables/?info=get_container_labels&amp;containers=5001+5002&amp;infolabel=Studio&amp;window_property=MyStudios&amp;window_id=Home)</onclick>
Param Description
containers=ID Required. The parent Container(ID) to retrieve the labels from. Multiple container IDs separated with +
infolabel=INFOLABEL Required. The Container(ID).Listitem.INFOLABEL to retrieve from the parent containers. Multiple infolabels separated with +
label2=INFOLABEL Optional. TheContainer(ID).Listitem.INFOLABEL is added to ListItem.Label2.
thumb=INFOLABEL Optional. The Container(ID).Listitem.INFOLABEL artwork is added to ListItem.Icon and ListItem.Art(thumb)
window_prop=PROPERTY&amp;window_id=ID Optional. Each infolabel is output to Window(ID).Property(PROPERTY.X) properties. Additionally, the full list separated by slashes / will be outputted to Window(ID).Property(PROPERTY)
contextmenu=LABEL;BUILTIN;;LABEL;BUILTIN Optional. Generates a context menu for each item. Use {label} {thumb} {label2} to add those labels to the context menu label and builtins. For example contextmenu=Image for {label};Notification({label},{thumb}) will provide a context menu with the option "Image for X" that pops up a notification with the label and thumb for that item.

📝 Optionally the container can also be filtered using filter_value and exclude_value params. Useful if you want to provide an edit control to narrow down results.

Set Player Subtitle/Audio Stream (Script)

Sets the audio or subtitle stream for the currently playing video to X where X is the number of the stream.

Runscript(set_player_subtitle=X)
Runscript(set_player_audiostream=X)

Get Player Subtitle/Audio Streams (Container)

Gets a list of subtitles or audio streams for the currently playing video.

plugin://script.skinvariables/?info=get_player_streams&amp;stream_type=subtitle
plugin://script.skinvariables/?info=get_player_streams&amp;stream_type=audio

Get JSON RPC (Container)

Run a JSON RPC command and output the return values to a listitem. Optionally can output to window properties.

See JSON RPC documentation: https://kodi.wiki/view/JSON-RPC_API/v12

plugin://script.skinvariables/?info=get_jsonrpc&amp;method=method&amp;param=value

💡 Example: Call the Settings.GetSettingValue method and retrieve the setting for myvideos.selectaction. The setting value will be output to ListItem.Property(value)

plugin://script.skinvariables/?info=get_jsonrpc&amp;method=Settings.GetSettingValue&amp;setting=myvideos.selectaction

📚 Use RunPlugin if onclick is preferred. In this example the setting value will be output to Window(Home).Property(KodiSetting.DefaultSelectAction.Value)

<onclick>RunPlugin(plugin://script.skinvariables/?info=get_jsonrpc&amp;method=Settings.GetSettingValue&amp;setting=myvideos.selectaction&amp;window_prop=KodiSetting.DefaultSelectAction&amp;window_id=Home)</onclick>

Set Edit Control (Script)

Inputs the TEXT into the edit control at EDITID and then returns focus to RETURNID after the specified wait. The setfocus params are optional and can be removed if you want focus to stay on the edit control.

RunScript(script.skinvariables,set_editcontrol=EDITID,text=TEXT,setfocus=RETURNID,setfocus_wait=00:00)

Set Tag to DBID (Script)

RunScript(script.skinvariables,set_dbid_tag=TAGNAME,dbtype=DBTYPE,dbid=DBID)

Create a tag called TAGNAME for the library item of the specified DBID and DBTYPE. Only works for dbtype=movie and dbtype=tvshow

Get Number Sum (Container)

Adds the specified numbers together and outputs to ListItem.Label

plugin://script.skinvariables/?info=get_number_sum&amp;expression=5+12+7

💡 Example: Sum of Container(5001).NumItems and Container(5002).NumItems

plugin://script.skinvariables/?info=get_number_sum&amp;expression=0$INFO[Container(5001).NumItems,+,]$INFO[Container(5002).NumItems,+,]

📚 To subtract numbers use +- to add a negative number.
💡 Example: Subtract Container(5002).NumItems from Container(5001).NumItems

plugin://script.skinvariables/?info=get_number_sum&amp;expression=0$INFO[Container(5001).NumItems,+,]$INFO[Container(5002).NumItems,+-,]

📝 Use optional params window_prop= and window_id= to set output to window property.

Get Encoded String (Container)

Encodes the string using urlquote_plus routine and optionally saves to window property.

<content>plugin://script.skinvariables/?info=get_encoded_string&amp;unencoded_paths=true&amp;window_prop=MyEncodedString&amp;window_id=Home&amp;&amp;Umläuts,‡†Special Characters</content>

📝 The params window_prop and window_id are optional.

📚 Multiple strings can be specified using double ampersand &amp;&amp; with each string added to its own listitem and window property:

$INFO[Container(ID).ListItemAbsolute(0).Label]
$INFO[Container(ID).ListItemAbsolute(1).Label]
$INFO[Window(WINDOW_ID).Property(WINDOW_PROP.0)]
$INFO[Window(WINDOW_ID).Property(WINDOW_PROP.1)]

🔖 2.1.18+ Use the unencoded_paths=true param to avoid the strings being passed from being decoded first. Use this param if the original string is not percent encoded and is likely to contain + or % characters (e.g. a studio string such as "Apple TV+").

📚 Use RunPlugin if onclick is preferred

<onclick>RunPlugin("plugin://script.skinvariables/?info=get_encoded_string&amp;window_prop=MyEncodedString&amp;window_id=Home&amp;&amp;Umläuts,‡†Special Characters")</onclick>

Check File Exists (Container)

Checks if file exists and optionally saves path to window property if it does.

<content>plugin://script.skinvariables/?info=get_file_exists&amp;window_prop=MyFile&amp;window_id=Home&amp;&amp;special://skin/LICENSE.txt</content>

📝 The params window_prop and window_id are optional.

📚 Multiple paths can be specified using double ampersand &amp;&amp; with each path added to its own listitem and property. The listitem folderpath and window property are filled if the path exists; otherwise they are cleared.

$INFO[Container(ID).ListItemAbsolute(0).FolderPath]
$INFO[Container(ID).ListItemAbsolute(1).FolderPath]
$INFO[Window(WINDOW_ID).Property(WINDOW_PROP.0)]
$INFO[Window(WINDOW_ID).Property(WINDOW_PROP.1)]

📚 Use RunPlugin if onclick is preferred

<onclick>RunPlugin("plugin://script.skinvariables/?info=get_file_exists&amp;window_prop=MyFile&amp;window_id=Home&amp;&amp;special://skin/LICENSE.txt")</onclick>

Get DBTYPE Details (Container)

Retrieve additional details about an item from the library via JSON RPC. Values are stored in Container(ID).ListItem.Property(PROPERTYNAME)

plugin://script.skinvariables/?info=get_dbitem_movieset_details&amp;dbid=DBID
plugin://script.skinvariables/?info=get_dbitem_movie_details&amp;dbid=DBID
plugin://script.skinvariables/?info=get_dbitem_tvshow_details&amp;dbid=DBID
plugin://script.skinvariables/?info=get_dbitem_season_details&amp;dbid=DBID
plugin://script.skinvariables/?info=get_dbitem_episode_details&amp;dbid=DBID
plugin://script.skinvariables/?info=get_dbitem_addon_details&amp;dbid=DBID

💡 Example: Get more details about a Movie

plugin://script.skinvariables/?info=get_dbitem_movie_details&amp;dbid=$INFO[Container(50).ListItem.DBID]

📚 Details retrieved for each dbtype

DBType Details
movie title plot genre director writer studio cast country fanart thumbnail tag art ratings
tvshow title plot genre studio cast fanart thumbnail tag art ratings runtime
season title plot fanart thumbnail tvshowid art
episode title plot writer director cast fanart thumbnail tvshowid art seasonid ratings
set title plot playcount fanart thumbnail art
addon name version summary description path author thumbnail disclaimer fanart dependencies broken extrainfo rating enabled installed deprecated

📚 Details are placed in properties

$INFO[Container(ID).ListItem.Property(plot)]
$INFO[Container(ID).ListItem.Property(title)]

📚 Details with child attributes are referenced with a dot separator:

$INFO[Container(ID).ListItem.Property(art.poster)]
$INFO[Container(ID).ListItem.Property(ratings.imdb.rating)]
$INFO[Container(ID).ListItem.Property(ratings.imdb.votes)]

📚 Details which can have multiple values are referenced by index:

$INFO[Container(ID).ListItem.Property(genre.0)]
$INFO[Container(ID).ListItem.Property(genre.1)]
$INFO[Container(ID).ListItem.Property(genre.count)]
$INFO[Container(ID).ListItem.Property(director.0)]
$INFO[Container(ID).ListItem.Property(director.1)]
$INFO[Container(ID).ListItem.Property(director.count)]

📚 Details which can have multiple values with child attributes are referenced by index and dot notation:

$INFO[Container(ID).ListItem.Property(cast.0.name)]
$INFO[Container(ID).ListItem.Property(cast.0.role)]
$INFO[Container(ID).ListItem.Property(cast.0.thumbnail)]
$INFO[Container(ID).ListItem.Property(cast.1.name)]
$INFO[Container(ID).ListItem.Property(cast.1.role)]
$INFO[Container(ID).ListItem.Property(cast.1.thumbnail)]
$INFO[Container(ID).ListItem.Property(cast.count)]

📚 Sets also retrieve subdetails about each movieid inside the set

$INFO[Container(ID).ListItem.Property(movies.count)]
$INFO[Container(ID).ListItem.Property(movies.1.label)]
$INFO[Container(ID).ListItem.Property(movies.1.item.plot)]
$INFO[Container(ID).ListItem.Property(movies.1.item.art.fanart)]
$INFO[Container(ID).ListItem.Property(movies.1.item.ratings.imdb.rating)]
$INFO[Container(ID).ListItem.Property(movies.1.item.genre.0)]
$INFO[Container(ID).ListItem.Property(movies.1.item.cast.0.name)]

📚 Floating point values (e.g. for ratings) have additional affixes 🔖 v2.1.16+

$INFO[Container(ID).ListItem.Property(ratings.imdb.rating)]
8.399999618530273

$INFO[Container(ID).ListItem.Property(ratings.imdb.rating_integer)]
8

$INFO[Container(ID).ListItem.Property(ratings.imdb.rating_rounded)]
8.4

$INFO[Container(ID).ListItem.Property(ratings.imdb.rating_percentage)]
84%