accentued char inside label :(
#1
Sad 
this code work until 'éèàïù....' char are inside the KODI Label Sad

Code:
json_result = xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method" : "VideoLibrary.GetMovies", "params": {"filter":{"actor":"%s"},"properties":["thumbnail","year","file","art","imdbnumber","cast"]}, "id":1 }' %(xbmc.getInfoLabel("ListItem.Label")) )

under web browser work nice :
Quote:http://127.0.0.1:8080/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.GetMovies","params":{"filter":{"actor":"Laurence Arné"},"properties":["thumbnail","year","file","cast"]},"id":"1"}
but not inside my python code with xbmc.executeJSONRPC...

utf, utf8, ascii , encode, decode...all tested....it's a nightmare with python !

May be someone know how to get the actor id and not the name ? it would be a solution for me.....

Someone can HELP ME ?
Intel NUC 5YPPH-8Go-SSD120go-external drive 1To
Windows 10 PRO - Kodi Krypton 17 - IconMix
Reply
#2
Try
Code:
xbmc.executeJSONRPC(u' ... ')
or
Code:
xbmc.getInfoLabel("ListItem.Label").encode('utf-8')

It's one of the things why I have changed my opinion about possible upgrade to Python 3 in Kodi -- this str/unicode mess needs to be cleaned for good.
Reply
#3
(2017-04-09, 23:13)Roman_V_M Wrote: Try
Code:
xbmc.executeJSONRPC(u' ... ')
or
Code:
xbmc.getInfoLabel("ListItem.Label").encode('utf-8')

It's one of the things why I have changed my opinion about possible upgrade to Python 3 in Kodi -- this str/unicode mess needs to be cleaned for good.

both don't work....
anyway, thank for your reply.....

Kodi call my plugin with this :
Code:
plugin://script.iconmixtools/?action=gettvfilmacteur&infotype=movie&id=Laurence Arné&local="oui"

But Python don't like non-us char.....
Intel NUC 5YPPH-8Go-SSD120go-external drive 1To
Windows 10 PRO - Kodi Krypton 17 - IconMix
Reply
#4
(2017-04-10, 08:40)telexxingou Wrote: But Python don't like non-us char.....

Python likes non-ASCII characters perfectly well. But in Python 2 you need to follow simple rules when dealing with textual data: unicode is for humans and str is for machine, and when textual data leave your program boundary they need to be encoded into a binary form (str) using an appropriate encoding ('utf-8' in most cases). The reverse is true for the data that arrive into your program: binary data need to be decoded into unicode using the same encoding they have been coded with. Unfortunately, in the latter case you may not have control over the other side so in case of encoding mismatch you need to find some workarounds.

This rule applies to URLs as well and your plugin call URL should not contain non-encoded Unicode codepoints in the first place so, ideally, your URL should look like this:

Code:
plugin://script.iconmixtools/?action=gettvfilmacteur&infotype=movie&id=Laurence%20Arn%C3%A9&local="oui"

To achieve this u''Laurence Arné' text need to be encoded into str with utf-8 and only then you can feed it to urllib.urlencode(). When parsing a paramstring you need to use a reverse process.

Unfortunately, the ability to use str type both for textual and binary data in Python 2 led to all this UnicodeXXXError mess. BTW, in Python 3 the abovementioned rule is enforced by design.
Reply
#5
Sorry i really need your help.....

Inside my XML skin file, this is the list control who contain :
Code:
<content>plugin://script.iconmixtools/?action=gettvfilmacteur&infotype=movie&id=$INFO[ListItem.Label]&local="oui"</content>

where ListItem.Label can be 'Laurence Arné' or 'Noémie Tartampion' .... with 'éàùè....' char ....

My Pyhton code get this parameter from this calling and do xbmc.executeJSONRPC command.....

for example ,
can you explain to me how can i call
Code:
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method" : "VideoLibrary.GetMovies", "params": {"filter":{"actor":"%s"},"properties":["thumbnail","year","file","art","imdbnumber","cast"]}, "id":1 }' %(xbmc.getInfoLabel("ListItem.Label")) )

to work even ListItem.Label contain 'éàèù....' and so to get all movies for actor name inside ListItem.Label ?

May be adding 'Id Actor' in cast list would be more easy to retrieve Actor's movie and not searching by his name...but it's not the subject here ....

Sorry but i'm confuse with this ....problem.....

thank you
Intel NUC 5YPPH-8Go-SSD120go-external drive 1To
Windows 10 PRO - Kodi Krypton 17 - IconMix
Reply
#6
First, I need to note that I have absolutely no knowledge of skinning.

And you are contradicting yourself:

Quote:My Pyhton code get this parameter from this calling and do xbmc.executeJSONRPC command.....

From what I see, you are calling xbmc.getInfoLabel("ListItem.Label"), and not taking actor's name from a plugin call parameters.

And please describe your problem with as much detail as possible along with links to Kodi debug logs taken when issues occur. Descriptions like "it works" and "it does not work" absolutely non-informative.

BTW, I tried this code in my setup:
Code:
# coding: utf-8

import xbmc

actor = u'Laurence Arné'
js_req = '{ "jsonrpc": "2.0", "method" : "VideoLibrary.GetMovies", "params": {"filter":{"actor":"%s"},"properties":["thumbnail","year","file","art","imdbnumber","cast"]}, "id":1 }'
resp = xbmc.executeJSONRPC(js_req % actor.encode('utf-8'))

xbmc.log(resp, xbmc.LOGNOTICE)

The response returned 0 results (I have no movies with such actor) but no errors happened. However, xbmc.getInfoLabel returns a str object so I guess it's already encoded.
Reply

Logout Mark Read Team Forum Stats Members Help
accentued char inside label :(0