Kodi Community Forum

Full Version: script.skinvariables - Construct multiple skin variables from a template.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
This script automates the construction of skin variables for different container IDs and listitem positions using a template.
The script also contains a function to generate visibility expressions for viewmodes so that you can lock views to specific rules.

Download
https://github.com/jurialmunkey/script.skinvariables

Usage
Wiki - Skin Variables
Wiki - Viewtypes
@jurialmunkey 

Script is it compatible for use with Kodi matrix? (Python 3) or work only with Leia (Python 2).
(2020-04-24, 04:16)Wanilton Wrote: [ -> ]@jurialmunkey 

Script is it compatible for use with Kodi matrix? (Python 3) or work only with Leia (Python 2).

Currently, it won't install under Matrix.
(2020-04-24, 04:37)drinfernoo Wrote: [ -> ]
(2020-04-24, 04:16)Wanilton Wrote: [ -> ]@jurialmunkey 

Script is it compatible for use with Kodi matrix? (Python 3) or work only with Leia (Python 2).

Currently, it won't install under Matrix.

@drinfernoo - Are you sure? There shouldn't be any reason why it doesn't work or install under Matrix. It doesn't have any module dependencies and it should be PY3 compatible.

@Wanilton - I haven't tested under Matrix but it should work.
EDIT: You just need to change python dependency in addon.xml to 3.0.0
@Wanilton - I've made a Matrix branch on the github to make it easier to install. I've just tested and script works properly.

Also FYI - You can use the script without adding it as a skin dependency. Just run the script on your own machine to generate the includes file and then commit that includes file to your repo. The end user doesn't need to run the script - they only need the includes file it makes.

So that it only runs if it is installed and doesn't prompt users to install, I run it with:
Code:
<onload condition="System.HasAddon(script.skinvariables)">runscript(script.skinvariables,folder=1080i)</onload>
@jurialmunkey 

Thanks, I will check here. Send info to MarcosQui about too.

Appreciate your work,

Regards,

Wanilton
(2020-04-24, 05:36)jurialmunkey Wrote: [ -> ]
(2020-04-24, 04:37)drinfernoo Wrote: [ -> ]
(2020-04-24, 04:16)Wanilton Wrote: [ -> ]@jurialmunkey 

Script is it compatible for use with Kodi matrix? (Python 3) or work only with Leia (Python 2).

Currently, it won't install under Matrix.

@drinfernoo - Are you sure? There shouldn't be any reason why it doesn't work or install under Matrix. It doesn't have any module dependencies and it should be PY3 compatible.

@Wanilton - I haven't tested under Matrix but it should work.
EDIT: You just need to change python dependency in addon.xml to 3.0.0

The issue is that while Leia declares backwards compatibility with `xbmc.python` down to `2.1.0`, Matrix only allows down to `3.0.0`. This means any add-on that declares a version below `3.0.0` won't install on Matrix.

What I found is that simply removing the xbmc.python, an add-on can install in any version. While this doesn't prevent users on Krypton from installing it, the API differences are minimal, insofar as you want to support it, at least in my experience.
(2020-04-24, 06:31)drinfernoo Wrote: [ -> ]
(2020-04-24, 05:36)jurialmunkey Wrote: [ -> ]
(2020-04-24, 04:37)drinfernoo Wrote: [ -> ]Currently, it won't install under Matrix.

@drinfernoo - Are you sure? There shouldn't be any reason why it doesn't work or install under Matrix. It doesn't have any module dependencies and it should be PY3 compatible.

@Wanilton - I haven't tested under Matrix but it should work.
EDIT: You just need to change python dependency in addon.xml to 3.0.0

The issue is that while Leia declares backwards compatibility with `xbmc.python` down to `2.1.0`, Matrix only allows down to `3.0.0`. This means any add-on that declares a version below `3.0.0` won't install on Matrix.

What I found is that simply removing the xbmc.python, an add-on can install in any version. While this doesn't prevent users on Krypton from installing it, the API differences are minimal, insofar as you want to support it, at least in my experience.

Yeah, I forgot that hard rules came into place with Matrix last month re python versioning. Prior to March updates, Matrix used to allow PY2/3 addons with a version lower than 3.
@jurialmunkey, I saw that you added some view related functions to the script, but I could not figure out what they do. Could you please explain? Thanks.

Regards,

Bart
@bsoriano

It's basically helps manage viewtype rules so that you can "lock" specific viewtype IDs to a specific rule. Instead of you writing visible conditions for your viewtypes, it will generate them for you as expressions and then you use them as the visibility condition like so <visible>$EXP[Exp_View_52]</visible>

I've added a wiki. It could use a little more detail and some better description, but it should help you get started
https://github.com/jurialmunkey/script.s...pe-Builder

Also have a look at my implementation in Arctic Horizon
https://github.com/jurialmunkey/skin.arc...types.json
https://github.com/jurialmunkey/skin.arc...#L633-L646
(2020-05-30, 07:31)jurialmunkey Wrote: [ -> ]@bsoriano

It's basically helps manage viewtype rules so that you can "lock" specific viewtype IDs to a specific rule. Instead of you writing visible conditions for your viewtypes, it will generate them for you as expressions and then you use them as the visibility condition like so <visible>$EXP[Exp_View_52]</visible>

I've added a wiki. It could use a little more detail and some better description, but it should help you get started
https://github.com/jurialmunkey/script.s...pe-Builder

Also have a look at my implementation in Arctic Horizon
https://github.com/jurialmunkey/skin.arc...types.json
https://github.com/jurialmunkey/skin.arc...#L633-L646
@jurialmunkey , thank you! I will certainly try this, it seems to be a great replacement/enhancement for my "set default view" functionality in Amber.

Regards,

Bart
@jurialmunkey , I am starting to add support for this script in Amber to customize the view types.  How can I make it so that all of my view types are available for all types of content as an out of the box experience? I mean, all viewtypes are visible for all types of content.  

I have not added the visiblity conditions yet for each viewtype container, but looking at the includes file that the addon generated (based on my json file, which you can see here: https://1drv.ms/u/s!AlII29kkG6TFiPYnKON7...A?e=g6uBk9), it would seem that no views are going to be visible for any content type except view 50, which I have set in the json as default for all content types.  Am I correct? Is there something that I am missing?

I did run the configurator to add a rule for one plugin.

The includes that the addon generated is this:


<?xml version="1.0" encoding="UTF-8"?>
<includes>
    <expression name="Exp_View_55">[]</expression>
    <expression name="Exp_View_54">[]</expression>
    <expression name="Exp_View_56">[]</expression>
    <expression name="Exp_View_51">[]</expression>
    <expression name="Exp_View_50">[[Container.Content(studios) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(playlists) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(videos) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Window.IsVisible(MyPVRSearch.xml) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(years) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(episodes) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(musicvideos) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(artists) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(images) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(genres) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(actors) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(files) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(tags) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(seasons) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(albums) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Window.IsVisible(MyPVRRecordings.xml) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content() + !Window.IsVisible(MyPVRTimers.xml) + !Window.IsVisible(MyPVRSearch.xml) + !Window.IsVisible(MyPVRRecordings.xml) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(countries) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(tvshows) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(movies) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName) + !String.IsEqual(Container.PluginName,script.embuary.info)]]] | [Container.Content(directors) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Window.IsVisible(MyPVRTimers.xml) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(sets) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(addons) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]] | [Container.Content(songs) + [[String.IsEmpty(Container.PluginName)] | [!String.IsEmpty(Container.PluginName)]]]]</expression>
    <expression name="Exp_View_53">[]</expression>
    <expression name="Exp_View_52">[]</expression>
    <expression name="Exp_View_511">Container.Content(movies) + [String.IsEqual(Container.PluginName,script.embuary.info) (wiki)]</expression>
    <expression name="Exp_View_551">[]</expression>
    <expression name="Exp_View_501">[]</expression>
</includes>

Please let me know.  Thanks.

Regards,

Bart
@bsoriano

On first run, the script locks each rule to the ID specified in "library" and "plugins" fields respectively. Each ID specified in the "viewtypes" field will be available to select. Replace the Viewmode switch button (id=2) with the script.skinvariables viewmode selector so that users can select a new view with the following onclick command:
Code:
Runscript(script.skinvariables,action=buildviews,contentid=$INFO[Container.Content],pluginname=$INFO[Container.PluginName]

If you're in the library and content is movies, that will display a dialog for the user to select from all the view IDs specified in the "viewtypes" field of the "movies" rule. For instance, if your movies rule has "viewtypes": ["50", "51", "52"] then the dialog displays the option to choose from 50, 51, 52 viewmodes.

When the user makes a choice, the script then rebuilds the includes file to reflect the new setup.

The viewmode selector uses DialogSelect.xml using the detailed list (id=6) if icons are specified and the simple list (id=3) if no icons are specified. You can check against !String.IsEmpty(Window(Home).Property(SkinViewtypes.DialogIsActive)) if you want to specify a different layout for the viewmode selector.

For instance, in my movies rule the viewtypes specified are 52, 54, 55, 56, 57 which are Posters, Landscape, List, Banners, Big Banner respectively. So when the user clicks to change view for movies they see this dialog and then when they make a choice the includes file is rewritten to reflect their choice.

Image
(2020-06-08, 03:00)jurialmunkey Wrote: [ -> ]@bsoriano

On first run, the script locks each rule to the ID specified in "library" and "plugins" fields respectively. Each ID specified in the "viewtypes" field will be available to select. Replace the Viewmode switch button (id=2) with the script.skinvariables viewmode selector so that users can select a new view with the following onclick command:
Code:
Runscript(script.skinvariables,action=buildviews,contentid=$INFO[Container.Content],pluginname=$INFO[Container.PluginName]

If you're in the library and content is movies, that will display a dialog for the user to select from all the view IDs specified in the "viewtypes" field of the "movies" rule. For instance, if your movies rule has "viewtypes": ["50", "51", "52"] then the dialog displays the option to choose from 50, 51, 52 viewmodes.

When the user makes a choice, the script then rebuilds the includes file to reflect the new setup.

The viewmode selector uses DialogSelect.xml using the detailed list (id=6) if icons are specified and the simple list (id=3) if no icons are specified. You can check against !String.IsEmpty(Window(Home).Property(SkinViewtypes.DialogIsActive)) if you want to specify a different layout for the viewmode selector.

For instance, in my movies rule the viewtypes specified are 52, 54, 55, 56, 57 which are Posters, Landscape, List, Banners, Big Banner respectively. So when the user clicks to change view for movies they see this dialog and then when they make a choice the includes file is rewritten to reflect their choice.

Image

@jurialmunkey, thank you for the explanation. I hope to complete my integration in the next couple of days.

Regards,

Bart
FYI - Skin Variables now uses XML Templates

The skin variable portion of this script now accepts an xml template to build your variables. This approach is much more user friendly. It will allow for easier conversion of variables into templates and make it clearer what the end results will be.

Replace shortcuts/skinvariables.json with shortcuts/skinvariables.xml

Basic starter skinvariables.xml template:

<?xml version="1.0" encoding="UTF-8"?>
<includes>
<variable name="Image_Poster" containers="51,52" start="1" end="2" parent="Control.HasFocus({id})">
<value condition="!String.IsEmpty({listitem}.Art(tvshow.poster))">$INFO[{listitem}.Art(tvshow.poster)]</value>
<value condition="!String.IsEmpty({listitem}.Art(poster))">$INFO[{listitem}.Art(poster)]</value>
<variable>
<expression name="Exp_Poster" containers="51,52" start="1" end="2">[!String.IsEmpty({listitem}.Art(poster)) | !String.IsEmpty({listitem}.Art(tvshow.poster))]</expression>
</includes>

See the wiki for more details: https://github.com/jurialmunkey/script.s...le-Builder
Pages: 1 2 3