Support for XBMC2 plugin (formerly XBMCRepeat)

Questions and comments specific to a particular plugin should go here.
jonib
Plugin Developer
Posts: 1344
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jonib » Sat Apr 18, 2020 3:06 am

jachin99 wrote:
Sat Apr 18, 2020 2:13 am
I would want to send Kodi this command if there is no disc in the tray.

ActivateWindow (10025,videodb://movies/titles/,return)

Code: Select all

result = eg.plugins.XBMC2.JSONRPC(u'XBMC.GetInfoBooleans', u'[["System.HasMediadvd"]]', True)
if result["System.HasMediadvd"]:
    eg.plugins.XBMC2.PlayDVD()
else:
    eg.plugins.XBMC2.BuiltInFunctions('ActivateWindow', '10025,videodb://movies/titles/,return')

Also, I may need to set up conditions where remote presses perform different actions based on the current window so Skip Minus seeks back ten seconds if I'm watching live TV but goes to the previous chapter if I'm watching a movie for instance. How would I do something like that? I think once I set up a few more of these I might be able to make them on my own. Thanks again!!
This probably is best done via Kodi keymaps.

I didn't find how to detect live TV and I can't test, if the keymap don't work for you, you should ask on the Kodi forum.

Edit: Looks like testing for Live TV can be done with this:

Code: Select all

eg.plugins.XBMC2.JSONRPC(u'XBMC.GetInfoBooleans', u'[["Pvr.IsPlayingTv"]]', True)
jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jachin99 » Sat Apr 18, 2020 4:47 am

I actually figured out the DVD part on my own, but that would not have happened without your help!! I am still asking around on the kodi forums but I'm having absolutely no luck getting the results I need. They're still helping me with it though. I need to start really thinking things through in terms of how I want my remote to act but EG always seems to pull through for me so that is why I choose to use it over the xml files. I'll try out your window detection script and see how that goes. Also, where can I look up the documentation for the JSON RPC interface so I can understand what all of my options are? Thanks again!!

jonib
Plugin Developer
Posts: 1344
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jonib » Sat Apr 18, 2020 5:41 pm

jachin99 wrote:
Sat Apr 18, 2020 4:47 am
I actually figured out the DVD part on my own, but that would not have happened without your help!!
Great.
Also, where can I look up the documentation for the JSON RPC interface so I can understand what all of my options are? Thanks again!!
JSON-RPC API on Kodi wiki(a bit outdated) you can also access the API directly from Kodi

Code: Select all

http://localhost:8080/jsonrpc
change localhost to the Kodi IP if it don't work.
Edit2: You need to use the port defined in Kodi for HTTP.

Builtinfunctions are documented here like your ActivateWindow command.
To access a lot of of info from Kodi Infolabels and Boolean access via the JSON-RPC "XBMC.GetInfoBooleans" and "XBMC.GetInfoLabes".

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jachin99 » Sat Apr 18, 2020 10:52 pm

Alright, now I think I'll need to combine some Boolean values for System.HasMediadvd & Player.Playing. I need EG to check if there is a disc inserted like we already have, and I want EG to send me to the movies library if there is no disc like it does now. However, I want to change this so that if System.HasMediaDVD, and Player.Playing are both true, I want to go straight to the DVD menu via the ShowVideoMenu command. I'm not sure I am far enough along to create that command on my own just yet but I can tinker with it.

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jachin99 » Mon Apr 20, 2020 12:07 am

Ok so I might have actually gotten this right on my own but I want a second pair of eyes to confirm. Ignore the smallstep back part for the moment because I want to change that to showvideo menu. When I run this script I don't get any errors

Code: Select all

result = eg.plugins.XBMC2.JSONRPC(u'XBMC.GetInfoBooleans', u'[["Player.Playing"]]', u'[["System.HasMediadvd"]]',True)
if result["Player.Playing"]:
    eg.plugins.XBMC2.SmallStepBack()
    print("ITWORKS")
    

else:
    eg.plugins.XBMC2.Back()
    print("Nope")
   
But now that I look at the script It looks like I have to dd the value for System.HasMediadvd to my if statement. Anyway I got excited for a minute because I got the script to run without errors. I just have to make sure it runs correctly.

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jachin99 » Mon Apr 20, 2020 12:45 am

Here is another shot at it. I want to evaluate whether or not a DVD has been inserted, and if a video is playing. If a DVD is in, and the video is playing then I want my movies button to take me to the DVD Menu. If a DVD is in the computer but they disc is not playing, then I want to play the disc. Finally if there is no disc in the PC, I just want to go to my movies library. Here is the script I have so far but it isn't working. I think the problems start on line 2

Code: Select all

result = eg.plugins.XBMC2.JSONRPC(u\'XBMC.GetInfoBooleans\', u\'[["Player.Playing"]]\', u\'[["System.HasMediadvd"]]\',True)
if result["Player.Playing", "System.HasMediadvd"]:
    #eg.plugins.XBMC2.ShowVideoMenu
    print("ITWORKS")
    

else:
    eg.plugins.XBMC2.Back()
    print("Nope")
I believe I need an elseif statement in there somewhere too but I haven't had time to try that out.

jonib
Plugin Developer
Posts: 1344
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jonib » Mon Apr 20, 2020 1:01 pm

More like this, the infolabels need to be in the same list.
You also need to test the results separately.

Code: Select all

result = eg.plugins.XBMC2.JSONRPC(u'XBMC.GetInfoBooleans', u'[["System.HasMediadvd", "Player.Playing"]]', True)
if result["System.HasMediadvd"] and result["Player.Playing"]:
	#eg.plugins.XBMC2.ShowVideoMenu
	print("ITWORKS")
else:
	eg.plugins.XBMC2.Back()
	print("Nope")
jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jachin99 » Tue Apr 21, 2020 3:15 pm

Jonib, that looks like it works but I need to rethink what behavior I want out of kodi. But now that I have a simple way to play around with these little scripts I think I'm hooked!! I'm actually excited to work on these now!!

jonib
Plugin Developer
Posts: 1344
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jonib » Wed Apr 22, 2020 7:21 pm

jachin99 wrote:
Tue Apr 21, 2020 3:15 pm
Jonib, that looks like it works but I need to rethink what behavior I want out of kodi.
Good idea as there are a number of ways to do this stuff in EventGhost/Kodi.
But now that I have a simple way to play around with these little scripts I think I'm hooked!! I'm actually excited to work on these now!!
Great. I just found a new way to access/test the JSON-RPC API api-browser (You might need to change the IP and port to Kodi)

I must thank you as this has finally inspired/motivated me to work on this plugin again, I have not been able to work on this stuff for more than two years because of many issues including helth and computer problems.

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jachin99 » Thu Apr 23, 2020 2:22 pm

Next I would like to evaluate whether or not a given video has chapters via infolabels. If it does have chapters I want my skip next, and skip previous buttons to change chapters. If not I want them to seek a given amount of time. Here is my attempt at evaluating chapters via Player.ChapterCount. I'll need one script for next chapter, and one for previous chapter if I understand things correctly.

Code: Select all

result = eg.plugins.XBMC2.JSONRPC(u'XBMC.GetInfoLabel', u'[["Player.ChapterCount"]]' >0)
if result["Player.ChapterCount"]:
    eg.plugins.XBMC2.ChapterOrBigStepForward()
    print("NextChapter")
    

else:
    eg.plugins.XBMC2.StepForward()
    print("Seek")
   
Also something I should bring up, I had issues getting Kodi to ignore my keypresses for keys that were already functional in Kodi. To fix this I had to comment out most of keyboard.xml, and I'm having the best luck with the Actions category of the plugin so most of my commands might be restricted to that. I also couldn't find a next chapter action in actions so I used chapterorbigstepforard. I don't want a seek time of ten minutes so specifying my seek time will give a better UX in my opinion. Thanks.

jonib
Plugin Developer
Posts: 1344
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jonib » Thu Apr 23, 2020 3:55 pm

jachin99 wrote:
Thu Apr 23, 2020 2:22 pm
Next I would like to evaluate whether or not a given video has chapters via infolabels. If it does have chapters I want my skip next, and skip previous buttons to change chapters. If not I want them to seek a given amount of time. Here is my attempt at evaluating chapters via Player.ChapterCount. I'll need one script for next chapter, and one for previous chapter if I understand things correctly.
The ChapterCount seems to return a string so it needs to be converted to "int" before testing, then it would test "True" when there is chapters and "False" if there is none.

Code: Select all

result = eg.plugins.XBMC2.JSONRPC(u'XBMC.GetInfoLabel', u'[["Player.ChapterCount"]]')
if int(result[u"Player.ChapterCount"]):
    eg.plugins.XBMC2.ChapterOrBigStepForward()
    print("NextChapter")
    

else:
    eg.plugins.XBMC2.StepForward()
    print("Seek")
   
Also something I should bring up, I had issues getting Kodi to ignore my keypresses for keys that were already functional in Kodi. To fix this I had to comment out most of keyboard.xml, and I'm having the best luck with the Actions category of the plugin so most of my commands might be restricted to that.
Yeah only actions are done directly by Kodi.

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jachin99 » Thu Apr 23, 2020 8:34 pm

I'm getting this error when I run the script

16:30:16 Error:
16:30:16 {
16:30:16 "code": -32601,
16:30:16 "message": "Method not found."
16:30:16 }
16:30:16 Traceback (most recent call last):
16:30:16 Python script "9", line 2, in <module>
16:30:16 if int(result[u"Player.ChapterCount"]):
16:30:16 TypeError: 'NoneType' object has no attribute '__getitem__'

Have you added chapterorbigstep actions to the plugin?

jonib
Plugin Developer
Posts: 1344
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jonib » Thu Apr 23, 2020 9:26 pm

jachin99 wrote:
Thu Apr 23, 2020 8:34 pm
I'm getting this error when I run the script
There is a missing "s" in "XBMC.GetInfoLabels"
Have you added chapterorbigstep actions to the plugin?
You need to "update actions" in the plugin settings, restart EventGhost. They will be added to XBMC2->Actions->Manually updated.

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image

jachin99
Experienced User
Posts: 646
Joined: Sat Feb 13, 2016 8:39 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jachin99 » Sat Apr 25, 2020 4:02 am

Jonib, I fixed the infolabels text, and I'm looking forward to an update to include chapter navigation.

jonib
Plugin Developer
Posts: 1344
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jonib » Sat Apr 25, 2020 5:19 pm

jachin99 wrote:
Sat Apr 25, 2020 4:02 am
and I'm looking forward to an update to include chapter navigation.
Hmm, feels like I'm missing something? If you mean "chapterorbigstep" you just need to press the action update in the plugins settings, or was there a problem with it?

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image

Post Reply