Kodi Community Forum

Full Version: How to get pvr recorded tv item id and make it play
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi!

I'm using a bit of scripting so that i can pause a film or downloaded tv item and continue it playing on another kodi box:

 --query currently playing
       sendToKodi('192.168.2.105','{"jsonrpc":"2.0","method":"Player.GetItem","params":{"properties":[],"playerid":1},"id":"VideoGetItem"}')

then i note the type and id of the item playing:
 --store id and type playing
        if string.len(FullResult) > 0 then
            PausedType=string.sub(FullResult, string.find(FullResult,"type")+7, -5)
            idstart=string.find(FullResult,"item")+12
            idend=string.find(FullResult,",",idstart)-1
            PausedID=string.sub(FullResult,idstart,idend)
            print(PausedType.."  "..PausedID)
        end

then i start it on the other kodi player:
--start movie/tv show playing with resume
            if PausedType == 'movie' then
                sendToKodi('192.168.2.140','{"jsonrpc":"2.0","id":"1","method":"Player.Open","params":{"item":{"movieid":'..PausedID..'},"options":{"resume":true}}}')
            end
            if PausedType == 'episode' then
                sendToKodi('192.168.2.140','{"jsonrpc": "2.0","id": "1","method":"Player.Open","params":{"item":{"episodeid":'..PausedID..'},"options":{"resume":true}}}')
            end


Question: How do i do the same for pvr items (mostly recorded but live would be great too) ?

The Player.GetItem doesn't have id's for pvr items Sad


Thanks!
Any ideas out there? Smile
I wrote a little addon for my personal use which displays the currently played media on my various kodi-machines in the house. It is probably not hte best style but it does the job. This piece of python code you might find useful with respect to how to query and process the info you're looking for:

        player = json_request('Player.GetActivePlayers', None, host)      
        if player and player[0]['type'] in ['audio', 'video']:
            player_id = player[0]['playerid']
            data = json_request('Player.GetItem',{'properties': ['title', 'file', 'showtitle', 'album', 'artist', 'track'], 'playerid': player_id}, host)

            if data:
                try:
                    if data['item']['type'] == 'channel':
                        item = '{} (IP: {}): \"{}\" ({}: {})'.format(hostname, host, data['item']['title'].encode('utf-8'), ['Radio', 'TV'][player_id], data['item']['label'])
                    elif data['item'].has_key('file') and urllib2.unquote(data['item']['file'].encode('utf-8'))[:6] == 'pvr://':
                        item = '{} (IP: {}): \"{}\" ({})'.format(hostname, host, data['item']['title'].encode('utf-8'), __localize__(30054))
                    elif data['item']['type'] == 'song' and data['item'].has_key('artist') and data['item'].has_key('album') and data['item'].has_key('track'):
                        item = '{} (IP: {}): \"{}: {} - {:02d}: {}\" ({})'.format(hostname, host, data['item']['artist'][0].encode('utf-8') , data['item']['album'].encode('utf-8'), data['item']['track'], data['item']['label'].encode('utf-8'), data['item']['type'])
                    elif data['item']['type'] == 'musicvideo' and data['item'].has_key('artist'):
                        item = '{} (IP: {}): \"{}: {}\" ({})'.format(hostname, host, data['item']['artist'][0].encode('utf-8'), data['item']['label'].encode('utf-8'), data['item']['type'])
                    elif data['item']['type'] == 'episode' and data['item'].has_key('showtitle'):
                        item = '{} (IP: {}): \"{} - {}\" ({})'.format(hostname, host, data['item']['showtitle'].encode('utf-8'), data['item']['label'].encode('utf-8'), data['item']['type'])
                    else:
                        item = '{} (IP: {}): \"{}\" ({})'.format(hostname, host, data['item']['label'].encode('utf-8'), data['item']['type'])

                except:
                    item = '{} (IP: {}): \"{}\" ({})'.format(hostname, host, data['item']['label'].encode('utf-8'), data['item']['type'])
Ah many thanks, i forgot to subscribe to this thread so only just saw your response Smile

Cheers!
I'm still trying to get this working - has anyone got any ideas?

Cheers!
I don't know if the recording ID is usable to start playback of a particular recording, but you can pull out details of all recordings with
{"jsonrpc": "2.0", "method": "PVR.GetRecordings", "params": {"properties":["title","channel","file","directory"],"limits":{"start":0}}, "id": 1}

You could parse the results to get titles and directory/file locations and then start playback using the file location.  Even though it's not specified in the parameters, the line above does return a recording ID but the script I use gets the path and filename to start the playback.
(2019-09-25, 18:04)black_eagle Wrote: [ -> ]I don't know if the recording ID is usable to start playback of a particular recording, but you can pull out details of all recordings with
{"jsonrpc": "2.0", "method": "PVR.GetRecordings", "params": {"properties":["title","channel","file","directory"],"limits":{"start":0}}, "id": 1}

You could parse the results to get titles and directory/file locations and then start playback using the file location.  Even though it's not specified in the parameters, the line above does return a recording ID but the script I use gets the path and filename to start the playback.
Thanks buddy Smile

I decided to use the file name as suggested Smile