access second argument of url string

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
User avatar
Fiasco
Plugin Developer
Posts: 222
Joined: Fri Jul 24, 2009 5:32 am
Location: St. Louis MO
Contact:

access second argument of url string

Post by Fiasco » Sun Sep 06, 2009 4:03 am

http://192.168.2.103/index.html?volumeZ1&1b

volumez1 is the event and the above appears like this in eventghost

HTTP.volumeZ1 [u'1b']

How do I access the 1b argument to pass it to a plugin command.

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: access second argument of url string

Post by Bartman » Sun Sep 06, 2009 5:25 am

This is the payload of the event. use eg.event.payload in a macro. Since the payload is a list in this case you have to use eg.event.payload[0]

User avatar
Fiasco
Plugin Developer
Posts: 222
Joined: Fri Jul 24, 2009 5:32 am
Location: St. Louis MO
Contact:

Re: access second argument of url string

Post by Fiasco » Sun Sep 06, 2009 5:42 am

do I have to put it in curly brackets or anything? The variable I always end up getting is the string literal eg.event.payload[0]

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: access second argument of url string

Post by Bartman » Sun Sep 06, 2009 5:44 am

That's right. Curly braces trigger the evaluating mechanism of EG.

User avatar
Fiasco
Plugin Developer
Posts: 222
Joined: Fri Jul 24, 2009 5:32 am
Location: St. Louis MO
Contact:

Re: access second argument of url string

Post by Fiasco » Sun Sep 06, 2009 5:47 am

also, within a plugin script how can I test to see if eg.event exists without throwing a NoneType error when it doesnt?

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: access second argument of url string

Post by Bartman » Sun Sep 06, 2009 5:57 am

Fiasco wrote:also, within a plugin script how can I test to see if eg.event exists without throwing a NoneType error when it doesnt?

Code: Select all

if eg.event:
    #do your stuff

User avatar
Fiasco
Plugin Developer
Posts: 222
Joined: Fri Jul 24, 2009 5:32 am
Location: St. Louis MO
Contact:

Re: access second argument of url string

Post by Fiasco » Sun Sep 06, 2009 6:27 am

Bartman wrote:That's right. Curly braces trigger the evaluating mechanism of EG.
I've got my onkyo macros on the right screen of eventghost.

I tried putting {eg.event.payload[0]} as the argument to the macro but within the script I end up with a string literal of {eg.event.payload[0]}

Bartman
Plugin Developer
Posts: 881
Joined: Sun Feb 12, 2006 9:03 am

Re: access second argument of url string

Post by Bartman » Sun Sep 06, 2009 11:15 am

call eg.ParseString to evalute the input

Post Reply