xbmc / xbmc

Kodi is an award-winning free and open source home theater/media center software and entertainment hub for digital media. With its beautiful interface and powerful skinning engine, it's available for Android, BSD, Linux, macOS, iOS, tvOS and Windows.
https://kodi.tv/
Other
18.48k stars 6.3k forks source link

[Addon instance settings] No way to set the new instance settings via Python API #22779

Open matthuisman opened 1 year ago

matthuisman commented 1 year ago

Looks like the new addon api can take a new argument for the instance ID and it defaults to the add-ons id (settings.xml).

Python API needs to be updated to allow getting a list of the instance ids and then accessing there settings.

addon.getSetting('setting_name', instance_id) ?

lrusak commented 1 year ago

Does a separate add-on instance have a separate addon_data folder?

What is the use case for different settings for multiple instances?

matthuisman commented 1 year ago

as far as I can tell, all instances use the same addon_data folder.

Only difference seems to be with settings xml.

settings.xml instance_1.xml instance_2.xml

Use case I've seen is with multiple instances of PVR Simple Client so you can have multiple playlists / epg sources.

matthuisman commented 1 year ago

ideally, we should be able to

1) get all instance ids 2) loop each instance and get its name and various settings 3) create a new instance 4) set / get instance settings

phunkyfish commented 1 year ago

There needs to be a way to get/set both add-on settings and instance settings.

It’s not the case with pvr.iptvsimple but other PVR add-ons such as pvr.vuplus and pvr.hts have settings that apply to everyone instance as well as individual settings.

Likely we also need a supports instance settings function to be able to differentiate between pvr add-ons that do/don’t support the feature

phunkyfish commented 1 year ago

Does a separate add-on instance have a separate addon_data folder?

What is the use case for different settings for multiple instances?

Another use case. I have two TVs in my house, and each has a PVR device. I should be able to connect to both from one kodi device.

matthuisman commented 1 year ago

I propose the python api follows the internal api

`addon = xbmcaddon.Addon('pvr.iptvsimple')

global = addon.getSetting('foo') instance_1 = addon.getSetting('foo', 1) instance_2 = addon.getSetting('foo', 2) (as well as the getInt, getBool etc)

addon.setSetting('bar', 'value') addon.setSetting('bar', 'value', 1) addon.setSetting('bar', 'value', 2) ` This would be a good start :)

phunkyfish commented 1 year ago

An alternative would be to leave getSetting() for the add-on settings and then something like getInstanceSetting() for instance settings. This would make it clear and distinct.

That way existing behaviour does not need to change and the API change is purely additive, leaving the current API functions unchanged. Remember that instance settings are only for PVR add-ons currently as far as I'm aware.

WDYT?

boogieeeee commented 1 year ago

+1 to this, my python addon also was modifying pvr iptvsimple settings to auto configure the hls streams. Noe it is just setting settings.xml instead of the instance.

phunkyfish commented 1 year ago

@enen92 do you have a preference between over loading the existing getSettings calls or using a separate getInstanceSettings() set of calls?

enen92 commented 1 year ago

Personally I'd prefer an overload but without any strong feelings. InstanceSettings might be a bit confusing for newcomers (even for me, I was not even aware of multi instance addons).

phunkyfish commented 1 year ago

I propose the python api follows the internal api

`addon = xbmcaddon.Addon('pvr.iptvsimple')

global = addon.getSetting('foo') instance_1 = addon.getSetting('foo', 1) instance_2 = addon.getSetting('foo', 2) (as well as the getInt, getBool etc)

addon.setSetting('bar', 'value') addon.setSetting('bar', 'value', 1) addon.setSetting('bar', 'value', 2) ` This would be a good start :)

Ok Matt, your suggestion is the winner 😉

github-actions[bot] commented 3 months ago

This issue is now marked stale because it has been open over a year without activity. Remove the stale label or add a comment to reset the stale state.

phunkyfish commented 3 months ago

Ping

matthuisman commented 3 months ago

Pong?