User:SistemaRayoXP/Playground: Difference between revisions

From Official Kodi Wiki
Jump to navigation Jump to search
(Initial creation of SistemaRayoXP/playground, being planned on)
 
m (Remove category links)
 
(2 intermediate revisions by one other user not shown)
Line 1: Line 1:
==What Kodi requires for your add-on==
So, you want to create a subtitle script, right? Or why else would you be here?
For XBMC to know what to do with your addon, 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.subtitles extension point. The layout of the XML describing this extension point is as follows:
 
To get started, you need some programming skills (Python, specifically), but with determination, you can get it done, and even learn a thing or two!
 
= Structure =
== What Kodi requires for your add-on ==
For XBMC to know what to do with your addon, 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 subtitle plugin source extends XBMC via the xbmc.python.subtitles extension point. The layout of the XML describing this extension point is as follows:


<syntaxhighlight lang="xml" enclose="div">
<syntaxhighlight lang="xml" enclose="div">
Line 32: Line 37:
             library="default.py" />
             library="default.py" />
   <extension point="xbmc.addon.metadata">
   <extension point="xbmc.addon.metadata">
     <summary lang="en">XBMC Subtitles</summary>
     <summary lang="en">Kodi Subtitles</summary>
     <summary lang="hu">XBMC feliratok</summary>  
     <summary lang="hu">Kodi feliratok</summary>  
     <description lang="en">Search and download subtitles from OpenSubtitles.org, Podnapisi.net, Sublight.si and Bierdopje.com. Subtitle button on OSD needs to be activated and path set to Kodi Subtitles under System-> Skin-> Addon Scripts</description>
     <description lang="en">Search and download subtitles from OpenSubtitles.org, Podnapisi.net, Sublight.si and Bierdopje.com. Subtitle button on OSD needs to be activated and path set to Kodi Subtitles under System-> Skin-> Addon Scripts</description>
     <description lang="hu">Film feliratok keresése letöltése az OpenSubtitles.org, Podnapisi.net, Sublight.si and Bierdopje.com webhelyekról. A dalszöveg OSD gombot aktiválni kell az elérési út megadásával a Beállítások -> Skin -> Szkriptek alatt.</description>
     <description lang="hu">Film feliratok keresése letöltése az OpenSubtitles.org, Podnapisi.net, Sublight.si and Bierdopje.com webhelyekról. A dalszöveg OSD gombot aktiválni kell az elérési út megadásával a Beállítások -> Skin -> Szkriptek alatt.</description>
Line 43: Line 48:
</syntaxhighlight>
</syntaxhighlight>


== Interacting with XBMC ==
See [[Add-on structure]] if you want more details on ways to structure your add-on.
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.
 
= Interacting with XBMC =
When Kodi calls a subtitle script, it passes several parameters and arguments about the kind of subtitle the user is looking for, like the search terms and the language for the subtitles.
 
These parameters and arguments are passed in the '''sys.argv[2]''' Python variable. They are urlencoded, so you might want to import the urllib module (urllib3 in [[Matrix]]) and user the urlparse module to parse the parameters.


[[Category:Add-on development]]
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. Kodi 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.

Latest revision as of 19:08, 29 January 2023

So, you want to create a subtitle script, right? Or why else would you be here?

To get started, you need some programming skills (Python, specifically), but with determination, you can get it done, and even learn a thing or two!

Structure

What Kodi requires for your add-on

For XBMC to know what to do with your addon, 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 subtitle plugin source extends XBMC via the xbmc.python.subtitles extension point. The layout of the XML describing this extension point is as follows:

  <extension point="xbmc.python.subtitles"
             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.subtitles":

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="script.xbmc.subtitles"
       name="XBMC Subtitles"
       version="1.7.4"
       provider-name="Amet">
  <requires>
    <import addon="xbmc.python" version="1.0"/>
  </requires>
  <extension point="xbmc.python.subtitles"
             library="default.py" />
  <extension point="xbmc.addon.metadata">
    <summary lang="en">Kodi Subtitles</summary>
    <summary lang="hu">Kodi feliratok</summary> 
    <description lang="en">Search and download subtitles from OpenSubtitles.org, Podnapisi.net, Sublight.si and Bierdopje.com. Subtitle button on OSD needs to be activated and path set to Kodi Subtitles under System-> Skin-> Addon Scripts</description>
    <description lang="hu">Film feliratok keresése letöltése az OpenSubtitles.org, Podnapisi.net, Sublight.si and Bierdopje.com webhelyekról. A dalszöveg OSD gombot aktiválni kell az elérési út megadásával a Beállítások -> Skin -> Szkriptek alatt.</description>
    <description lang="sr">Претражи и скини преводе са OpenSubtitles.org, Podnapisi.net, Sublight.si и Bierdopje.com. Дугме за преводе на OSD треба да се активира и изабере Kodi Subtitles у Систем-> Маска-> Скрипт додаци</description>
    <platform>all</platform>
  </extension>
</addon>

See Add-on structure if you want more details on ways to structure your add-on.

Interacting with XBMC

When Kodi calls a subtitle script, it passes several parameters and arguments about the kind of subtitle the user is looking for, like the search terms and the language for the subtitles.

These parameters and arguments are passed in the sys.argv[2] Python variable. They are urlencoded, so you might want to import the urllib module (urllib3 in Matrix) and user the urlparse module to parse the parameters.

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. Kodi 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.