MikeSiLVO/script.skinshortcuts

[Bug?] Just Select method doesn't work from Python scripts

Closed this issue · 10 comments

I'm attempting to create an add-on that features path choosing, and was looking to use the "Just Select" method of setting shortcuts/widgets for it. I've tried the following code in Python:

# broken into lines for easier readability
xbmc.executebuiltin("RunScript(script.skinshortcuts,type=widgets
    &showNone=False
    &skinWidgetType=autoWidgetType-1
    &skinWidgetName=autoWidgetName-1
    &skinWidgetTarget=autoWidgetTarget-1
    &skinWidgetPath=autoWidgetPath-1)")

And expecting the autoWidgetType-1, autoWidgetName-1, autoWidgetTarget-1, and autoWidgetPath-1 skin strings to be filled. After executing this line, and selecting my shortcut in the select dialog, these skin strings are never updated.

I have also tried the alternative method:

# broken into lines for easier readability
xbmc.executebuiltin("RunScript(script.skinshortcuts,type=shortcuts
    &skinLabel=autoLabel-1
    &skinAction=autoAction-1
    &skinList=autoSkinList-1)")

I am able to successfully set skin strings this way by setting the above RunScript(...) calls into the action of a skin shortcut, defined inside Kodi, or by manually editing the .xml file.

Similar methods from other add-ons seem to work, like from Skin Helper, successfully setting the skin string I've defined in the script call, even when called from Python.

For clarity, I am watching these skin strings in real-time via webinterface.devhelper.

For the record, the (what the script docs refer to as the) just-select methods were never designed to be called from another script. This script isn't designed for these variables to be passed on to another script, so I'm sure you understand that such behaviour isn't officially supported.

Having said that, can I clarify exactly what the issue is here - the type=widgets isn't working - is that it? Is that all?

Can we also please have a full debug log, preferably with Skin Shortcuts own debug logging option enabled from its settings.

The issue isn't that the call doesn't work, as the select dialog does show up, and allows me to select a shortcut/widget, but it never updates the specified skin strings.

I can furnish a log a little bit later today, and I'll make sure to give a full debug log, including Skin Shortcuts' own debug mode.

My plan with this is to let the script update the skin strings, then grab them back from the skin into my own script.

Would this work if I was to build my own custom management dialog, separate from the skin?

I look forward to your debug logs, as obviously these skin string should be set when called and I'm sure we'll be able to work out why they aren't being.

Yes, its possible that you can use these strings, whether via your own custom management dialog or another method. However, because you're using the script in a way it wasn't designed for, even when we fix this current issue we obviously can't make any guarantees that this will continue to work when any updates to this script are made.

A potential - permanent - solution, though no means ideal, is to fork the script and pull out the relevant code (mostly in library.py) into your own script, so that you aren't relying on a third-party-script-that-could-potentially-break going forward.

The absolutely ideal solution would be for someone to pull out all of the library.py script code (the code primarily responsible for loading all of the available shortcuts and allowing the user to browse it) into its own script that could then be updated independently of any and all third party scripts, including the Skin Shortcuts script...

Here is a full debug log (including Skin Shortcuts debug), on a clean instance: https://pastebin.com/fTnhsQqX

This instance only had Arctic Zephyr 2 and its most current dependencies, this version of Skin Shortcuts, and my add-on (plugin.program.autowidget, I know, very creative 😆)

In that log, I made sure to show not only the path in which I trigger Skin Shortcuts via my add-on (first, for "Popular Movies" in TheMovieDb Helper), and then from a skin shortcut action (second, for "Top Rated Movies", again in TheMovieDb Helper). Both of these operations use the exact same code to trigger Skin Shortcuts:

RunScript(script.skinshortcuts,type=widgets&showNone=False&skinWidgetType=autoWidgetType-1&skinWidgetName=autoWidgetName-1&skinWidgetTarget=autoWidgetTarget-1&skinWidgetPath=autoWidgetPath-1)

With the notable exception that in my add-on, it is called via xbmc.executebuiltin(...).

Thanks very much for the debug log.

There's nothing immediately apparent - which is to say there are no obvious errors occurring when the script is being called with the type=widgets call.

I'll see if I can recreate your issue over the next few days but, just to be certain, can you confirm if you're using the Python 2 or the Python 3 version of the script?

@BobCratchett If I'm not mistaken, the version I used for those logs was the version from master. I did first notice the behavior in the version in the official repo, and it is also present in the version on @marcelveldt's repo.

Thanks for the confirmation. Though I'm 99.9% certain of the answer, it would be appreciated if you could confirm what version (exactly) of Kodi you're running. From all of that, I'll do my best to re-recreate your issue over the next few days so we can get it fixed :)

@BobCratchett Oh, Kodi version? That log was generated using Kodi 18.5 (37f51f6e63), with xbmc.python 2.26.0.

OK, not that I've had chance to try to re-create this yet, but your answer leads to certain possibilities. From what I understand, Mike's current Master branch targets Kodi v19 (which supports Python v3x), whereas you're using Kodi 18 (which targets Python v2x). Can you please ensure you're using a Kodi 18/Python 2 version of the script (delete any Mike Silvo repository, and 'upgrade' through Settings > Addon-ons to the current repo version) OR a Kodi 19 (manually install)/Pythonv3 version (manually install) of the script. If still not working, please provide an updated debug log.

I actually was able to figure out what was going wrong here: When calling from Python, the path should have & instead of & 🤦‍♀