Script lyrics: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
>Amet
(Created page with '==What XBMC requires for your addon== For XBMC to know what to do with your addon, we require your script, and an addon.xml file. See here for more informati…')
 
m (Text replacement - "xbmcaddon module" to "xbmcaddon module")
(17 intermediate revisions by 9 users not shown)
Line 1: Line 1:
==What XBMC requires for your addon==
{{mininav|[[Development]]|[[Add-on development]]}}
For XBMC to know what to do with your addon, we require your script, and an addon.xml file. See [[addons for XBMC|here]] for more information on addon.xml, including how you add descriptions to your addon for users. A plugin source extends XBMC via the xbmc.python.lyrics extension point. The layout of the XML describing this extension point is as follows:
==What Kodi requires for your add-on==
For XBMC to know what to do with your add-on, we require your script, and an addon.xml file. See [[Add-on development|here]] for more information on addon.xml, including how you add descriptions to your addon for users. A plugin source extends XBMC via the xbmc.python.lyrics extension point. The layout of the XML describing this extension point is as follows:


<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
   <extension point="xbmc.python.lyrics"
   <extension point="xbmc.python.lyrics"
             library="default.py" />
             library="default.py" />
</source>
</syntaxhighlight>


list of extension points and their explanation:
list of extension points and their explanation:
Line 20: Line 21:


Example of "xbmc.python.lyrics":
Example of "xbmc.python.lyrics":
<source lang="xml">
<syntaxhighlight lang="xml" enclose="div">
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.cu.lyrics"
<addon id="script.cu.lyrics"
Line 37: Line 38:
   </extension>
   </extension>
</addon>
</addon>
</source>
</syntaxhighlight>


==Interacting with XBMC==
== Interacting with XBMC ==
Given that your script can return information to the user, you may wish to allow some (or all) of the information you provide to be translatable. You do this by providing a strings.xml file (in resources/language/<name_of_language>/strings.xml) which associates integer id's with each label. XBMC then handles loading these string files and ensuring that the users' locale information is taken into account. To display strings you use the '''getString''' function in the xbmcaddon module.
Given that your script can return information to the user, you may wish to allow some (or all) of the information you provide to be translatable. You do this by providing a strings.xml file (in resources/language/<name_of_language>/strings.xml) which associates integer id's with each label. XBMC then handles loading these string files and ensuring that the users' locale information is taken into account. To display strings you use the '''getString''' function in the xbmcaddon module.


==The xbmcaddon module==
== See also ==
* [[Add-ons]]
* [[Unofficial add-on repositories]]
'''Development:'''
* [[Add-on development]]
* [[Addon Settings]]
* [[Add-on repositories]]
* [[Official add-on repository]]


The documentation for the xbmcaddon module may be found here <linky to auto-gen'd python docs>.  The '''getSetting''' and '''setSetting''' commands may be used to store state information between calls, in addition to accessing configuration information. '''openSettings''' pops up the configuration dialog allowing the user to change the configuration of your plugin source.  '''getLocalizedString''' retrieves translated strings, and '''getAddonInfo''' returns pertinent information about your pluginsource should you want to display this via some other means.


  import xbmcaddon
[[Category:Python]]
  __settings__ = xbmcaddon.Addon(id='<your addons ID>')
[[Category:Add-on development]]
  __language__ = __settings__.getLocalizedString
  __language__(30204)              # this will return localized string from resources/language/<name_of_language>/strings.xml
  __settings__.getSetting( "foo" ) # this will return "foo" setting value
  __settings__.setSetting( "foo" ) # this will set "foo" setting value
  __settings__.openSettings()      # this will open settings window
 
please note that <your addons ID> mentioned above must be the same as addon id="<your addons ID> in addons.xml
[[category:Add-ons]]

Revision as of 01:00, 22 July 2020

Home icon grey.png   ▶ Development ▶ Add-on development ▶ Script lyrics

What Kodi requires for your add-on

For XBMC to know what to do with your add-on, we require your script, and an addon.xml file. See here for more information on addon.xml, including how you add descriptions to your addon for users. A plugin source extends XBMC via the xbmc.python.lyrics extension point. The layout of the XML describing this extension point is as follows:

  <extension point="xbmc.python.lyrics"
             library="default.py" />

list of extension points and their explanation:

  "xbmc.python.script"          This is the standard Script extension point

below listed extensions will not appear in the Scripts/Programs window and can only be run via skin shortcuts

  "xbmc.python.weather"        Used for weather scripts
  "xbmc.python.subtitles"      Used for subtitle scripts
  "xbmc.python.lyrics"         Used for lyrics scripts
  "xbmc.python.library"        Used for skin dependent scripts (e.g. recently added script)


Example of "xbmc.python.lyrics":

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.cu.lyrics"
       name="CU Lyrics"
       version="0.8.6"
       provider-name="Amet">
  <requires>
    <import addon="xbmc.python" version="1.0"/>
  </requires>
  <extension point="xbmc.python.lyrics"
             library="default.py" />
  <extension point="xbmc.addon.metadata">
    <summary lang="en">CU Lyrics</summary>
    <description lang="en">Search, download and display lyrics from LyricWIKI.org. Downloaded lyrics will be saved in userdata/addon_data.Lyrics button on OSD needs to be activated and path set to CU Lyrics under Settings-> Skin-> Scripts </description>
    <platform>all</platform>
  </extension>
</addon>

Interacting with XBMC

Given that your script can return information to the user, you may wish to allow some (or all) of the information you provide to be translatable. You do this by providing a strings.xml file (in resources/language/<name_of_language>/strings.xml) which associates integer id's with each label. XBMC then handles loading these string files and ensuring that the users' locale information is taken into account. To display strings you use the getString function in the xbmcaddon module.

See also

Development: