How to pass variable between json-rpc to addon script
#16
@Lunatixz 

Now I can pass i values between two python scripts in the same folder like this:

first.py

I=1199
import second


second.py

from __main__ import *

if i == 1199:

    print x

else:
    print "sorry"
and now first.py can print I value


and now looking for remotely way!
Reply
#17
@networkmad Your objective was to use sys.argv and create arguments that can be passed between two plugins; NOT to share data between two modules... I strongly suggest you re-read my previous posts and I advise you to read through ALL of the links I posted for you. Good luck...
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#18
@Lunatixz.  I have been looking for a way for me to use JSON RPC or something like that from a separate application to a Kodi plugin, is sys.argv something that I could use for that or is this strictly limited to plugin to plugin?  Basically I want to wire up a function inside my modified PTVL addon that would allow another application to change to specific channels.

At first I was thinking of trying to utilize the JSON RPC call Addons.ExecuteAddon for instance to initiate a channel change to channel 13:

{"jsonrpc": "2.0","method": "Addons.ExecuteAddon","params": {"wait": false,"addonid": "script.pseudotv.live","params": ["?changeto=13"]},"id": 2}

And yes, this would I believe technically call default.py, aka attempting to start the plugin while it's already running.  But I was thinking I would change that code and check to see if any parameters were sent, and if they were process them.  If no parameters are received then it would just execute normally "give you the already running error" prompt as it usually does.

The only missing piece of my puzzle is how to grab these parameters in default.py so I can process the remote command.  self.params perhaps?

Found this from here: https://kodi.wiki/view/HOW-TO:Script_add...lt.py_file

def __init__(self, *args, **kwargs): # get the optional data and add it to a variable you can use elsewhere in your script
     self.data = kwargs['optional1']

Or is this sys.argv the way to go?

I'm wiring up an old pushbutton cable box to a Phidgets USB control board that will allow a VB.NET app I am writing to send these channel commands directly to PTVL to use this box to change the channels.
Reply
#19
(2019-09-20, 02:43)soundman1611 Wrote: @Lunatixz.  I have been looking for a way for me to use JSON RPC or something like that from a separate application to a Kodi plugin, is sys.argv something that I could use for that or is this strictly limited to plugin to plugin?  Basically I want to wire up a function inside my modified PTVL addon that would allow another application to change to specific channels.

At first I was thinking of trying to utilize the JSON RPC call Addons.ExecuteAddon for instance to initiate a channel change to channel 13:

{"jsonrpc": "2.0","method": "Addons.ExecuteAddon","params": {"wait": false,"addonid": "script.pseudotv.live","params": ["?changeto=13"]},"id": 2}

And yes, this would I believe technically call default.py, aka attempting to start the plugin while it's already running.  But I was thinking I would change that code and check to see if any parameters were sent, and if they were process them.  If no parameters are received then it would just execute normally "give you the already running error" prompt as it usually does.

The only missing piece of my puzzle is how to grab these parameters in default.py so I can process the remote command.  self.params perhaps?

Found this from here: https://kodi.wiki/view/HOW-TO:Script_add...lt.py_file

def __init__(self, *args, **kwargs): # get the optional data and add it to a variable you can use elsewhere in your script
     self.data = kwargs['optional1']

Or is this sys.argv the way to go?

I'm wiring up an old pushbutton cable box to a Phidgets USB control board that will allow a VB.NET app I am writing to send these channel commands directly to PTVL to use this box to change the channels.

I don't see the need for this since PTVL is controlled via keyboard... you can use Kodi's RPC to send a keypress.
ex. in the link below from a janky "remote" plugin I wrote to control PTVL.
https://github.com/PseudoTV/PseudoTV_Uti...lt.py#L372

As for your modified version... just a heads up there are significate changes in the upcoming release... hate to see any hard work wasted.
Image Lunatixz - Kodi / Beta repository
Image PseudoTV - Forum | Website | Youtube | Help?
Reply
#20
Hasn't been too hard of work so far, actually it's been a lot of fun and a great way to get my feet wet with Python. 

Regarding your code, I already have PseudoCompanion installed, am I correct to assume that I need to replace the code in pseudo companion with your posted code?  

Also do you have a JSON RPC example of how to send a command to pseudo companion?  

Am I correct to assume that the way this works is my VB app would send a JSON RPC call to Pseudo Companion, with parameters, then companion sends the predetermined command to PTVL?
Reply

Logout Mark Read Team Forum Stats Members Help
How to pass variable between json-rpc to addon script0