try to get PVR uniqueID via JSON
#1
I try to mod a addon (THHifgLights) cause I would need one more property from the addon.
I wood need the PVR uniqueID... So tried to "copie" existent Property...

but I allway get the an error:

Quote:Error Contents: global name 'uniqueid' is not defined

I tried as follow:

Code:
def channelName2uniqueId(channelname):
    query = {
            "jsonrpc": "2.0",
            "method": "PVR.GetChannels",
            "params": {"channelgroupid": "alltv"},
            "id": 1
            }
    res = json.loads(xbmc.executeJSONRPC(json.dumps(query, encoding='utf-8')))
    #debug(res)
    # translate via json if necessary
    trans = json.loads(str(ChannelTranslate))
    for tr in trans:
        if channelname == tr['name']:
            debug("Translating %s to %s" % (channelname,tr['pvrname']))
            channelname = tr['pvrname']
    
    if 'result' in res and 'channels' in res['result']:
        res = res['result'].get('channels')
        for channels in res:
            #debug("TVHighlights %s - %s" % (channels['label'],channelname))
            # priorize HD Channel
            if channelname+" HD".lower() in channels['label'].lower():
                debug("TVHighlights found  HD priorized channel %s" % (channels['label']))
                return channels['uniqueid']
            if channelname.lower() in channels['label'].lower():
                debug("TVHighlights found  channel %s" % (channels['label']))
                return channels['uniqueid']
    return 0

so how can I define the name... I did not find it...
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#2
next try.... but also without success...

Code:
def channelName2uniqueId(channelname):
    query = {
            "jsonrpc": "2.0",
            "method": "PVR.GetChannels",
            "params": {"channelgroupid": "alltv"},
            "id": 1
            }
    res = json.loads(xbmc.executeJSONRPC(json.dumps(query, encoding='utf-8')))
    #debug(res)
    # translate via json if necessary
    trans = json.loads(str(ChannelTranslate))
    for tr in trans:
        if channelname == tr['name']:
            debug("Translating %s to %s" % (channelname,tr['pvrname']))
            channelname = tr['pvrname']
    if 'result' in res and 'channels' in res['result']:
        res = res['result'].get('channels')
        for channels in res:
            #debug("TVHighlights %s - %s" % (channels['label'],channelname))
            # priorize HD Channel
            if channelname+" HD".lower() in channels['label'].lower():
                debug("TVHighlights found  HD priorized channel %s" % (channels['label']))
                try:
                    if channels['uniqueid']:
                        return channels['uniqueid']
                except:
                    debug("bbb")
            if channelname.lower() in channels['label'].lower():
                debug("TVHighlights found  channel %s" % (channels['label']))
                try:
                    if channels['uniqueid']:
                        return channels['uniqueid']
                except:
                    return '-'
    return 0

it alway give "-" back. so it don't find the uniqueid...

Image

for the channelid it work...

Code:
def channelName2channelId(channelname):
    query = {
            "jsonrpc": "2.0",
            "method": "PVR.GetChannels",
            "params": {"channelgroupid": "alltv"},
            "id": 1
            }
    res = json.loads(xbmc.executeJSONRPC(json.dumps(query, encoding='utf-8')))
    #debug(res)
    # translate via json if necessary
    trans = json.loads(str(ChannelTranslate))
    for tr in trans:
        if channelname == tr['name']:
            debug("Translating %s to %s" % (channelname,tr['pvrname']))
            channelname = tr['pvrname']
    
    if 'result' in res and 'channels' in res['result']:
        res = res['result'].get('channels')
        for channels in res:
            #debug("TVHighlights %s - %s" % (channels['label'],channelname))
            # priorize HD Channel
            if channelname+" HD".lower() in channels['label'].lower():
                debug("TVHighlights found  HD priorized channel %s" % (channels['label']))
                return channels['channelid']
            if channelname.lower() in channels['label'].lower():
                debug("TVHighlights found  channel %s" % (channels['label']))
                return channels['channelid']
    return 0

so any Idea what I'm doing wrong?
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#3
uniqueId is not available before a less than a week alpha of Kodi Wink
Reply
#4
Thanks for your answer...

I've tried yesterday Alpha without success too...
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#5
Well that's a lot of .........

You must also of course as the Wiki and sample explains, ask for the field to be returned Wink

Hint : (,"properties":["uniqueId"])
Reply
#6
okay, new try...

you mean in this way?

PHP Code:
query = {
            
"jsonrpc""2.0",
            
"method""PVR.GetChannelDetails",
            
"params": {"channelid"channelid"properties": ["uniqueid"]},
            
"id"1
            
}
    
res json.loads(xbmc.executeJSONRPC(json.dumps(queryencoding='utf-8')))
    
debug(res)
    if 
'result' in res and 'channeldetails' in res['result'] and 'uniqueid' in res['result']['channeldetails']:
        return 
res['result']['channeldetails']['uniqueid']
    else:
        return 


returned the following error:

Quote: 17:51:55 T:3316 DEBUG: {u'jsonrpc': u'2.0', u'id': 1, u'error': {u'message': u'Invalid params.', u'code': -32602, u'data': {u'method': u'PVR.GetChannelDetails', u'stack': {u'message': u'Invalid type string received', u'type': u'integer', u'name': u'channelid'}}}}
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#7
Well the error message is quite clear no ? Smile

It says you sent a string as channelid when it expect an integer.

You are seeking more for python support to start than JSON here )
Reply
#8
(2016-02-14, 20:00)Tolriq Wrote: You are seeking more for python support to start than JSON here )

it seems to be so... Confused
it's will be my first mod od a script so my python knowledge is verry limited....
but with every step I learn a little bit mor....

(2016-02-14, 20:00)Tolriq Wrote: It says you sent a string as channelid when it expect an integer.

ah so this part is wrong
PHP Code:
"params": {"channelid"channelid"properties": ["uniqueid"]}, 

it should be more than this?

PHP Code:
"params": {"channelid"int(channelid), "properties": ["uniqueid"]}, 
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#9
I have no idea I do not use / know python and I doubt many python devs looks here Wink
Reply
#10
okay...

thanks... will see that I find a answer elsewhere...
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#11
As Tolriq states you need a pretty recent build of krypton and to query channeldetails you need to pass the id of the channel as integer. Below are two examples:

Code:
http://127.0.0.1:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "PVR.GetChannels", "params": {"channelgroupid": "alltv", "properties" :["uniqueid"]},"id": 1}

http://127.0.0.1:8080/jsonrpc?request={"jsonrpc": "2.0", "method": "PVR.GetChannelDetails", "params": {"channelid": 5, "properties" :["uniqueid"]},"id": 1}

Note that 5 is different from "5".
Reply
#12
many thanks enen92...

I think now I got it...

PHP Code:
def channelName2uniqueId(channelname):
    
query = {
            
"jsonrpc""2.0",
            
"method""PVR.GetChannels",
            
"params": {"channelgroupid""alltv""properties" :["uniqueid"]},
            
"id"1
            
}
    
res json.loads(xbmc.executeJSONRPC(json.dumps(queryencoding='utf-8')))
    
debug(res)
    
# translate via json if necessary
    
trans json.loads(str(ChannelTranslate))
    for 
tr in trans:
        if 
channelname == tr['name']:
            
debug("Translating %s to %s" % (channelname,tr['pvrname']))
            
channelname tr['pvrname']
    
    if 
'result' in res and 'channels' in res['result']:
        
res res['result'].get('channels')
        for 
channels in res:
            
#debug("TVHighlights %s - %s" % (channels['label'],channelname))
            # priorize HD Channel
            
if channelname+" HD".lower() in channels['label'].lower(): 
                
debug("TVHighlights found  HD priorized channel %s" % (channels['label']))
                return 
channels['uniqueid']
            if 
channelname.lower() in channels['label'].lower(): 
                
debug("TVHighlights found  channel %s" % (channels['label']))
                return 
channels['uniqueid']
    return 


seems to work now....
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#13
one more question...

I tried to start the VideoPlayer via JSON... I want to start the PVR channel by using the channelid

example:
PHP Code:
query = {
        
"jsonrpc""2.0",
        
"id"1,
        
"method""Player.Open",
        
"params": {"item": {"channelid"57}}
        }
res jsonrpc(query

starts the OVR-Channel with ID 57...

My goal is to use the channelID which I wont to get from xbmc.getInfoLabel('ListItem.channelid')

the Listitem I will get from here:

Code:
<onclick>RunScript(service.channel_switch,channelid=$INFO[Window(Home).Property(TVHighlightsToday.Info.PVRID)])</onclick>

is it ossible to put in the line with "params":{"item": {"channelid": xbmc.getInfoLabel('ListItem.channelid')}
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#14
I payed a liitke bit around and get the following

PHP Code:
query = {
        
"jsonrpc""2.0",
        
"id"1,
        
"method""Player.Open",
        
"params": {"item": {"channelid": {xbmc.getInfoLabel('Window(Home).Property(TVHighlightsToday.Info.PVRID)')}}}
        }
res jsonrpc(query

I get the following error

Code:
Error Type: <type 'exceptions.TypeError'>
Error Contents: set(['42']) is not JSON serializable

the 42 is the right channelid but it seems to be a wrong type...


EDIT:

get it work...

PHP Code:
query = {
        
"jsonrpc""2.0",
        
"id"1,
        
"method""Player.Open",
        
"params": {"item": {"channelid"int(xbmc.getInfoLabel('Window(Home).Property(TVHighlightsToday.Info.PVRID)'))}}
        }
res jsonrpc(query
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply
#15
Hello,

I've a nother question reg. json request...

I tried to get the imdbid by TvShow-name...

Code:
query = {
           "jsonrpc": "2.0",
           "method": "VideoLibary.GeTVShowDetails",
            "params": {"?": "?"},
            "imdbnumber": 1

but I realy don't now how toset the right params...
Board: B85M-ITX
CPU: i3 4330
GPU: Geforce GTX 750ti
Reply

Logout Mark Read Team Forum Stats Members Help
try to get PVR uniqueID via JSON0