Kodi Community Forum
$ESCINFO doesn't seem to work - 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)
+--- Thread: $ESCINFO doesn't seem to work (/showthread.php?tid=355938)



$ESCINFO doesn't seem to work - roidy - 2020-07-19

I'm passing Container.ShowName into a custom script  to fill the content of a list like so:-

xml:
<content type="video">plugin://script.seasonjump/?action=getSeasons&showName=$INFO[Container.ShowTitle]</content>

However it fails if any of the Show Titles contain an & symbol, which is to be expected, & symbols separate the parameters. 

So looking at the wiki I see there is an $ESCINFO version of $INFO, but changing my code to:-

xml:
<content type="video">plugin://script.seasonjump/?action=getSeasons&showName=$ESCINFO[Container.ShowTitle]</content>

Still does not work, the & symbols aren't being escaped Sad Any ideas on how to deal with this? Thanks


Edit:- So again it's just easier to do this in python using

python:
showTitle = xbmc.getInfoLabel('Container.ShowTitle')

Still doesn't explain why $ESCINFO fails to escape the string properly.


RE: $ESCINFO doesn't seem to work - sualfred - 2020-07-23

$ESCINFO just escapes the whole string.

Code:
Superduperstring, with special chars & other stuff
->
Code:
"Superduperstring, with special chars & other stuff"

In my Embuary helper script I use a small helper function to clean this quoted string:
Code:

def remove_quotes(label):
    if not label:
        return ''

    if label.startswith("'") and label.endswith("'") and len(label) > 2:
        label = label[1:-1]

        if label.startswith('"') and label.endswith('"') and len(label) > 2:
            label = label[1:-1]
        elif label.startswith('&quot;') and label.endswith('&quot;'):
            label = label[6:-6]

    return label

To prevent any other issues you have to quote it twice for your content call. Like so:
Code:
<content type="video">plugin://script.seasonjump/?action=getSeasons&showName='$ESCINFO[Container.ShowTitle]'</content>
or
Code:
<content type="video">plugin://script.seasonjump/?action=getSeasons&showName='"$INFO[Container.ShowTitle]"'</content>



RE: $ESCINFO doesn't seem to work - roidy - 2020-07-23

Thank you for the reply, but unfortunately when dealing with url's and query strings wrapping the value in quotes won't work.

plugin://script.seasonjump/?action=someaction&title=sometitle

This is effectively a url and a query string, and the query strings parameters are separated by an & symbol, so if you want to include an & symbol in the value of one of the parameters then it needs to be correctly encoded. No amount of wrapping it in quotes will do this.

For instance, and I have tested this.

?action=action1&title=my title

Gets split into:
ParamValue
actionaction1
titlemy title

?action=action1&title=my title & some more

Gets split into:
ParamValue
actionaction1
titlemy title
Exactly the same because the extra & some more gets split into a new parameter with no value

Now if we wrap it in quotes like you suggest then
?action=action1&title='"my title & some more"'

Gets split into:
ParamValue
actionaction1
title'"my title

In order for it to work the & symbol needs to be properly encoded into %26 which $ESCINFO or wrapping with quotes does not do Sad


RE: $ESCINFO doesn't seem to work - sualfred - 2020-07-23

I'm using something like this:

https://github.com/sualfred/script.embuary.helper/blob/matrix/plugin.py#L27-L41


RE: $ESCINFO doesn't seem to work - roidy - 2020-07-24

(2020-07-23, 22:39)sualfred Wrote: I'm using something like this:

https://github.com/sualfred/script.embuary.helper/blob/matrix/plugin.py#L27-L41

Thanks