<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://kodi.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pete+%28Wgtn%2CNZ%29</id>
	<title>Official Kodi Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://kodi.wiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Pete+%28Wgtn%2CNZ%29"/>
	<link rel="alternate" type="text/html" href="https://kodi.wiki/view/Special:Contributions/Pete_(Wgtn,NZ)"/>
	<updated>2026-06-17T16:17:11Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.8</generator>
	<entry>
		<id>https://kodi.wiki/index.php?title=Context_Item_Add-ons&amp;diff=233308</id>
		<title>Context Item Add-ons</title>
		<link rel="alternate" type="text/html" href="https://kodi.wiki/index.php?title=Context_Item_Add-ons&amp;diff=233308"/>
		<updated>2021-09-15T04:59:00Z</updated>

		<summary type="html">&lt;p&gt;Pete (Wgtn,NZ): Grammar corrections.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Context item add-ons allows the [[context menu]] in Kodi to be extended. Add-ons must provide the &amp;lt;code&amp;gt;kodi.context.item&amp;lt;/code&amp;gt; extension point and a &amp;lt;menu&amp;gt; definition. &lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30000&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
  &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first &#039;&#039;&#039;&amp;lt;menu&amp;gt;&#039;&#039;&#039; element defines which top level menu to attach to. In core, there are two available: &amp;lt;code&amp;gt;kodi.core.main&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;kodi.core.manage&amp;lt;/code&amp;gt;. Add-ons may attach to a menu defined by other add-ons as well.&lt;br /&gt;
&lt;br /&gt;
Next, the &#039;&#039;&#039;&amp;lt;item&amp;gt;&#039;&#039;&#039; element defines the action to add to perform when the user selects the item. It is specified my assigning the name of a Python script file to the  &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; attribute. Each menu item needs to have a unique &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; value (Duplicate items are ignored).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&#039; is a string, or an ID from the language file, that specifies the text that is shown in the context menu item, on the screen.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;visible&amp;gt;&#039;&#039;&#039; is required, and should contain a [[Conditional visibility|visibility expression]], which will determine if (or when) the item is visible in the [[context menu]]. &lt;br /&gt;
&lt;br /&gt;
This feature requires at least version 2.23.0 of the Python API (Jarvis), which should be specified in the [[Addon.xml#&amp;lt;requires&amp;gt;]] element:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;import addon=&amp;quot;xbmc.python&amp;quot; version=&amp;quot;2.23.0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{note|Kodi v19 Matrix and later.}}&lt;br /&gt;
&lt;br /&gt;
In Kodi v19 Matrix and later, it is possible to specify an optional &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; attribute to a context item. The contents of this attribute will be passed as an argument to the script specified in the &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; attribute. It can be accessed via &amp;lt;code&amp;gt;sys.argv&amp;lt;/code&amp;gt;. The combination of &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; need to be unique. Duplicate combinations are ignored.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem.py&amp;quot; args=&amp;quot;command_arg&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30000&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
  &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Keep in mind that there is limited space in the [[context menu]]. Attaching a context menu to an add-on will force the user to have all of them enabled at the same time. Consider using [[#submenus]], or creating a separate add-on.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Submenus ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;menu&amp;gt; and &amp;lt;item&amp;gt; elements may be mixed and nested to created submenus. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu&amp;gt;&lt;br /&gt;
    &amp;lt;label&amp;gt;My submenu&amp;lt;/label&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem1.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30001&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem2.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30002&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;menu&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;Subsubmenu&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;item library=&amp;quot;contextitem3.py&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;label&amp;gt;30003&amp;lt;/label&amp;gt;&lt;br /&gt;
        &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
      &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Accessing information about selected item ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;sys.listitem&amp;lt;/code&amp;gt; attribute contains a copy of the item the context menu was opened on. It is an instance of &amp;lt;code&amp;gt;xbmcgui.ListItem&amp;lt;/code&amp;gt;. See https://codedocs.xyz/xbmc/xbmc/group__python__xbmcgui__listitem.html for available properties.&lt;br /&gt;
&lt;br /&gt;
Example script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
import xbmc&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    message = &amp;quot;Clicked on &#039;{}&#039;&amp;quot;.format(sys.listitem.getLabel())&lt;br /&gt;
    xbmcgui.Dialog().notification(&amp;quot;Hello context items!&amp;quot;, message)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== v15 Isengard (deprecated) ==&lt;br /&gt;
Isengard, API version 2.20.0, does not support &amp;lt;menu&amp;gt; definition and can only define a single item as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot; library=&amp;quot;addon.py&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;item&amp;gt;&lt;br /&gt;
    &amp;lt;label&amp;gt;Hello World&amp;lt;/label&amp;gt;&lt;br /&gt;
    &amp;lt;visible&amp;gt;!IsEmpty(ListItem.Genre)&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;parent&amp;gt;kodi.core.manage&amp;lt;/parent&amp;gt;&lt;br /&gt;
  &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This syntax is considered deprecated and will be removed in future versions.&lt;br /&gt;
&lt;br /&gt;
Note: Both syntaxes are &#039;&#039;&#039;backwards&#039;&#039;&#039; and &#039;&#039;&#039;forward&#039;&#039;&#039; compatible. Add-ons may use both the old &amp;lt;item&amp;gt; and the new &amp;lt;menu&amp;gt; at the same time for comparability with v15 Isengard and v16 Jarvis.&lt;br /&gt;
&lt;br /&gt;
[[Category:Add-on development]]&lt;/div&gt;</summary>
		<author><name>Pete (Wgtn,NZ)</name></author>
	</entry>
	<entry>
		<id>https://kodi.wiki/index.php?title=Context_Item_Add-ons&amp;diff=233307</id>
		<title>Context Item Add-ons</title>
		<link rel="alternate" type="text/html" href="https://kodi.wiki/index.php?title=Context_Item_Add-ons&amp;diff=233307"/>
		<updated>2021-09-15T04:57:21Z</updated>

		<summary type="html">&lt;p&gt;Pete (Wgtn,NZ): Further improvements to specificity.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Context item add-ons allows the [[context menu]] in Kodi to be extended. Add-ons must provide the &amp;lt;code&amp;gt;kodi.context.item&amp;lt;/code&amp;gt; extension point and a &amp;lt;menu&amp;gt; definition. &lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30000&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
  &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first &#039;&#039;&#039;&amp;lt;menu&amp;gt;&#039;&#039;&#039; element defines which top level menu to attach to. In core, there are two available: &amp;lt;code&amp;gt;kodi.core.main&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;kodi.core.manage&amp;lt;/code&amp;gt;. Add-ons may attach to a menu defined by other add-ons as well.&lt;br /&gt;
&lt;br /&gt;
Next, the &#039;&#039;&#039;&amp;lt;item&amp;gt;&#039;&#039;&#039; element defines the action to add to perform when the user selects the item. It is specified my assigning the name of a Python script file to the  &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; attribute. Each menu item needs to have a unique &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; value (Duplicate items are ignored).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&#039; is a string, or an ID from the language file, that specifies the text that is shown in the context menu item, on the screen.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;visible&amp;gt;&#039;&#039;&#039; is required, and should contain a [[Conditional visibility|visibility expression]], which will determine if (or when) the item is visible in the [[context menu]]. &lt;br /&gt;
&lt;br /&gt;
This feature requires at least version 2.23.0 of the Python API (Jarvis), which should be specified in the [[Addon.xml#&amp;lt;requires&amp;gt;]] element:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;import addon=&amp;quot;xbmc.python&amp;quot; version=&amp;quot;2.23.0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{note|Kodi v19 Matrix and later.}}&lt;br /&gt;
&lt;br /&gt;
In Kodi v19 Matrix and later, it is possible to specify an optional &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; attribute to a context item. The contents of this attribute will be passed as an argument to the script specified in the &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; attribute. It can be accessed via &amp;lt;code&amp;gt;sys.argv&amp;lt;/code&amp;gt;. The combination of &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; need to be unique. Duplicate combinations are ignored.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem.py&amp;quot; args=&amp;quot;command_arg&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30000&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
  &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Keep in mind that there is limited space in the [[context menu]]. Attaching context menu to an add-on will force the user to have all of them enabled at the same time. Consider using [[#submenus]] or a creating a separate add-on.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Submenus ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;menu&amp;gt; and &amp;lt;item&amp;gt; elements may be mixed and nested to created submenus. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu&amp;gt;&lt;br /&gt;
    &amp;lt;label&amp;gt;My submenu&amp;lt;/label&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem1.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30001&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem2.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30002&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;menu&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;Subsubmenu&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;item library=&amp;quot;contextitem3.py&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;label&amp;gt;30003&amp;lt;/label&amp;gt;&lt;br /&gt;
        &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
      &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Accessing information about selected item ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;sys.listitem&amp;lt;/code&amp;gt; attribute contains a copy of the item the context menu was opened on. It is an instance of &amp;lt;code&amp;gt;xbmcgui.ListItem&amp;lt;/code&amp;gt;. See https://codedocs.xyz/xbmc/xbmc/group__python__xbmcgui__listitem.html for available properties.&lt;br /&gt;
&lt;br /&gt;
Example script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
import xbmc&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    message = &amp;quot;Clicked on &#039;{}&#039;&amp;quot;.format(sys.listitem.getLabel())&lt;br /&gt;
    xbmcgui.Dialog().notification(&amp;quot;Hello context items!&amp;quot;, message)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== v15 Isengard (deprecated) ==&lt;br /&gt;
Isengard, API version 2.20.0, does not support &amp;lt;menu&amp;gt; definition and can only define a single item as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot; library=&amp;quot;addon.py&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;item&amp;gt;&lt;br /&gt;
    &amp;lt;label&amp;gt;Hello World&amp;lt;/label&amp;gt;&lt;br /&gt;
    &amp;lt;visible&amp;gt;!IsEmpty(ListItem.Genre)&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;parent&amp;gt;kodi.core.manage&amp;lt;/parent&amp;gt;&lt;br /&gt;
  &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This syntax is considered deprecated and will be removed in future versions.&lt;br /&gt;
&lt;br /&gt;
Note: Both syntaxes are &#039;&#039;&#039;backwards&#039;&#039;&#039; and &#039;&#039;&#039;forward&#039;&#039;&#039; compatible. Add-ons may use both the old &amp;lt;item&amp;gt; and the new &amp;lt;menu&amp;gt; at the same time for comparability with v15 Isengard and v16 Jarvis.&lt;br /&gt;
&lt;br /&gt;
[[Category:Add-on development]]&lt;/div&gt;</summary>
		<author><name>Pete (Wgtn,NZ)</name></author>
	</entry>
	<entry>
		<id>https://kodi.wiki/index.php?title=Context_Item_Add-ons&amp;diff=233306</id>
		<title>Context Item Add-ons</title>
		<link rel="alternate" type="text/html" href="https://kodi.wiki/index.php?title=Context_Item_Add-ons&amp;diff=233306"/>
		<updated>2021-09-15T04:49:30Z</updated>

		<summary type="html">&lt;p&gt;Pete (Wgtn,NZ): Paragraph sentences re-arranged in more logical order, and separated.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Context item add-ons allows the [[context menu]] in Kodi to be extended. Add-ons must provide the &amp;lt;code&amp;gt;kodi.context.item&amp;lt;/code&amp;gt; extension point and a &amp;lt;menu&amp;gt; definition. &lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30000&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
  &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first &#039;&#039;&#039;&amp;lt;menu&amp;gt;&#039;&#039;&#039; element defines which top level menu to attach to. In core, there are two available: &amp;lt;code&amp;gt;kodi.core.main&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;kodi.core.manage&amp;lt;/code&amp;gt;. Add-ons may attach to a menu defined by other add-ons as well.&lt;br /&gt;
&lt;br /&gt;
Next, the &#039;&#039;&#039;&amp;lt;item&amp;gt;&#039;&#039;&#039; element defines the action to add to the menu. &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; is the file to execute. Each menu item needs to have a unique &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; specified. Duplicate items are ignored.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&#039; is a string, or an ID from the language file, to show in the context menu.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&amp;lt;visible&amp;gt;&#039;&#039;&#039; is required, and should contain a [[Conditional visibility|visibility expression]], which will determine if (or when) the item is visible in the [[context menu]]. &lt;br /&gt;
&lt;br /&gt;
This feature requires at least version 2.23.0 of the Python API (Jarvis), which should be specified in the [[Addon.xml#&amp;lt;requires&amp;gt;]] element:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;import addon=&amp;quot;xbmc.python&amp;quot; version=&amp;quot;2.23.0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{note|Kodi v19 Matrix and later.}}&lt;br /&gt;
&lt;br /&gt;
In Kodi v19 Matrix and later, it is possible to specify an optional &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; attribute to a context item. The contents of this attribute will be passed as an argument to the script specified in the &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; attribute. It can be accessed via &amp;lt;code&amp;gt;sys.argv&amp;lt;/code&amp;gt;. The combination of &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; need to be unique. Duplicate combinations are ignored.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem.py&amp;quot; args=&amp;quot;command_arg&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30000&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
  &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Keep in mind that there is limited space in the [[context menu]]. Attaching context menu to an add-on will force the user to have all of them enabled at the same time. Consider using [[#submenus]] or a creating a separate add-on.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Submenus ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;menu&amp;gt; and &amp;lt;item&amp;gt; elements may be mixed and nested to created submenus. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu&amp;gt;&lt;br /&gt;
    &amp;lt;label&amp;gt;My submenu&amp;lt;/label&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem1.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30001&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem2.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30002&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;menu&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;Subsubmenu&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;item library=&amp;quot;contextitem3.py&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;label&amp;gt;30003&amp;lt;/label&amp;gt;&lt;br /&gt;
        &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
      &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Accessing information about selected item ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;sys.listitem&amp;lt;/code&amp;gt; attribute contains a copy of the item the context menu was opened on. It is an instance of &amp;lt;code&amp;gt;xbmcgui.ListItem&amp;lt;/code&amp;gt;. See https://codedocs.xyz/xbmc/xbmc/group__python__xbmcgui__listitem.html for available properties.&lt;br /&gt;
&lt;br /&gt;
Example script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
import xbmc&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    message = &amp;quot;Clicked on &#039;{}&#039;&amp;quot;.format(sys.listitem.getLabel())&lt;br /&gt;
    xbmcgui.Dialog().notification(&amp;quot;Hello context items!&amp;quot;, message)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== v15 Isengard (deprecated) ==&lt;br /&gt;
Isengard, API version 2.20.0, does not support &amp;lt;menu&amp;gt; definition and can only define a single item as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot; library=&amp;quot;addon.py&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;item&amp;gt;&lt;br /&gt;
    &amp;lt;label&amp;gt;Hello World&amp;lt;/label&amp;gt;&lt;br /&gt;
    &amp;lt;visible&amp;gt;!IsEmpty(ListItem.Genre)&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;parent&amp;gt;kodi.core.manage&amp;lt;/parent&amp;gt;&lt;br /&gt;
  &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This syntax is considered deprecated and will be removed in future versions.&lt;br /&gt;
&lt;br /&gt;
Note: Both syntaxes are &#039;&#039;&#039;backwards&#039;&#039;&#039; and &#039;&#039;&#039;forward&#039;&#039;&#039; compatible. Add-ons may use both the old &amp;lt;item&amp;gt; and the new &amp;lt;menu&amp;gt; at the same time for comparability with v15 Isengard and v16 Jarvis.&lt;br /&gt;
&lt;br /&gt;
[[Category:Add-on development]]&lt;/div&gt;</summary>
		<author><name>Pete (Wgtn,NZ)</name></author>
	</entry>
	<entry>
		<id>https://kodi.wiki/index.php?title=Context_Item_Add-ons&amp;diff=233305</id>
		<title>Context Item Add-ons</title>
		<link rel="alternate" type="text/html" href="https://kodi.wiki/index.php?title=Context_Item_Add-ons&amp;diff=233305"/>
		<updated>2021-09-15T04:42:25Z</updated>

		<summary type="html">&lt;p&gt;Pete (Wgtn,NZ): Additions of conjoining words, and punctuation.... to aid readability.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
Context item add-ons allows the [[context menu]] in Kodi to be extended. Add-ons must provide the &amp;lt;code&amp;gt;kodi.context.item&amp;lt;/code&amp;gt; extension point and a &amp;lt;menu&amp;gt; definition. &lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30000&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
  &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The first &amp;lt;menu&amp;gt; element defines which top level menu to attach to. In core, there are two available: &amp;lt;code&amp;gt;kodi.core.main&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;kodi.core.manage&amp;lt;/code&amp;gt;. Add-ons may attach to a menu defined by other add-ons as well. Next, the &amp;lt;item&amp;gt; element defines the action to add to the menu. &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; is the file to execute, &amp;lt;label&amp;gt; is a string, or an ID from the language file, to show in the context menu. Each menu item needs to have a unique &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; specified. Duplicate items are ignored.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;visible&amp;gt; (required) should contain a [[Conditional visibility|visibility expression]], which will determine when the item is visible in the [[context menu]]. &lt;br /&gt;
&lt;br /&gt;
This feature requires at least version 2.23.0 of the Python API (Jarvis), which should be specified in the [[Addon.xml#&amp;lt;requires&amp;gt;]] element:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;import addon=&amp;quot;xbmc.python&amp;quot; version=&amp;quot;2.23.0&amp;quot;/&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{note|Kodi v19 Matrix and later.}}&lt;br /&gt;
&lt;br /&gt;
In Kodi v19 Matrix and later, it is possible to specify an optional &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; attribute to a context item. The contents of this attribute will be passed as an argument to the script specified in the &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; attribute. It can be accessed via &amp;lt;code&amp;gt;sys.argv&amp;lt;/code&amp;gt;. The combination of &amp;lt;code&amp;gt;args&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;library&amp;lt;/code&amp;gt; need to be unique. Duplicate combinations are ignored.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem.py&amp;quot; args=&amp;quot;command_arg&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30000&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
  &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|Keep in mind that there is limited space in the [[context menu]]. Attaching context menu to an add-on will force the user to have all of them enabled at the same time. Consider using [[#submenus]] or a creating a separate add-on.}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Submenus ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;menu&amp;gt; and &amp;lt;item&amp;gt; elements may be mixed and nested to created submenus. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;menu id=&amp;quot;kodi.core.main&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;menu&amp;gt;&lt;br /&gt;
    &amp;lt;label&amp;gt;My submenu&amp;lt;/label&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem1.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30001&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;item library=&amp;quot;contextitem2.py&amp;quot;&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;30002&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;menu&amp;gt;&lt;br /&gt;
      &amp;lt;label&amp;gt;Subsubmenu&amp;lt;/label&amp;gt;&lt;br /&gt;
      &amp;lt;item library=&amp;quot;contextitem3.py&amp;quot;&amp;gt;&lt;br /&gt;
        &amp;lt;label&amp;gt;30003&amp;lt;/label&amp;gt;&lt;br /&gt;
        &amp;lt;visible&amp;gt;true&amp;lt;/visible&amp;gt;&lt;br /&gt;
      &amp;lt;/item&amp;gt;&lt;br /&gt;
    &amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/menu&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Accessing information about selected item ==&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;sys.listitem&amp;lt;/code&amp;gt; attribute contains a copy of the item the context menu was opened on. It is an instance of &amp;lt;code&amp;gt;xbmcgui.ListItem&amp;lt;/code&amp;gt;. See https://codedocs.xyz/xbmc/xbmc/group__python__xbmcgui__listitem.html for available properties.&lt;br /&gt;
&lt;br /&gt;
Example script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import sys&lt;br /&gt;
import xbmc&lt;br /&gt;
&lt;br /&gt;
if __name__ == &#039;__main__&#039;:&lt;br /&gt;
    message = &amp;quot;Clicked on &#039;{}&#039;&amp;quot;.format(sys.listitem.getLabel())&lt;br /&gt;
    xbmcgui.Dialog().notification(&amp;quot;Hello context items!&amp;quot;, message)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== v15 Isengard (deprecated) ==&lt;br /&gt;
Isengard, API version 2.20.0, does not support &amp;lt;menu&amp;gt; definition and can only define a single item as follows:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;xml&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;extension point=&amp;quot;kodi.context.item&amp;quot; library=&amp;quot;addon.py&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;lt;item&amp;gt;&lt;br /&gt;
    &amp;lt;label&amp;gt;Hello World&amp;lt;/label&amp;gt;&lt;br /&gt;
    &amp;lt;visible&amp;gt;!IsEmpty(ListItem.Genre)&amp;lt;/visible&amp;gt;&lt;br /&gt;
    &amp;lt;parent&amp;gt;kodi.core.manage&amp;lt;/parent&amp;gt;&lt;br /&gt;
  &amp;lt;/item&amp;gt;&lt;br /&gt;
&amp;lt;/extension&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This syntax is considered deprecated and will be removed in future versions.&lt;br /&gt;
&lt;br /&gt;
Note: Both syntaxes are &#039;&#039;&#039;backwards&#039;&#039;&#039; and &#039;&#039;&#039;forward&#039;&#039;&#039; compatible. Add-ons may use both the old &amp;lt;item&amp;gt; and the new &amp;lt;menu&amp;gt; at the same time for comparability with v15 Isengard and v16 Jarvis.&lt;br /&gt;
&lt;br /&gt;
[[Category:Add-on development]]&lt;/div&gt;</summary>
		<author><name>Pete (Wgtn,NZ)</name></author>
	</entry>
</feed>