Repeated enum definition in Settings
#1
I want to add Favourites Channels to our add-on, so that the user can define what TV channels the keys 1-9 will jump to.

At the moment I have

Code:
<category label="Favourite Channels">
        <setting id="fav1" label="Favourite 1" type="enum" values="BBC One | BBC Two | ITV 1 | Channel 4 | Five | ITV 1 +1 | Channel 4 +1  | Five +1 | BBC Three | BBC Four | ITV 2 | ITV 2 +1| ITV 3 | ITV 3 +1 | ITV 4 | ITV 4 +1 | E4 | E4 +1" default="0" />
        <setting id="fav2" label="Favourite 2" type="enum" values="BBC One | BBC Two | ITV 1 | Channel 4 | Five | ITV 1 +1 | Channel 4 +1 | Five +1 | BBC Three | BBC Four | ITV 2 | ITV 2 +1| ITV 3 | ITV 3 +1 | ITV 4 | ITV 4 +1 | E4 | E4 +1" default="1" />
        <setting id="fav3" label="Favourite 3" type="enum" values="BBC One | BBC Two | ITV 1 | Channel 4 | Five | ITV 1 +1 | Channel 4 +1 | Five +1 | BBC Three | BBC Four | ITV 2 | ITV 2 +1| ITV 3 | ITV 3 +1 | ITV 4 | ITV 4 +1 | E4 | E4 +1" default="2" />
    </category>

The final enum will have 50+ channels and there will be 10 settings, is there a better way than just repeating the same (very long) definition for each?

TIA
Reply
#2
Don't use settings. Store them in a database or other file. Seems more intuitive to access something like that from a context menu.
Reply
#3
that makes sense to use a database, but for future reference i would use a "select" setting for a large number of items, if possible.

<setting label="30440" type="select" id="video_local1" default="" source="$CWD/local_video_list/" />

you would then set up a folder with dummy files named "BBC One", "BBC Two" ...
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#4
(2012-11-18, 03:48)Bstrdsmkr Wrote: Don't use settings. Store them in a database or other file. Seems more intuitive to access something like that from a context menu.

Thanks for the reply, but I'm not quite sure what you mean, how I see it working is as follows.

In the settings page the user can set what his 10 favorite channels are (out of about 50), eg

Favorite 1 = BBC ONE
Favorite 2 = ITV 1
Favorite 3 = E4
Favorite 4 = CBeebies
etc

Then when watching a live steam, the user can simply press a numeric button on his keyboard/remote and it will switch to that channel,.

Reply
#5
(2012-11-18, 05:44)Nuka1195 Wrote: that makes sense to use a database, but for future reference i would use a "select" setting for a large number of items, if possible.

<setting label="30440" type="select" id="video_local1" default="" source="$CWD/local_video_list/" />

you would then set up a folder with dummy files named "BBC One", "BBC Two" ...

Select is definitely better, many thanks for the suggestion. When you say "set up a folder with dummy files", do you mean create folder called local_video_list in the addon folder and then fill it with empty files called BBC One, BBC Two, ITV 1, etc?
Reply
#6
yes, but of course you can name it anything you want, just change sourec=""
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#7
(2012-11-18, 14:33)Nuka1195 Wrote: yes, but of course you can name it anything you want, just change sourec=""

I've tried what you suggested but I just end up with an empty list :-(

I created 2 text files (empty) one called BBC One, and the other called BBC Two (no file extensions)

Is what you are suggesting documented anywhere, so I can have a read?
Reply
#8
Code:
<setting id="defmovieservice" type="select" mask="/" label="30113" default="OpenSubtitles" source="/resources/lib/services" />

is what I have and that works fine, /resources/lib/services is in addon folder structure, mask="/" specifies folders
Reply
#9
(2012-11-18, 15:01)amet Wrote:
Code:
<setting id="defmovieservice" type="select" mask="/" label="30113" default="OpenSubtitles" source="/resources/lib/services" />

is what I have and that works fine, /resources/lib/services is in addon folder structure, mask="/" specifies folders

That works a treat many thanks.

Is there a way to do it with files rather than folders, otherwise I guess I will have to put a dummy file in each folder as I don't think you can have an empty folder in a zip file (although I could be wrong on that one).

Is that mask option documented anywhere?

Reply
#10
Should work with files. Still need to update the settings page where it is described
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply
#11
yeah, mask=".txt" will work just for txt files.. (not sure if " . " needs to be there)

Reply
#12
Right, thanks everyone for the help one this one, most appreciated, and very interesting.

I've got it sussed now, and in case anyone else ever has this issue and comes across this thread;

The syntax for files is:
Code:
<setting label="30440" type="select" id="video_local1" default="" source="/list" />
You would then set up a folder called list with dummy files named "BBC One", "BBC Two" etc
There is no need for the $CWD


And for folders it is:
Code:
<setting label="30440" type="select" id="video_local1" default="" source="/list" mask="/" />
You would then set up a folder called list containing further sub-folder named "BBC One", "BBC Two" etc
Reply
#13
If you have a folder of icons for each channel named properly, you could use that folder with the mask set to file type (.jpg) then add the hideext option.
For python coding questions first see http://mirrors.xbmc.org/docs/python-docs/
Reply
#14
(2012-11-18, 16:08)Nuka1195 Wrote: If you have a folder of icons for each channel named properly, you could use that folder with the mask set to file type (.jpg) then add the hideext option.

Now that is rather cool! The icing on the cake would have been it displaying the icons too, but you can't have everything!

Is all this documented anywhere?

Reply
#15
Unfinished
http://wiki.xbmc.org/index.php?title=Addon_Settings
Read/follow the forum rules.
For troubleshooting and bug reporting, read this first
Interested in seeing some YouTube videos about Kodi? Go here and subscribe
Reply

Logout Mark Read Team Forum Stats Members Help
Repeated enum definition in Settings0