JSON-RPC ExecuteAddon

  Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
bob3695 Offline
Junior Member
Posts: 6
Joined: Jan 2013
Reputation: 0
Post: #1
Hey guys,

This might be an obvious answer but somehow I am missing something. I am trying to use the Addon.ExecuteAddon to pass some params to the PleXBMC addon. I am using the following JSON:

PHP Code:
{"jsonrpc""2.0","method""Addons.ExecuteAddon","params": {"wait"false,"addonid""plugin.video.plexbmc","params": ["?url=http://192.168.1.100:32400/library/metadata/1&mode=5&id=1"]},"id"2

and I get the following response:

PHP Code:
{"id":2,"jsonrpc":"2.0","result":"OK"

and in XBMC it goes into the menu which is not what I expected. I am trying to get the addon to launch the movie.... I check the log (I have it in debug mode) and find the following:

PHP Code:
19:41:30 T:4646768640  NOTICE: == ENTERget_params ==
19:41:30 T:4646768640  NOTICEPleXBMC -> get_paramsParameter string:
19:41:30 T:4646768640  NOTICEPleXBMC -> get_paramsReturning: []
19:41:30 T:4646768640  NOTICEPleXBMC -> []
19:41:30 T:4646768640  NOTICEPleXBMC -> ModeNone
19
:41:30 T:4646768640  NOTICEPleXBMC -> URLNone
19
:41:30 T:4646768640  NOTICEPleXBMC -> NameNone
19
:41:30 T:4646768640  NOTICEPleXBMC -> IDNone 

I've tried many different variations of the JSON but all seem to result in the same thing... Am I passing in the parameters wrong?

Thanks
find quote
Montellese Offline
Team Kodi Developer
Posts: 4,803
Joined: Jan 2009
Reputation: 66
Location: Switzerland
Post: #2
Your "params" parameter is wrong. You should pass in every addon parameter seperately and not as a full string. It might work fine if you just drop the "?" at the beginning of your parameter. If not try
Code:
{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon", "params": { "wait": false, "addonid": "plugin.video.plexbmc", "params": { "url": "http://192.168.1.100:32400/library/metadata/1", "mode": "5", "id": "1"} }, "id": 2 }
As you can see, "url", "mode" and "id" are seperate parameters and you can provide them to JSON-RPC in that way.

NB: I haven't tried this or anything (as I don't have PleXBMC).

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.
find quote
bob3695 Offline
Junior Member
Posts: 6
Joined: Jan 2013
Reputation: 0
Post: #3
No dice... I have tried the following variations with the same results:

Code:
{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon", "params": { "wait": false, "addonid": "plugin.video.plexbmc", "params": { "url": "http://192.168.1.100:32400/library/metadata/1", "mode": "5", "id": "1"} }, "id": 2 }

Code:
{"jsonrpc": "2.0","method": "Addons.ExecuteAddon","params": {"wait": false,"addonid": "plugin.video.plexbmc","params": ["url=http://192.168.1.100:32400/library/metadata/1&mode=5&id=1"]},"id": 2}

I also noticed my PleXBMC plugin was outdated so I updated and tried again with still no luck. I am not a Python developer (but am a developer) so I took a peek at the code and noticed this:

Code:
printDebug( "PleXBMC -> Script argument is " + str(sys.argv[1]), False)

try:
    params=get_params(sys.argv[2])
except:
    params={}

In my log the script argument is set to 0 which means argv[1] is setting something but sys.argv[2] isn't. That leads me to believe either the plugin is not accessing the params correctly or XBMC is not even passing them in correctly.

This lead me to turn on debugging on XBMC as well to see what was getting passed in... I found this in my log:

Code:
06:32:49 T:4635795456   DEBUG: JSONRPC: Incoming request: { "jsonrpc": "2.0", "method": "Addons.ExecuteAddon", "params": { "wait": false, "addonid": "plugin.video.plexbmc", "params": { "url": "http://192.168.1.100:32400/library/metadata/1", "mode": "5", "id": "1"} }, "id": 2 }
06:32:49 T:4635795456   DEBUG: JSONRPC: Calling addons.executeaddon
06:32:49 T:140735192387968   DEBUG: Activating window ID: 10025
06:32:49 T:140735192387968   DEBUG: ------ Window Deinit (MyVideoNav.xml) ------
06:32:49 T:140735192387968   DEBUG: ------ Window Init (MyVideoNav.xml) ------
06:32:49 T:140735192387968   DEBUG: CGUIMediaWindow::GetDirectory (plugin://plugin.video.plexbmc)
06:32:49 T:140735192387968   DEBUG:   ParentPath = [plugin://plugin.video.plexbmc]
06:32:49 T:140735192387968   DEBUG: StartScript - calling plugin PleXBMC('plugin://plugin.video.plexbmc/','0','')

I am thinking the params should actually be on the "calling plugin PleXBMC" line but there is no sign of them. Am I correct in this thinking?
find quote
queeup Offline
Posting Freak
Posts: 812
Joined: Feb 2009
Reputation: 16
Post: #4
yes you are right about it. I also try to play youtube video from jsonrpc but no luck.

when I am playing a video from add-on log show me this:
Code:
YouTube-4.4.1 ARGV: ['plugin://plugin.video.youtube/', '0', '?path=/root/video&action=play_video&videoid=P3uRsNqB9ks']

But if I try same with rpc:
Code:
{"jsonrpc":"2.0", "method":"Addons.ExecuteAddon", "params":{"addonid":"plugin.video.youtube", "params":{"path":"/root/video", "action":"play_video", "videoid":"P3uRsNqB9ks"}},"id":"2"}
Log sow me this:
Code:
YouTube-4.4.1 ARGV: ['plugin://plugin.video.youtube/', '0', '']

Something wrong here.
find quote
Montellese Offline
Team Kodi Developer
Posts: 4,803
Joined: Jan 2009
Reputation: 66
Location: Switzerland
Post: #5
Seems like something goes wrong when serializing the arguments for the addon.

How do you get those URLs? Because if you have them in form of "plugin://<addonid>/<arguments>" then you can just use that with Player.Open and the "file" property in the "item" parameter.

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.
find quote
queeup Offline
Posting Freak
Posts: 812
Joined: Feb 2009
Reputation: 16
Post: #6
Yes what you suggest works. Yatse using that:
Code:
DEBUG: JSONRPC: Incoming request: {"id":1,"jsonrpc":"2.0","method":"Player.Open","params":{"item":{"file":"plugin:\/\/plugin.video.youtube\/?path=\/root\/search&action=play_video&videoid=17upC495LMg"}}}

I just experiment with ExecuteAddon and I never succeeded.
find quote
queeup Offline
Posting Freak
Posts: 812
Joined: Feb 2009
Reputation: 16
Post: #7
Maybe some debug log helps(not full log but If you need I will post full):
http://pastebin.com/224A7yP8
find quote
bob3695 Offline
Junior Member
Posts: 6
Joined: Jan 2013
Reputation: 0
Post: #8
Thanks for the workaround. I will test it first thing when I get home!
find quote
bob3695 Offline
Junior Member
Posts: 6
Joined: Jan 2013
Reputation: 0
Post: #9
{"id":1,"jsonrpc":"2.0","method":"Player.Open","params":{"item":{"file":"plugin:\/\/plugin.video.plexbmc\/?url=http://192.168.1.100:32400/library/metadata/1&mode=5&id=1"}}}

that also works perfectly for my uses for PleXBMC. So I would say that there is something up with ExecuteAddon :-(
find quote
Montellese Offline
Team Kodi Developer
Posts: 4,803
Joined: Jan 2009
Reputation: 66
Location: Switzerland
Post: #10
I've created a PR that will fix passing the parameters on to the plugin, see PR2072. But that's probably not gonna make it possible to start playing a video from a plugin through ExecuteAddon (but I didn't have the time to try it). For that you might still need to use Player.Open.

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.
find quote
queeup Offline
Posting Freak
Posts: 812
Joined: Feb 2009
Reputation: 16
Post: #11
Thx. we will see. I think it depends on add-on. If add-on take parameters and start player, why not Smile
find quote
mcpc Offline
Junior Member
Posts: 3
Joined: Jan 2017
Reputation: 0
Post: #12
Hi Guys,

Was wondering if any of you managed to find a parameter or a way to open an addon in its "original state". For example, if an addon has 4 options, currently if I go "home" or back, it won't default to the first option..

As I am trying to "crudely" create a macro that will go to some specific areas of the addon without me having to use the remote, but once I've used it the first time, all other logic to reach other areas fails because it doesn't start from the addon's initial state.

Cheers
find quote
ncarthy Offline
Member
Posts: 50
Joined: Aug 2010
Reputation: 0
Location: London
Post: #13
which addon?
find quote