Receive JSON Notifications from XBMC
#1
I've been playing around a bit with an existing plugin that already acts as a service of sorts to better integrate it with the XBMC library. One thing I would like to accomplish is to receive JSON notifications regarding changes to the video library. In this specific case I'm looking to capture when something is removed from the library or is marked as watched. I have found several examples of sending JSON calls to XBMC and parsing the results but nothing I've found seemingly ties into the notifications. So any pointers on where to start or how to accomplish this? In the plugin I'm extending there's already a 'service' running that extends xbmc.Player and monitors its status in a loop so somehow this would need to be done asynchronously from that.
Reply
#2
JsonRPC is only unidirectional.

You need to write a service add-on which implements a monitor-class using onDatabaseUpdated-callback.
My GitHub. My Add-ons:
Image
Reply
#3
Thanks for the response Sphere.

It might be semantics but I'm currently executing/sending JSON commands and receiving results so that's why I was thinking JSON.

If I understand the docs the onDatabaseUpdated call doesn't seem to tell me anything about what was changed other than the database name ... right? Or am I missing something really basic here?
Reply
#4
I've found the perfect example using JSON in the TrakUtilities script and have the bulk of it figured out. If there is an easier, more direct way to be notified when an item is marked as watched or removed from the library I'd love to know.
Reply
#5
(2013-08-07, 23:56)sphere Wrote: JsonRPC is only unidirectional.

You need to write a service add-on which implements a monitor-class using onDatabaseUpdated-callback.

That's not right. Over a TCP or WebSocket connection (if enabled in the settings) everyone can receive JSON-RPC notifications.

For this specific case the VideoLibrary.OnUpdate would be useful.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#6
(2013-08-08, 08:28)Montellese Wrote:
(2013-08-07, 23:56)sphere Wrote: JsonRPC is only unidirectional.

You need to write a service add-on which implements a monitor-class using onDatabaseUpdated-callback.

That's not right. Over a TCP or WebSocket connection (if enabled in the settings) everyone can receive JSON-RPC notifications.

For this specific case the VideoLibrary.OnUpdate would be useful.

Interesting, didn't know that. Thanks for the clarification!
My GitHub. My Add-ons:
Image
Reply
#7
For clarity and my own interest, am I correct in my understanding of the onDatabaseUpdate method? It's not going to tell me anything about what actually changed making it impossible to act upon the playcount/watched status being changed.
Reply
#8
(2013-08-08, 16:21)bdam Wrote: For clarity and my own interest, am I correct in my understanding of the onDatabaseUpdate method? It's not going to tell me anything about what actually changed making it impossible to act upon the playcount/watched status being changed.

That's correct.

I just created a pull request with some code that add a "onNotification" method to the Monitor class which is called for every notification that JSON-RPC also sends out through TCP. That way python addons will be able to receive those notifications without having to deal with TCP connections and message parsing etc. But obviously that will be a Gotham feature.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#9
Thanks Montallese for both the confirmation and work on enhancing the monitor class.
Reply

Logout Mark Read Team Forum Stats Members Help
Receive JSON Notifications from XBMC0