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.
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.
Attention kgschlosser
Attention kgschlosser
kgschlosser
Something is going on with my login(s) and each time I try to login, it throws errors at random, like wrong email, pw, pass phrase etc. so I have to make a new login when I need to post. (Not logging out with this one!!)
Anyway, you helped me out a while ago solve this
http://www.eventghost.org/forum/viewtop ... fa74ef8b72
I'm trying to so something similar for a week with no luck, would you mind helping?
Details:
The event is XBMC2.Player.OnPlay.movie {u'item': {u'id': 231}, u'player': {u'playerid': 1, u'speed': 1}}
The eg.result printed is ..{u'genre': [u'Family', u'Animation'], u'title': u"A Bug's Life", u'type': u'movie', u'id': 11, u'label': u"A Bug's Life"}
I'm trying to find a way to trigger an action from "Animation". Is this possible? also if possible, I'd like to have things setup like the channels where I can add other types for different genres to trigger different actions.
When I use the cmd print type as you suggested before, it shows NONE
Thanks!
Eric
Something is going on with my login(s) and each time I try to login, it throws errors at random, like wrong email, pw, pass phrase etc. so I have to make a new login when I need to post. (Not logging out with this one!!)
Anyway, you helped me out a while ago solve this
http://www.eventghost.org/forum/viewtop ... fa74ef8b72
I'm trying to so something similar for a week with no luck, would you mind helping?
Details:
The event is XBMC2.Player.OnPlay.movie {u'item': {u'id': 231}, u'player': {u'playerid': 1, u'speed': 1}}
The eg.result printed is ..{u'genre': [u'Family', u'Animation'], u'title': u"A Bug's Life", u'type': u'movie', u'id': 11, u'label': u"A Bug's Life"}
I'm trying to find a way to trigger an action from "Animation". Is this possible? also if possible, I'd like to have things setup like the channels where I can add other types for different genres to trigger different actions.
When I use the cmd print type as you suggested before, it shows NONE
Thanks!
Eric
Re: Attention kgschlosser
Try this:
Code: Select all
genre = eg.result['genre']
for x in genre:
if x == "Animation":
eg.TriggerEvent("Genre", "Animation", "Kodi_matched")Re: Attention kgschlosser
Thanks for helping out. Tried this:
PlayerID = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False)[0][\'playerid\']
eg.result = eg.plugins.XBMC2.JSONRPC(u\'Player.GetItem\', u"["+str(PlayerID)+",[\'genre\',\'title\']]", False)
genre = eg.result[\'genre\']
for x in genre:
if x == "Animation":
eg.TriggerEvent("Genre", "Animation", "Kodi_matched")
It throws KeyError 'genre'
this is what I get when I print eg.result
{u'genre': [u'Family', u'Animation'], u'title': u"A Bug's Life", u'type': u'movie', u'id': 11, u'label': u"A Bug's Life"}
PlayerID = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False)[0][\'playerid\']
eg.result = eg.plugins.XBMC2.JSONRPC(u\'Player.GetItem\', u"["+str(PlayerID)+",[\'genre\',\'title\']]", False)
genre = eg.result[\'genre\']
for x in genre:
if x == "Animation":
eg.TriggerEvent("Genre", "Animation", "Kodi_matched")
It throws KeyError 'genre'
this is what I get when I print eg.result
{u'genre': [u'Family', u'Animation'], u'title': u"A Bug's Life", u'type': u'movie', u'id': 11, u'label': u"A Bug's Life"}
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Attention kgschlosser
that's because you have \'s where they aren't needed
this
is supposed to be this
this
Code: Select all
genre = eg.result[\'genre\']
Code: Select all
genre = eg.result['genre']
- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Attention kgschlosser
see what is happening is you are looking at what you are sending the XBMC plugin and trying to use that same thing to access a dictionary
the information you are passing the XBMC plugin is a str.
this below is a string representation of a list.
I am thinking to make this easier for you to understand you may want to code the script in this manner. it will defiantly make it a lot easier to read
in the code below. I am creating a list called getTitle with all of the bits in their proper spots. then when i pass it to XBMC i will convert it to a string using str() instead of having to do all of the escaping and quotes.
I ditched the iteration of result and just simply ask if Animation is in the result but i also ask result if it has genre in it. because if it doesn't and you do result['genre'] it will throw you a KeyError traceback so instead of assuming it's in there we want to make sure so you don't get any of the red on the screen
the information you are passing the XBMC plugin is a str.
this below is a string representation of a list.
Code: Select all
u"["+str(PlayerID)+",[\'genre\',\'title\']]"
in the code below. I am creating a list called getTitle with all of the bits in their proper spots. then when i pass it to XBMC i will convert it to a string using str() instead of having to do all of the escaping and quotes.
I ditched the iteration of result and just simply ask if Animation is in the result but i also ask result if it has genre in it. because if it doesn't and you do result['genre'] it will throw you a KeyError traceback so instead of assuming it's in there we want to make sure so you don't get any of the red on the screen
Code: Select all
playerId= eg.plugins.XBMC2.JSONRPC('Player.GetActivePlayers', '', False)[0]['playerid']
getTitle = [str(playerId), ['genre', 'title']]
result = eg.plugins.XBMC2.JSONRPC('Player.GetItem', str(getTitle) , False)
if if 'genre' in result and 'Animation' in result['genre'] :
eg.TriggerEvent(
prefix='Kodi_matched',
suffix='Genre.Animation',
payload='Animation'
)
Re: Attention kgschlosser
Just a quick note, there is an extra if in that last code Kgschlosser posted. Also, the get player id action can be removed as it's always going to be "1" with the XBMC2 plugins OnPlayMovie event. So Just this should suffice.
Code: Select all
getTitle = ['1', ['genre', 'title']]
result = eg.plugins.XBMC2.JSONRPC('Player.GetItem', str(getTitle) , False)
if 'genre' in result and 'Animation' in result['genre'] :
eg.TriggerEvent(
prefix='Kodi_matched',
suffix='Genre.Animation',
payload='Animation'
)- kgschlosser
- Site Admin
- Posts: 5190
- Joined: Fri Jun 05, 2015 5:43 am
- Location: Rocky Mountains, Colorado USA
Re: Attention kgschlosser
ooops heh.. sorry...
Re: Attention kgschlosser
I can't thank you enough for helping sort this both of you!
the first thing was the slash"\" that only appeared when I copied as python to post and wasn't in the script.
I caught the extra if statement and adjusted but still gettin that nasty red error...
Python Script
Error:
{
"code": -32602,
"data": {
"method": "Player.GetItem",
"stack": {
"message": "Invalid type string received",
"name": "playerid",
"type": "integer"
}
},
"message": "Invalid params."
}
Traceback (most recent call last):
Python script "10", line 3, in <module>
if 'genre' in result and 'Animation' in result['genre'] :
TypeError: argument of type 'NoneType' is not iterable
the first thing was the slash"\" that only appeared when I copied as python to post and wasn't in the script.
I caught the extra if statement and adjusted but still gettin that nasty red error...
Python Script
Error:
{
"code": -32602,
"data": {
"method": "Player.GetItem",
"stack": {
"message": "Invalid type string received",
"name": "playerid",
"type": "integer"
}
},
"message": "Invalid params."
}
Traceback (most recent call last):
Python script "10", line 3, in <module>
if 'genre' in result and 'Animation' in result['genre'] :
TypeError: argument of type 'NoneType' is not iterable
Re: Attention kgschlosser
Sorry, my fault. It was expecting an integer instead of string for the player id. This should work.
Code: Select all
getTitle = [1, ['genre', 'title']]
result = eg.plugins.XBMC2.JSONRPC('Player.GetItem', str(getTitle) , False)
if 'genre' in result and 'Animation' in result['genre'] :
eg.TriggerEvent(
prefix='Kodi_matched',
suffix='Genre.Animation',
payload='Animation'
)Re: Attention kgschlosser
the script runs but no events trigger. Change "False" to True in this line
result = eg.plugins.XBMC2.JSONRPC('Player.GetItem', str(getTitle) , False)
prints Result:
{
"item": {
"genre": [
"Animation",
"Action",
"Adventure"
],
"id": 129,
"label": "The Incredibles",
"type": "movie"
}
}
it's clearly there I don't understand why it won't pick up on it.
result = eg.plugins.XBMC2.JSONRPC('Player.GetItem', str(getTitle) , False)
prints Result:
{
"item": {
"genre": [
"Animation",
"Action",
"Adventure"
],
"id": 129,
"label": "The Incredibles",
"type": "movie"
}
}
it's clearly there I don't understand why it won't pick up on it.
Re: Attention kgschlosser
Okay, sorry again. I should have looked at the result closer. It's actually result['item']['genre'] . If you look at the structure of the returned result you'll see 'item' is the whole group, then 'genre', then items within the genre list.
I tested this, so it should be right now.
Just another note, when i tested this with The Simpsons Movie. The genre i got back was 'Family/Animation', if you have movies that don't match 'Animation' exactly this script won't work. If that's a problem for you it can be changed to find any variation of 'Animation'.
I tested this, so it should be right now.
Code: Select all
getTitle = [1, ['genre', 'title']]
result = eg.plugins.XBMC2.JSONRPC('Player.GetItem', str(getTitle) , False)
if 'genre' in result['item'] and 'Animation' in result['item']['genre'] :
eg.TriggerEvent(
prefix='Kodi_matched',
suffix='Genre.Animation',
payload='Animation'
)Re: Attention kgschlosser
Yep that works! thank - you
More importantly, I understand how it works. I knew Item had something to do with it but just couldn't get there.
THANKS AGAIN!
More importantly, I understand how it works. I knew Item had something to do with it but just couldn't get there.
THANKS AGAIN!
