Kodi Community Forum
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174)
+---- Thread: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC (/showthread.php?tid=68263)



- Montellese - 2012-01-07

yallah Wrote:Hi,

No possibility to put methods :
"LiveTV.GetChannelGroupDetails"
"LiveTV.GetChannels"
"LiveTV.GetChannelDetails"
"LiveTV.GetEpgDetails"

like you did : https://github.com/Montellese/xbmc/tree/pvr


Regards

Uhm I'm not sure if you are asking me something or if you just stated a fact. The work I did in my PVR branch is not available anywhere except in there and it's heavily outdated as I don't have the time to continue working on it so these can't be used.


- yallah - 2012-01-07

Montellese Wrote:Uhm I'm not sure if you are asking me something or if you just stated a fact. The work I did in my PVR branch is not available anywhere except in there and it's heavily outdated as I don't have the time to continue working on it so these can't be used.

Oh sorry it's question. I ll try to parse tv channel thru databases sqlite tv and epg.

Regards


- giftie - 2012-01-07

null_pointer Wrote:There might be a problem with empty directories and the response form GetDirectory

http://forum.xbmc.org/showpost.php?p=973729&postcount=5

the response fails eval()

You can use a json library as Montellese describes, or to use eval() the json responce by declaring values before the eval() I use this method instead of a json lib. See my post here -> http://forum.xbmc.org/showthread.php?tid=100598


- othrayte - 2012-01-08

Hey,

Previously we found a problem with the play/pause/stopped notifications that were created by calls to 'PlayMedia' (usually from a skin) and this affected many skin based add-ons like watchlist etc. whereby the message would always specify type='Movie' and no other info. I was wondering if any progress had been made, or do I need to start a ticket.

My belief was that you could look-up the path requested for playing in the db and convert it back to a libraryid and type. Would that work?

Also a user just found that the same thing occurs with the official remote I can confirm the messages look like this
Code:
{"jsonrpc":"2.0","method":"Player.OnStop","params":{"data":{"item":{"type":"movie"},"title":""},"sender":"xbmc"}}
, which isn't very helpful. Would this need a separate trac ticket if any?

Thanks for the great work, I hope XBMC prospers this year and I can't wait to see Eden finished.


- Montellese - 2012-01-08

othrayte Wrote:Hey,

Previously we found a problem with the play/pause/stopped notifications that were created by calls to 'PlayMedia' (usually from a skin) and this affected many skin based add-ons like watchlist etc. whereby the message would always specify type='Movie' and no other info. I was wondering if any progress had been made, or do I need to start a ticket.

My belief was that you could look-up the path requested for playing in the db and convert it back to a libraryid and type. Would that work?

Also a user just found that the same thing occurs with the official remote I can confirm the messages look like this
Code:
{"jsonrpc":"2.0","method":"Player.OnStop","params":{"data":{"item":{"type":"movie"},"title":""},"sender":"xbmc"}}
, which isn't very helpful. Would this need a separate trac ticket if any?

Thanks for the great work, I hope XBMC prospers this year and I can't wait to see Eden finished.

The problem is essentially the same as reported in http://trac.xbmc.org/ticket/11547

The reason for this is that all media started from a script through the builtin PlayMedia() and everything started through HTTP API are played without properly retrieving the metadata. That's why I introduced the Player.GetItem() method in JSON-RPC which explicitly retrieves the metadata for the currently playing item. This isn't done for announcements because database queries take time and slow other things down.

Ideally the problem would be fixed in XBMC's internal PlayMedia function by looking up metadata based on the path but that's very unlikely to happen for Eden. The other very hacky way (which would only solve JSON-RPC notifications) would be to check both video and music database by path if there's no database id for an item coming through the notification system but I didn't have time yet to look into it.


- othrayte - 2012-01-08

Montellese Wrote:The problem is essentially the same as reported in http://trac.xbmc.org/ticket/11547

The reason for this is that all media started from a script through the builtin PlayMedia() and everything started through HTTP API are played without properly retrieving the metadata. That's why I introduced the Player.GetItem() method in JSON-RPC which explicitly retrieves the metadata for the currently playing item. This isn't done for announcements because database queries take time and slow other things down.

Ideally the problem would be fixed in XBMC's internal PlayMedia function by looking up metadata based on the path but that's very unlikely to happen for Eden. The other very hacky way (which would only solve JSON-RPC notifications) would be to check both video and music database by path if there's no database id for an item coming through the notification system but I didn't have time yet to look into it.
Yeah I can understand that it would be a lot of work, it would be best if it happened eventually but for the moment I'll change my end to make the Player.GetItem() requests (which I hadn't noticed existed) whenever it doesn't get enough data.


- wuench - 2012-01-09

When I issue the command Player.SetAudiostream next or previous the audiostream changes but the movie also rewinds.

Has anyone reported this yet?

Code:
Sending - {"jsonrpc":"2.0","method":"Player.GetProperties","params":{"playerid":1,"properties":["audiostreams","currentaudiostream","currentsubtitle","percentage","speed","subtitleenabled","subtitles","totaltime","time"]},"id":0}
Response - {"id":0,"jsonrpc":"2.0","result":{"audiostreams":[{"index":0,"language":"eng","name":"English - DTS-HD MA 5.1"},{"index":1,"language":"eng","name":"English - AC3 Stereo"},{"index":2,"language":"fra","name":"French - DTS-HD MA 5.1"},{"index":3,"language":"spa","name":"Castilian - AC3 5.1"},{"index":4,"language":"por","name":"Portuguese - DTS-HD MA 5.1"},{"index":5,"language":"","name":"Unknown"}],"currentaudiostream":{"bitrate":2172711,"channels":6,"codec":"dtshd_ma","index":0,"language":"eng","name":"English - DTS-HD MA 5.1"},"currentsubtitle":{"index":0,"language":"English","name":"English"},"[color=Red][b]percentage":6.4103484153747559[/b][/color],"speed":1,"subtitleenabled":true,"subtitles":[{"index":0,"language":"English","name":"English"},{"index":1,"language":"English","name":"English"},{"index":2,"language":"French","name":"French"},{"index":3,"language":"Castilian","name":"Castilian"},{"index":4,"language":"Portuguese","name":"Portuguese"},{"index":5,"language":"French","name":"French"},{"index":6,"language":"English","name":"English"},{"index":7,"language":"Castilian","name":"Castilian"},{"index":8,"language":"Portuguese","name":"Portuguese"}],"time":{"hours":0,"milliseconds":863,"minutes":7,"seconds":26},"totaltime":{"hours":1,"milliseconds":0,"minutes":56,"seconds":10}}}

[b][color=Red]Sending - {"jsonrpc":"2.0","method":"Player.SetAudioStream","params":{"playerid":1,"stream":"next"},"id":0}
Response - {"id":0,"jsonrpc":"2.0","result":"OK"}[/color][/b]

Sending - {"jsonrpc":"2.0","method":"Player.GetProperties","params":{"playerid":1,"properties":["audiostreams","currentaudiostream","currentsubtitle","percentage","speed","subtitleenabled","subtitles","totaltime","time"]},"id":0}
Response - {"id":0,"jsonrpc":"2.0","result":{"audiostreams":[{"index":0,"language":"eng","name":"English - DTS-HD MA 5.1"},{"index":1,"language":"eng","name":"English - AC3 Stereo"},{"index":2,"language":"fra","name":"French - DTS-HD MA 5.1"},{"index":3,"language":"spa","name":"Castilian - AC3 5.1"},{"index":4,"language":"por","name":"Portuguese - DTS-HD MA 5.1"},{"index":5,"language":"","name":"Unknown"}],"currentaudiostream":{"bitrate":255284,"channels":2,"codec":"ac3","index":1,"language":"eng","name":"English - AC3 Stereo"},"currentsubtitle":{"index":0,"language":"English","name":"English"},"[b][color=Red]percentage":4.758997917175293[/color][/b],"speed":1,"subtitleenabled":true,"subtitles":[{"index":0,"language":"English","name":"English"},{"index":1,"language":"English","name":"English"},{"index":2,"language":"French","name":"French"},{"index":3,"language":"Castilian","name":"Castilian"},{"index":4,"language":"Portuguese","name":"Portuguese"},{"index":5,"language":"French","name":"French"},{"index":6,"language":"English","name":"English"},{"index":7,"language":"Castilian","name":"Castilian"},{"index":8,"language":"Portuguese","name":"Portuguese"}],"time":{"hours":0,"milliseconds":748,"minutes":5,"seconds":31},"totaltime":{"hours":1,"milliseconds":0,"minutes":56,"seconds":10}}}

EDIT: Ok it appears to only do it for that one movie (first movie I tried). Haven't been able to duplicate it with others.... So maybe just a screwed up rip?!?


- Montellese - 2012-01-10

othrayte Wrote:Yeah I can understand that it would be a lot of work, it would be best if it happened eventually but for the moment I'll change my end to make the Player.GetItem() requests (which I hadn't noticed existed) whenever it doesn't get enough data.

I justed pushed a commit (https://github.com/xbmc/xbmc/commit/dd0663108ba2c5f674076630e94a8e3e892e19df) which should (temporarily) fix the problem. It does a database lookup if the item passed to the notification manager does not have a valid database id (but only once) and if it finds additional information it will use that in the notification sent out to the clients. I hope this fixes the invalid data in the Player notifications.


- othrayte - 2012-01-10

Montellese Wrote:I justed pushed a commit (https://github.com/xbmc/xbmc/commit/dd0663108ba2c5f674076630e94a8e3e892e19df) which should (temporarily) fix the problem. It does a database lookup if the item passed to the notification manager does not have a valid database id (but only once) and if it finds additional information it will use that in the notification sent out to the clients. I hope this fixes the invalid data in the Player notifications.

Cool thanks, I'll try it out when it gets into a build.


Files.GetDirectory - giftie - 2012-01-10

Has there been some changes to Files.GetDirectory? I use this often in my script Cinema Experience and lately it seems to be broken(from what it used to be)

The call that is made is:
Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "/home/xbmc/Cinema Experience Stuff/Videos/Audio/DTSHD-MA/", "media": "video"}, "id": 1}

The log shows the following:
Code:
22:12:59 T:2718952304   DEBUG: JSONRPC: Incoming request: {"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "/home/xbmc/Cinema Experience Stuff/Videos/Audio/DTSHD-MA/", "media": "video"}, "id": 1}
22:12:59 T:2718952304   DEBUG: JSONRPC: Calling files.getdirectory
22:12:59 T:2718952304   DEBUG: GetMovieId (/home/xbmc/Cinema Experience Stuff/Videos/Audio/DTSHD-MA/hd_dts_orchestra_long_lossless.m2ts), query = select idMovie from movie where idFile=4037
22:12:59 T:2718952304   DEBUG: GetEpisodeId (/home/xbmc/Cinema Experience Stuff/Videos/Audio/DTSHD-MA/hd_dts_orchestra_long_lossless.m2ts), query = select idEpisode from episode where idFile=4037
22:12:59 T:2718952304   DEBUG: GetMusicVideoId (/home/xbmc/Cinema Experience Stuff/Videos/Audio/DTSHD-MA/hd_dts_orchestra_long_lossless.m2ts), query = select idMVideo from musicvideo where idFile=4037
22:12:59 T:2718952304   DEBUG: [json_utils.py] - retrieve_json_dict - JSONRPC -
                                            {
                                                "id": 1,
                                                "jsonrpc": "2.0",
                                                "result": {
                                                    "files": null,
                                                    "limits": {
                                                        "end": 0,
                                                        "start": 0,
                                                        "total": 0
                                                    }
                                                }
                                            }

The Folder does have two videos inside it:
Code:
hd_dts_living_world_of_audio_lossless.m2ts
hd_dts_orchestra_long_lossless.m2ts

If I drop the "media": "video", or use "media": "files" I do get the full directory back:
Code:
{
    "id": 1,
    "jsonrpc": "2.0",
    "result": {
        "files": [
            {
                "file": "/home/xbmc/Cinema Experience Stuff/Videos/Audio/DTSHD-MA/hd_dts_orchestra_long_lossless.m2ts",
                "filetype": "file",
                "label": "hd_dts_orchestra_long_lossless.m2ts",
                "type": "unknown"
            },
            {
                "file": "/home/xbmc/Cinema Experience Stuff/Videos/Audio/DTSHD-MA/hd_dts_living_world_of_audio_lossless.m2ts",
                "filetype": "file",
                "label": "hd_dts_living_world_of_audio_lossless.m2ts",
                "type": "unknown"
            }
        ],
        "limits": {
            "end": 2,
            "start": 0,
            "total": 2
        }
    }
}


It seems to ignore the files since they report as "type": "unknown" or since they don't have an Id(MovieId, EpisodeIs, MusicVideoId)


- Montellese - 2012-01-10

Thanks for the report giftie. I fixed it in https://github.com/xbmc/xbmc/commit/6aa04be25d47b654d45c906ced9d5affe74e43e8. You were right if the file was not in the database and XBMC wasn't able to retrieve any meta-data from it, it simply didn't show up in the response.


- samdret - 2012-01-10

Sorry if this has been asked a lot, but I can't seem to find any information regarding it.

After I've called JSONRPC.Introspect and gotten a list of available commands, where can I get information on which parameters each command accepts? I.e. I would like more than just label and id when I call VideoLibrary.GetRecentlyAddedMovies


- Montellese - 2012-01-10

samdret Wrote:Sorry if this has been asked a lot, but I can't seem to find any information regarding it.

After I've called JSONRPC.Introspect and gotten a list of available commands, where can I get information on which parameters each command accepts? I.e. I would like more than just label and id when I call VideoLibrary.GetRecentlyAddedMovies

Unless you are using Dharma, JSONRPC.Introspect provides you will all the information about every parameter of every method. You can also find some (limited) information on the wiki.

In case you are using Dharma I recommend to either wait till Eden stable has been released or if you can't wait update to Eden Beta 1 and to take a look at the new introspect.

Concerning your question on VideoLibrary.GetRecentlyAddedMovies: You must specify the additional information you want in the "properties" parameter as an array of strings (e.g. [ "title", "rating", "thumbnail" ]).


- Mizaki - 2012-01-10

Should Player.SetSubtitle and Player.SetAudioStream trigger GUI notifications? Currently they don't seem to.


- Montellese - 2012-01-10

What do you mean by GUI notification? A notification dialog telling you that you switched to audiostream XYZ? Don't you know that already because you initiated the action? AFAIK there's no such thing in XBMC.