Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Support for XBMC2 plugin (formerly XBMCRepeat)

Questions and comments specific to a particular plugin should go here.
curtdwar
Posts: 4
Joined: Sun Aug 30, 2015 5:39 am

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by curtdwar »

gday Jonib, thanks for this plugin and the time you spend keeping it going, much appreciated mate.

Small bit of feedback, might be of interest, might not.

I was having a problem with the JSON notification function dying after a few minutes of starting eventghost. it would throw and error in waitforXBMC(). A listindex out of range error.

Line 1981 "if headers['USN'].split(':', 2)[1] not in USNCache:".

Please excuse my ignorance, this explanation will get terminology wrong.....

From what I could tell I have some upnp devices on my network (I couldn't locate which ones) that transmit the USN without the 'uuid:' label at the beginning. From my limited knowledge it appears you split the headers['USN'] and read the UUID from the second item in the list, if there is no 'uuid:' label and only the UUID then the .split() only has one item, and reading the second items fails.

I don't really know what that part of the code is trying to do, it was a bit over my head, but I added some amateur code to strip leading spaces, then test for "uuid:' at start of headers['USN'] before either adding 'uuid:' to the start or continuing on with your code.

Hopefully that made sense to you. I'm not sure if it's of interest, but figured I'd post and you can ignore it at your leisure. :)

Ask the next Aussie you meet to buy you a beer, tell him it's on me.

Cheers mate.
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by Sem;colon »

I have two question on the JSON-RPC notifications:
-On one PC (win 8.1 x64) it's working only if I deactivate/reactivate the plugin after I started kodi, is that normal?
-On my other PC (win 10 x64) it's not working at all - here it looks like the plugin cannot connect to the JSON-RPC notification port, I'm wondering if they maybe not on port 9090 on this PC, but I don't know how I can verify what is set on Kodi side.. The only port I can set in the settings is the webserver port and that one is working (I can send commands from the XBMC2 plugin to Kodi)

Kodi 15.1
XBMC2 Plugin 0.6.23
Windows 10 Home x64

Thank you very much in advance!
If you like my work, Image me a drink :wink:
Sem;colon
Plugin Developer
Posts: 625
Joined: Sat Feb 18, 2012 10:51 am
Location: Germany

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by Sem;colon »

OK, I guess I figured it out, I needed to enable "Broadcast events" as well and activate in Kodi the possibility that remote programs can control Kodi (programs on this PC doesn't seem to be enough)
If you like my work, Image me a drink :wink:
popy
Posts: 24
Joined: Tue Mar 24, 2009 8:40 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by popy »

Nice plugin!!! Now i can use my USBUIRT with Kodi.
I have a question regarding using variable/payload-data in an JSON API ShowNotification cmd.

I am using Tasker on my android phone to send a low battery warning to a running eventghost/kodi client.
The way is like this:

Android phone -> low battery -> tasker HTTP Get request -> Eventghost WebServer -> HTTP Event with payload (device name & battery percent, seperated with /) -> send notification to Kodi

When i am using the experimental function SendNotification with the payload text all is working as it should, here is the xml code of eventghost:

Code: Select all

XBMC2.SendNotification(u"{eg.event.payload[0].split('/')[0]} dein Akku ist fast leer", u"{eg.event.payload[0].split('/')[1]}% verbleibend")
But ill want to use the JSON API, because ill can add a custom image and timeout. So i have used the following code/xml:

Code: Select all

XBMC2.JSONRPC(u'GUI.ShowNotification', u'{"title": "{eg.event.payload[0].split(\'/\')[0]} dein Akku ist fast leer", "message": "{eg.event.payload[0].split(\'/\')[1]}% verbleibend", "image": "C:\\Program Files (x86)\\EventGhost\\webserver_root\\lowbat.png"}', True, True)
The result is an exception because of the ... "{eg.event.payload[0].split(\'/\')[0]} dein Akku ist fast leer" ...
When i DONT use variables/payload-data, the JSON cmd works and ill see the notification in Kodi:

Code: Select all

XBMC2.JSONRPC(u'GUI.ShowNotification', u'{"title": "Test1", "message": "Test2", "image": "C:\\Program Files (x86)\\EventGhost\\webserver_root\\lowbat.png"}', True, True)
Any hints how ill can use variables/payload-data in JSON API cmds?

Keep up the good work
thx
pOpY
jonib
Plugin Developer
Posts: 1328
Joined: Thu Mar 26, 2009 9:33 pm
Location: Sweden

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jonib »

popy wrote:Nice plugin!!! Now i can use my USBUIRT with Kodi.
Thanks
Any hints how ill can use variables/payload-data in JSON API cmds?
If you double up the curly braces it should work, I had to do a hack as JSON already uses curly braces. (This might change if I figure out a better way)

Code: Select all

{{eg.event.payload[0].split('/')[0]}}
jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image
popy
Posts: 24
Joined: Tue Mar 24, 2009 8:40 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by popy »

thx, will try this and report back.
Another question:

The battery notification is rather rare, but every time it gets triggered there is a notification in Kodi -> "Eventghost, New Connection" and after this my custom text is displayed.
Also when i manually trigger the notification, wait a few minutes and trigger it again -> the connected notification will be display first again.

Is there a way to prevent this? (heartbeat the connection so it doent get closed or any setting i have missed)

Eventghost and Kodi are running on the same Windows 10 machine,

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

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by jonib »

popy wrote:thx, will try this and report back.
Please do.
Is there a way to prevent this? (heartbeat the connection so it doent get closed or any setting i have missed)
With these commands the plugin creates a new connection every time, it's some of the oldest code in the plugin and I would need to rewrite/redesign big parts of the plugin to keep it connected. It's on my todo list but as my development pace is glacial and other things seem higher priority to fix/add.

The JSON-RPC Notifications use that kind of connection but it's not straight forward to use it for this.

jonib
XBMC2 plugin to control XBMC. If you want to flatter me Image
popy
Posts: 24
Joined: Tue Mar 24, 2009 8:40 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by popy »

thx for clearing things up.
Take your time :-)

pOpY
popy
Posts: 24
Joined: Tue Mar 24, 2009 8:40 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by popy »

jonib wrote:
popy wrote:Nice plugin!!! Now i can use my USBUIRT with Kodi.
Thanks
Any hints how ill can use variables/payload-data in JSON API cmds?
If you double up the curly braces it should work, I had to do a hack as JSON already uses curly braces. (This might change if I figure out a better way)

Code: Select all

{{eg.event.payload[0].split('/')[0]}}
jonib
works, thx
Kvantos
Posts: 2
Joined: Fri Oct 09, 2015 9:05 am

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by Kvantos »

Dear All.
I would get the "properties": ["speed"] parameter to EG global variable, it need for realise "Discrete Play / Pause" function.
Now I use phyton script for send JSONRPC:
eg.plugins.XBMC2.JSONRPC(u'Player.GetProperties', u'{ "playerid": 0, "properties": ["speed"] }', True)

Please help me. How can I do it?
Thank you in advance.
bengalih
Posts: 48
Joined: Sat Feb 25, 2012 1:13 am

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by bengalih »

Kvantos wrote:Dear All.
I would get the "properties": ["speed"] parameter to EG global variable, it need for realise "Discrete Play / Pause" function.
Now I use phyton script for send JSONRPC:
eg.plugins.XBMC2.JSONRPC(u'Player.GetProperties', u'{ "playerid": 0, "properties": ["speed"] }', True)

Please help me. How can I do it?
Thank you in advance.
Sure, just wrote this function for a script of mine:

Code: Select all

def getVideoPlaying():
    videoPlaying = 0
    activePlayer = eg.plugins.XBMC2.JSONRPC(u'Player.GetActivePlayers', u'', False)
    if activePlayer:
        if activePlayer[0]["type"] == "video":
            mediaSpeed = eg.plugins.XBMC2.JSONRPC(u'Player.GetProperties', u'1,["speed"]', False)["speed"]
            if mediaSpeed > 0:
                videoPlaying = 1
    return videoPlaying
So you can run that function in a script and the return value will be true or false to operate on your next action.
If instead you really want to send that to a global variable (which I'm not sure how good that will be since you will probably need to check this value immediately before acting upon it.
But if you do want return a global variable instead of just using the function you would just use eg.globals, like:

Code: Select all

def getVideoPlaying():
    videoPlaying = 0
    activePlayer = eg.plugins.XBMC2.JSONRPC(u'Player.GetActivePlayers', u'', False)
    if activePlayer:
        if activePlayer[0]["type"] == "video":
            mediaSpeed = eg.plugins.XBMC2.JSONRPC(u'Player.GetProperties', u'1,["speed"]', False)["speed"]
            if mediaSpeed > 0:
                videoPlaying = 1
    eg.globals.videoPlaying = videoPlaying
Kvantos
Posts: 2
Joined: Fri Oct 09, 2015 9:05 am

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by Kvantos »

>>bengalih
Its worked! Thank you very helpful.
eirik226
Experienced User
Posts: 142
Joined: Wed Nov 07, 2012 5:22 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by eirik226 »

Hello,

thanks for a great plugin, I've been using it a lot. I have a question tho' is it possible to send a command to kodi that makes kodi just update part of my library? I don't want to update moveis, only TV-shows because my moviescraper is really bad. I've tried searching around, but can't seem to find anything, maybe my search words are bad but does anyone have any idea how I can only update TV-shows?

Thanks in advance!
bengalih
Posts: 48
Joined: Sat Feb 25, 2012 1:13 am

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by bengalih »

eirik226 wrote:Hello,

thanks for a great plugin, I've been using it a lot. I have a question tho' is it possible to send a command to kodi that makes kodi just update part of my library? I don't want to update moveis, only TV-shows because my moviescraper is really bad. I've tried searching around, but can't seem to find anything, maybe my search words are bad but does anyone have any idea how I can only update TV-shows?

Thanks in advance!
XBMC2 > Experimental > JSONRPC
example
example
The text in there is:

Code: Select all

{"directory":"smb://mediabase/media/Video/TV"}
Replace with your path as defined in kodi/userdata/sources.xml
eirik226
Experienced User
Posts: 142
Joined: Wed Nov 07, 2012 5:22 pm

Re: Support for XBMC2 plugin (formerly XBMCRepeat)

Post by eirik226 »

Thank you so much - if your reply was the it's more XMBC question then EG (before edit), the reason I asked was exectly what you showed me - how I could do it in EG, anyway thanks for your reply, helped me out a lot!

The reason I must do this in EG:

I run kodi and all other stuff on a Intel NUC (small computer) that is on 24/7 - but I use it for a lot more then just Kodi, so I use directory watcher to see if any new files have been created, if so, EG starts kodi, sends update command, wait some time and then exit the application. (So it's like the update never happend)

One more question - is it possible to automate the shutdown process after the library update? Right now I have "Wait some time 240 sec" (It will take around that time to update the library) then shutdown, but i'm afraid it might take longer sometimes and EG force a shutdown in the middle of the update - anyway around this?
Post Reply