Json from Kodi to an external application
#1
Hello,

I'm not a real developer but I like to do little stuffs with Kodi, I did a custom add-on and small stuffs like that...
My goal would be this time to send a json information from a Kodi installed on a Firetv to an audio application (Cycling 74 "Max") running on a Mac OS.
(to execute some actions in Max, triggered by events in Kodi). The Firetv and the Mac are on the same network.

And I don't know at all how Json works... could anyone help to begin ?
I see that Max is able to receive UDP messages. Is it possible to send json messages over UDP with Kodi ?

Or anyone knowing Max could find another way ? (midi, osc,...)
Thanks for your help !
Reply
#2
most things python can do kodi can do from an addon including udp - https://wiki.python.org/moin/UdpCommunication

what isnt clear is what you are asking for, it sounds like you want someone to tell you how the protocols work for Cycling 74 "Max" and what data you can send to it rather than a more general inquiry on how to use udp in kodi

if its the latter the link should be helpful, if its the former im not sure you will find the answer here
Reply
#3
Hum… sorry if my question was not clear…

I’m trying to establish communication from Kodi to Max.

And as I saw Max is able to read UDP data, that’s why I was asking if Kodi was able to send UDP messages. And your answer seems to say that yes, so that’s a good news, thanks !
Reply
#4
(2023-05-30, 16:48)badsheep Wrote: Hello,

I'm not a real developer but I like to do little stuffs with Kodi, I did a custom add-on and small stuffs like that...
My goal would be this time to send a json information from a Kodi installed on a Firetv to an audio application (Cycling 74 "Max") running on a Mac OS.
(to execute some actions in Max, triggered by events in Kodi). The Firetv and the Mac are on the same network.

And I don't know at all how Json works... could anyone help to begin ?
I see that Max is able to receive UDP messages. Is it possible to send json messages over UDP with Kodi ?

Or anyone knowing Max could find another way ? (midi, osc,...)
Thanks for your help !


Kodi has a JSON RPC interface but I am not sure if it is UDP based.  Kodi also supports UPnP/DLNA as a way to share information in a standards format but without knowing more about what you want to do, I am not sure this is what you are looking for.


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#5
(2023-05-30, 19:29)jbinkley60 Wrote:
(2023-05-30, 16:48)badsheep Wrote: Hello,

I'm not a real developer but I like to do little stuffs with Kodi, I did a custom add-on and small stuffs like that...
My goal would be this time to send a json information from a Kodi installed on a Firetv to an audio application (Cycling 74 "Max") running on a Mac OS.
(to execute some actions in Max, triggered by events in Kodi). The Firetv and the Mac are on the same network.

And I don't know at all how Json works... could anyone help to begin ?
I see that Max is able to receive UDP messages. Is it possible to send json messages over UDP with Kodi ?

Or anyone knowing Max could find another way ? (midi, osc,...)
Thanks for your help !


Kodi has a JSON RPC interface but I am not sure if it is UDP based.  Kodi also supports UPnP/DLNA as a way to share information in a standards format but without knowing more about what you want to do, I am not sure this is what you are looking for.


Thanks,

Jeff

he wants to send rpc commands From kodi To cycling 74 "max" from the way i read it - custom addon territory
Reply
#6
(2023-05-30, 19:39)jepsizofye Wrote:
(2023-05-30, 19:29)jbinkley60 Wrote:
(2023-05-30, 16:48)badsheep Wrote: Hello,

I'm not a real developer but I like to do little stuffs with Kodi, I did a custom add-on and small stuffs like that...
My goal would be this time to send a json information from a Kodi installed on a Firetv to an audio application (Cycling 74 "Max") running on a Mac OS.
(to execute some actions in Max, triggered by events in Kodi). The Firetv and the Mac are on the same network.

And I don't know at all how Json works... could anyone help to begin ?
I see that Max is able to receive UDP messages. Is it possible to send json messages over UDP with Kodi ?

Or anyone knowing Max could find another way ? (midi, osc,...)
Thanks for your help !


Kodi has a JSON RPC interface but I am not sure if it is UDP based.  Kodi also supports UPnP/DLNA as a way to share information in a standards format but without knowing more about what you want to do, I am not sure this is what you are looking for.


Thanks,

Jeff

he wants to send rpc commands From kodi To cycling 74 "max" from the way i read it - custom addon territory

Oops.  Sorry, the wrong direction.  It can be done via a web call or similar from an addon.  Not sure of JSON over UDP.  I've never really seen it used much except for the SSDP discovery packets for UPnP.  You end up with some pretty low level Python coding with sockets. 

Here's an example from my addon.


Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#7
Thanks everybody for all your messages, it's really interesting !
I'll explain more precisely what I need :

Actually I run Kodi on the same Mac OS with Max. The audio output (5.1) is routed from Kodi to Max. 
In Max I have different audio treatments I can apply : dynamic compression, low cut, mono reduction, DTS upmix... (I work in sound for movies)
I can manually activate those treatments, but I also created an add-on to automate something : at every start of a movie, my addon-on checks the numbers of audio channels.
If it's 2 (stereo), it does a keystroke.
If it's > 2 (usually 5.1), it does another keystroke.

Those keystrokes are converted via Hammerspoon in Midi and sent to Max over a internal virtual Midi channel ; then Max activates the proper audio treatment (if audio is 5.1 it does nothing, if audio is stereo it applies a DTS Upmix to feed my 5.1 monitoring system). That may seem twisted or over-complicated but in fact it's really working very well and I use this since years... (that's one of the many reasons why I love Kodi).

What's new : I'd like to use a Firetv stick to watch movies on Kodi, to avoid the problems related to the widevine levels and the streaming platforms.

The only problem I have is that I have to find another type of communication between this Kodi and Max (that will still be active on my Mac, and receiving the audio like before).
Midi isn't possible anymore, that's why I was thinking of Json, but it seems more complicated that I expected...
Reply
#8
Hi everybody,

I found a solution. In my add-on I send a UDP message formatted in OSC (a protocol that is a kind of modern MIDI).

python:
   sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
                MESSAGE = b'\x2f\x66\x6f\x6f\x00\x00\x00\x00\x2c\x69\x00\x00\x00\x00\x00\x01'
                sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))

That HEX message kind of means : "value 1 for the foo parameter".  (/foo ,i 1)
(if anybody need to understand the syntax of the OSC, this page helped me to understand)

I use value 1 in one case and value 2 in the other case : that's it !
Thanks to everybody for helping me searching in the right direction.
Reply
#9
right on

glad you got it
Reply
#10
(2023-05-31, 15:42)badsheep Wrote: Hi everybody,

I found a solution. In my add-on I send a UDP message formatted in OSC (a protocol that is a kind of modern MIDI).

python:
   sock = socket.socket(socket.AF_INET, # Internet
                     socket.SOCK_DGRAM) # UDP
                MESSAGE = b'\x2f\x66\x6f\x6f\x00\x00\x00\x00\x2c\x69\x00\x00\x00\x00\x00\x01'
                sock.sendto(MESSAGE, (UDP_IP, UDP_PORT))

That HEX message kind of means : "value 1 for the foo parameter".  (/foo ,i 1)
(if anybody need to understand the syntax of the OSC, this page helped me to understand)

I use value 1 in one case and value 2 in the other case : that's it !
Thanks to everybody for helping me searching in the right direction.

Nice solution.  It aligns to some of the socket programming in my addon.  One question is whether you are looking for a response ?  Looking at the link you provided I don't see where the server sends a response.  In my socket code there is a class used to catch the responses to the broadcasts. It might give you some additional ideas, in case you need this functionality.


Thanks,

Jeff
Running with the Mezzmo Kodi addon.  The easier way to share your media with multiple Kodi clients.
Service.autostop , CBC Sports, Kodi Selective Cleaner and Mezzmo Kodi addon author.
Reply
#11
Hi Jeff, thanks !

For now I'll try without asking for a response : the Firetv and the Mac will be very close from each other, plugged on the same ethernet switch, so I think it will be stable without.
If I have problems I'll check your solution !

Thanks again for your help
Reply

Logout Mark Read Team Forum Stats Members Help
Json from Kodi to an external application0