Kodi Community Forum
Release script.skinshortcuts - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Skinning (https://forum.kodi.tv/forumdisplay.php?fid=12)
+---- Forum: Skin helper addons (https://forum.kodi.tv/forumdisplay.php?fid=300)
+---- Thread: Release script.skinshortcuts (/showthread.php?tid=178294)



RE: script.skinshortcuts - BobCratchett - 2016-03-12

Great stuff - and lets also give credit to Jayz2K, for coming up with the wonderful method of assigning a unique ID to each item.

There's one other situation I know of where widgets can start to disappear - when the window is closed whilst Kodi is loading the widget. Kodi won't try to load it again until the URI changes. If you want to start getting ready for the next repo version of the script, and I'm sure this method itself will evolve when you skilled skinners start playing with it, I'm using the following in my templates to work around this particular problem...

New template:-

Code:
    <other include="widgetReloadTrick">
        <propertyGroup>mainmenuWidgets</propertyGroup>
        <controls>
            <onunload condition="Container(800$SKINSHORTCUTS[id]).IsUpdating | !IntegerGreaterThan(Container(800$SKINSHORTCUTS[id]).NumItems,0)">SetProperty(refresh800$SKINSHORTCUTS[id],$INFO[system.time(hh:mm:ss)])</onunload>
        </controls>
    </other>

The propertyGroup is one of the new features, and just allows me to only define the <property /> elements once for multiple templates. In that propertyGroup there are the following...

Code:
        <property name="id" tag="mainmenuid" />

        <!-- Python snippets -->
        <property name="autoreload">autoreloadStringAnd %( id ) if path in 'plugin' and path in '?' else autoreloadStringQuestion %( id ) if path in 'plugin' else ''</property>
        <property name="autoreloadStringAnd">&amp;igConq=$INFO[Window.Property(refresh800%s)]</property>
        <property name="autoreloadStringQuestion">?igConq=$INFO[Window.Property(refresh800%s)]</property>
And then in the content for my lists...

Code:
<content target="$SKINSHORTCUTS[target]">$SKINSHORTCUTS[path]$PYTHON[$SKINSHORTCUTS[autoreload]]</content>

Which all comes together as... if the widget is loading, or hasn't any items, when the window is closed it's specific refresh property is updated on the home window. The widgetPath property - if the widget is a plugin - has that refresh property added to it, with a little Python snippet used so that a '?' or a '&' is used correctly to add it to the URI, so will reload when the home screen is next accessed.

Though maybe have a break before looking into this Wink


RE: script.skinshortcuts - braz - 2016-03-12

(2016-03-12, 21:45)BobCratchett Wrote: Though maybe have a break before looking into this Wink
Got the day off, will try to push through. This looks straight-forward enough, the only question I have is where the propertyGroup goes. Inside the first template, outside of the templates?


RE: script.skinshortcuts - BobCratchett - 2016-03-12

The property group is defined outside of an individual template, and referenced within the template with <propertyGroup>[name]</propertyGroup>. Link to the relevant docs. (It, and the python snippets, are both features of v1.0.8 and so not yet available on the repo).


RE: script.skinshortcuts - braz - 2016-03-12

(2016-03-12, 22:18)BobCratchett Wrote: The property group is defined outside of an individual template, and referenced within the template with <propertyGroup>[name]</propertyGroup>. Link to the relevant docs. (It, and the python snippets, are both features of v1.0.8 and so not yet available on the repo).
Ah, I hadn't updated skinshortcuts from github!

After updating to 1.08, however, I get an error that the menu can't be built. I don't think I'm missing any dependencies, ideas?

Here's my log...

http://goo.gl/DcXGXV

Thanks!


RE: script.skinshortcuts - BobCratchett - 2016-03-12

You haven't defined the property 'path' Wink

Either <property name="path" tag="property" attribute="name|widgetPath" />, or update path in the python snippet to whatever you've named the property you keep the widgetPath in - so if it's called widgetPath, for example, the snippet would be:-

Code:
<property name="autoreload">autoreloadStringAnd %( id ) if widgetPath in 'plugin' and widgetPath in '?' else autoreloadStringQuestion %( id ) if widgetPath in 'plugin' else ''</property>



RE: script.skinshortcuts - braz - 2016-03-12

Hmm, I have path defined, but probably have placement wrong...

Is the propertyGroup in the wrong place?

Code:
<template>
    <propertyGroup name="mainmenuWidgets">
        <property name="id" tag="mainmenuid" />
        <property name="path" tag="property" attribute="name|widgetPath" />
        <property name="target" tag="property" attribute="name|widgetTarget" />

        <!-- Python snippets -->
        <property name="autoreload">autoreloadStringAnd %( id ) if path in 'plugin' and path in '?' else autoreloadStringQuestion %( id ) if path in 'plugin' else ''</property>
        <property name="autoreloadStringAnd">&amp;igConq=$INFO[Window.Property(refresh8011%s)]</property>
        <property name="autoreloadStringQuestion">?igConq=$INFO[Window.Property(refresh8011%s)]</property>
    </propertyGroup>
    <other include="widget-fixed">
        <propertyGroup>mainmenuWidgets</propertyGroup>
        .....
    </other>
</template>



RE: script.skinshortcuts - BobCratchett - 2016-03-12

That looks correct, though it's never easy to be sure from a snippet. Are you still getting the same error in the log? For reference, the error in the previous log was:

Code:
NameNotDefined: 'path' is not defined for expression 'autoreloadStringAnd %( id ) if path in 'plugin' and path in '?' else autoreloadStringQuestion %( id ) if path in 'plugin' else '''

If it helps, here's the property group in my own template.xml, one place I pull it into a template and one where I use the snippet.


RE: script.skinshortcuts - braz - 2016-03-12

Still the same error.

In the following code, what is igConq? The name of your skin? Is there something specific I need to use there?

Code:
<property name="autoreloadStringAnd">&amp;igConq=$INFO[Window.Property(refresh8011%s)]</property>
<property name="autoreloadStringQuestion">?igConq=$INFO[Window.Property(refresh8011%s)]</property>



RE: script.skinshortcuts - BobCratchett - 2016-03-13

Yes, just the name of my skin mod. It shouldn't matter what you use there, so long as it doesn't interfere with any properties the plugin might actually be expecting to receive.


RE: script.skinshortcuts - BobCratchett - 2016-03-13

Just quickly added it to the fork of Mimic on my own git (updated against your Master), and it all seems to build fine. If that doesn't work for you, then I can only conclude there's some differences in how simpleeval (the library that skin shortcuts is using to evaluate these python snippets) works on different platforms... (I have only tested Mac + Linux)


RE: script.skinshortcuts - braz - 2016-03-13

I'm on Windows, I got it to work by adding the following to my propertyGroup...

Code:
<propertyGroup name="mainmenuWidgets">
        <property name="id" tag="mainmenuid" />
        <property name="path" tag="property" attribute="name|widgetPath" />
        <property name="target" tag="property" attribute="name|widgetTarget" />
        <property name="path"></property>
        <property name="target"></property>

        <!-- Python snippets -->
        <property name="autoreload">autoreloadStringAnd %( id ) if path in 'plugin' and path in '?' else autoreloadStringQuestion %( id ) if path in 'plugin' else ''</property>
        <property name="autoreloadStringAnd">&amp;mimic=$INFO[Window.Property(refresh8011%s)]</property>
        <property name="autoreloadStringQuestion">?mimic=$INFO[Window.Property(refresh8011%s)]</property>
</propertyGroup>

But now I get the following ExtendedInfo error for one of my widget paths.

Code:
14:29:58 T:5556   ERROR: XFILE::CDirectory::GetDirectory - Error getting plugin://script.extendedinfo/?info=youtubeusersearch&&id=Eurogamer&mimic=

I see it added &mimic= to the end of the path, which is the identifier used in my autoreloadStringAnd property. Not sure what the empty path and target properties I added to the propertyGroup do.

Going to take a look at your commit now. Smile


RE: script.skinshortcuts - BobCratchett - 2016-03-13

Ah, that makes sense.

These two both pull out the relevant property from the menu item. If the menu item doesn't have the property, they won't be set.

Code:
<property name="path" tag="property" attribute="name|widgetPath" />
<property name="target" tag="property" attribute="name|widgetTarget" />

Whereas these set the relevant properties to an empty string, if they haven't already been set.

Code:
<property name="path"></property>
<property name="target"></property>

So you must have templates that are building where the widgetPath isn't actually set (and so the python snippet is quite correctly saying that 'path' doesn't exist). The property fallbacks you've added are absolutely the right way to go about it. The double && in the path looks wrong, but that really shouldn't be caused by anything you're doing with the snippet...


RE: script.skinshortcuts - braz - 2016-03-13

I see in your igConq template.xml you used:

Code:
$PYTHON[$SKINSHORTCUTS[autoreload]]

But in the Mimic template you used:

Code:
$PYTHON[autoreload]

Do they both work?


RE: script.skinshortcuts - braz - 2016-03-13

You're right, I need to take a break...off to lunch. Smile

Couldn't get the autoreload stuff to work with plugin paths no matter what I tried. Worked fine with local library paths though.


RE: script.skinshortcuts - BobCratchett - 2016-03-13

They do both work, but don't follow my example in igConq Smile I'm still learning what these python snippets can do and how to use them (they were actually added because a skinner requested a way to do simple maths but, as it often goes, doing that in a safe and secure manner meant the easiest way was to use the simpleeval library which has opened up a lot of other possibilities), so the $PYTHON[$SKINSHORTCUTS[]] is a remnant of an early attempt.

As I say it does work, but it has more potential issues - for example if there's a square bracket in the $SKINSHORTCUTS[] property (which is to say, the value associated with that property) it will cause a build failure. Accessing the property directly by name should be a lot less unexpected-error-prone.

Enjoy your lunch, I'm off to bed myself Smile