New settings format for addons
#16
I tested a number of skins and so far only Estuary is displaying the help strings.  Looks like we'll have to nudge the skinners.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#17
(2019-12-16, 03:03)ronie Wrote: During the development of Kodi Leia, we've added support for addons to use the same settings format as Kodi itself uses.
Due to some initial bugs that couldn't be fixed in time before the v18 release, we've never promoted the use of this settings format for addons.

Over the past few months, these issues have been fixed.
If you're running a nightly v19 build and plan to submit your addon to the addon repo for Matrix,
there shouldn't be any reason to stop you from migrating your settings.xml file to the new format.

Here's an addon that will do (or at least try to) the hard work for you:
script.settings-convert-0.0.11.zip
(please make a backup of your settings.xml file before running this script)


In case you prefer not to depend on automated tools and rather do it manually, there's a wiki page where i tried to cover as much as i could think of:
https://kodi.wiki/view/Add-on_settings_conversion
@ronie Ran into one issue during conversion, the change below fixed it. Thanks for the script it works great!

line 154: default.py
from:
python:
grouplabel = attributes['label']
to:
python:
grouplabel = attributes.get('label','')
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#18
Hi @ronie, in the Wiki setting conversion page https://kodi.wiki/view/Add-on_settings_conversion
is missing how to use / help to convert conditions based of infolabels like:
xml:

          <dependencies>
            <dependency type="enable">
              <condition on="property" name="InfoBool">system.platform.android</condition>
            </dependency>
          </dependencies>

can you add it?
it would be very useful
Dev-Maintainer of InputStream Adaptive add-on, Netflix add-on ▫ Skills Python, C#, VB.NET and a bit of C++
Reply
#19
@CastagnaIT thanx for the info, i wasn't aware that was possible.
i've added the info to the wiki page now.
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#20
I've run into a settings issue between Kodi 18 and Kodi 19.  

Here's the Kodi 18 setting:

    <setting id="pastop" type="labelenum" label="30383" values="0|5|10|15|20|25|30|35|40|45|50|55|60" default="0"/>

The conversion script converted it to:

                <setting id="pastop" type="string" label="30383" help="">
                    <level>0</level>
                    <default>0</default>
                    <constraints>
                        <options>
                            <option label="0">0</option>
                            <option label="5">5</option>
                            <option label="10">10</option>
                            <option label="15">15</option>
                            <option label="20">20</option>
                            <option label="25">25</option>
                            <option label="30">30</option>
                            <option label="35">35</option>
                            <option label="40">40</option>
                            <option label="45">45</option>
                            <option label="50">50</option>
                            <option label="55">55</option>
                            <option label="60">60</option>
                        </options>
                    </constraints>
                    <control type="spinner" format="string"/>
                </setting>

This is not working with Kodi 19 and not showing the proper setting labels like 0,5, 10 etc... values.  Instead it is showing months and days like Jan, Fri,  The setting values are being stored properly in addon_data.  The Kodi 18 settings format works fine with Kodi 19.  If I force change the label;s to strings they display properly:

                <setting id="pastop" type="string" label="30383" help="30523">
                    <level>0</level>
                    <default>0</default>
                    <constraints>
                        <options>
                            <option label="A 0 ">0</option>
                            <option label="B 5 ">5</option>
                            <option label="C 10 ">10</option>
                            <option label="D 15 ">15</option>
                            <option label="E 20 ">20</option>
                            <option label="F 25 ">25</option>
                            <option label="G 30 ">30</option>
                            <option label="H 35 ">35</option>
                            <option label="I 40 ">40</option>
                            <option label="J 45 ">45</option>
                            <option label="K 50 ">50</option>
                            <option label="L 55 ">55</option>
                            <option label="M 60 ">60</option>
                        </options>
                    </constraints>
                    <control type="spinner" format="string"/>
                </setting>

If I go to language option labels it works too but I was preferring not to chew up a bunch of language labels just for this.  Is labelnum still supported in the new Kodi 19 settings format ?


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#21
i think you can ommit the label in case you want to display the values..

give this a shot:

xml:
<options>
    <option>0</option>
    <option>5</option>
    <option>10</option>
    ....
</options>
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#22
(2021-05-26, 16:25)ronie Wrote: i think you can ommit the label in case you want to display the values..

give this a shot:

xml:
<options>
    <option>0</option>
    <option>5</option>
    <option>10</option>
    ....
</options>

That worked.  Thanks for the quick response.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#23
Hey @ronie

I just converted some settings for my weather add on using your latest converter script (so handy!)

I didn't realise this addon was still using the old settings to be honest....thought I'd converted all of mine previously...but this time I'm having an issue.

This control works fine:

xml:

<setting id="Location1" type="action" label="32202" help="">
  <level>0</level>
  <default/>
  <constraints> <allowempty>true</allowempty> </constraints>
  <control type="button" format="action">
    <data>RunScript(weather.ozweather,Location1)</data>
  </control>
</setting>

This all is functionally fine, however the user can not see the value they've chosen from the location list....basically, the setting value is not displayed in the control once chosen (or if an existing value is in there).

I can't see anything in the wiki about getting the value to show?  Any tips??  Without the value showing it looks like it hasn't worked and users will definitely get confused...

(for reference, this old version settings worked fine:

xml:

<setting id="Location1" label="32111" type="action" action="RunScript($ID,Location1)" default=""/>
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#24
@bossanova808 the wiki lists two examples of an action type setting, it's the second one that you'll need to use.
https://kodi.wiki/view/Add-on_settings_c...2action.22

xml:
<setting id="test34" type="string" label="32034" help="">
    <level>0</level>
    <default/>
    <constraints>
        <allowempty>true</allowempty>
    </constraints>
    <control type="button" format="action">
        <data>RunScript(weather.yahoo,Location1)</data>
    </control>
</setting>
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#25
@ronie ah thanks - managed to look straight past that.  Working well now!
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#26
Hi @ronie,

Thanks for this script. I ran into a few bugs, and though I fixed them by hand, I wanted to report them for other users.

- In the old format, I had some booleans without a default attribute. This creates a boolean without a default in the new format, which causes to throw an error (though in the old format it worked acceptably)
- If you have multiple conditions in the old format for 'visible' and 'enable', it doesn't seem to convert the dependencies correctly to the new format. 

Old:
xml:
<setting id="group0_pauseSceneName" type="text" label="30036" default="Not selected" enable="false" visible="eq(-1,true) + eq(-8,true)" />

Becomes:
xml:

                    <dependencies>
                        <dependency type="enable">
                            <condition on="property" name="InfoBool">false</condition>
                        </dependency>
                        <dependency type="visible">
                            <and>
                                <condition operator="is" setting="group0_pauseBehavior">true</condition>
                                <condition on="property" name="InfoBool"> eq(-8,true)</condition>
                            </and>
                        </dependency>
                    </dependencies>

My understanding is that the enable attribute should just be set to false outside of the dependency section, without a condition. The first condition looks like it converted OK but the second is converted to an InfoBool
Reply
#27
thanx for the heads-up @Snapcase 
i've corrected both issues in v0.0.12
Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ, Help and Search the forum before posting.
Reply
#28
@ronie

I installed the addon "script.settings-convert", but when using it I got this error:
Code:
2021-08-30 21:36:26.439 T:12516   ERROR <general>: 
    EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
        - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
       Error Type: <class 'xml.etree.ElementTree.ParseError'>
       Error Contents: not well-formed (invalid token): line 4, column 136
       Traceback (most recent call last):
         File "D:\Program Files (x86)\Kodi v19.1 x64\portable_data\addons\script.settings-convert\default.py", line 844, in <module>
           Main()
         File "D:\Program Files (x86)\Kodi v19.1 x64\portable_data\addons\script.settings-convert\default.py", line 47, in __init__
           newsettings = self.updateSettings(settingsxml)
         File "D:\Program Files (x86)\Kodi v19.1 x64\portable_data\addons\script.settings-convert\default.py", line 78, in updateSettings
           data = ET.parse(settingsxml).getroot()
         File "D:\Program Files (x86)\Kodi v19.1 x64\system\python\Lib\xml\etree\ElementTree.py", line 1202, in parse
           tree.parse(source, parser)
         File "D:\Program Files (x86)\Kodi v19.1 x64\system\python\Lib\xml\etree\ElementTree.py", line 595, in parse
           self._root = parser._parse_whole(source)
         File "<string>", line None
       xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 4, column 136
       -->End of Python script error report<--

This is the settings.xml content:
https://paste.ubuntu.com/p/t49RxzZDdY

EDIT: The issue was with the & char, I changed it to & a m p ; (without spaces) and it works.
Reply
#29
Hello @ronie 

Thank you for the script.settings-convert add-on!

I first started the conversion of my settings.xml file manually using the wiki page and when I faced issues I searched the forum for help and found this thread.
I think you should add a link to your add-on at the top of the wiki page so that people starts with the automatic conversion first: it would be a shame that people don't benefit from your great work Wink

EDIT: if you modify the wiki page, could you also please add what is explained in this post: strings cannot be used for the help attribute, only IDs of strings defined in strings.po. I found this very useful information only in this thread but not in the wiki.
Reply
#30
@ronie Can we somehow set visible dependencies to groups and make them hide? It's really annoying to have group tags visible when the settings are not available.

eg. Kodi v19, new settings format
Image

EDIT:
Ok, I assume that parent should be used for the different settings, though group dependencies would be better looking.
Reply

Logout Mark Read Team Forum Stats Members Help
New settings format for addons0