Script to change a addon setting
#1
Is it possible to use a script to change a specific addon setting,

I would like to map a key to enable disable an addon setting (on/off) the addon would be a service.

Thank's
Reply
#2
Yep.

Code:
import xbmc
ADDONID = 'your addon id goes here'
query = xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.GetAddonDetails","id":1,"params":{"addonid":"%s", "properties": ["enabled"]}' % ADDONID)
if '"enabled":true' in query:
    xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","id":1,"params":{"addonid":"%s","enabled":false}}' % ADDONID)
else:
    xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","id":1,"params":{"addonid":"%s", "enabled":true}}' % ADDONID)
Reply
#3
Thank's

I was going for setting of the addon, like username, password, server etc ...

I building a service that downloads and plays video from a company internal server, the service is built so that if, for any reason, no video is available a fallback video is played.

I need a way to pause the service (for maintenance, so that i can access xbmc gui) i was thinking of checking a setting like "service_paused" , during the service loop this setting would be checked and if true video player would stop.

Also the service manages client queues, i am using the tv remote to increase / decrease current client number, using a simple script mapped to the remote buttons but i would like to save current client number in case a reboot is needed .

I was look at xbmcaddon.Addon ('script.foo.bar')

Sorry for my English.

Again any help is much appreciated
Reply
#4
Thanks for the info Karnagious.

Are the only areas that need to be amended in the code:

Code:
ADDONID = 'your addon id goes here'

&

Code:
"id":1

If so, I assume the id relates to the 'setting ID' in settings.xml, but can't seem to get the script to enable/disable as hoped.
My fanart.tv & themoviedb.org accounts.

Image
Reply
#5
no, the suggested code is to enable/disable an addon in its entirety.

while you in principle can do

Code:
addon = xbmcaddon.Addon('service.foo')
addon.setSetting('foo', 'bar')

this will only update the xml file, but it won't signal a running service.
Reply
#6
I use a loop in my service script that check for a change in the settings

PHP Code:
import xbmcxbmcguixbmcaddon;
addon xbmcaddon.Addon("script.service.wedoiptv")

if 
addon.getSetting('servico_ativo') =="true"
    
do stuff 

you can use this in other scripts called by your addon
Reply
#7
If you have a service running you can create a Monitor which will announce when the settings change through the onSettingsChanged() method.

Code:
class LazyMonitor(xbmc.Monitor):

    def __init__(self, *args, **kwargs):
        xbmc.Monitor.__init__(self)


    def onSettingsChanged(self):
        <><>THIS is where you can run the code that updates the settings<><>
Reply

Logout Mark Read Team Forum Stats Members Help
Script to change a addon setting0