Gimme a hand with script

Do you have questions about writing plugins or scripts in Python? Meet the coders here.
Post Reply
CollinR
Experienced User
Posts: 265
Joined: Tue Sep 05, 2006 7:16 am
Location: Oklahoma
Contact:

Gimme a hand with script

Post by CollinR » Mon Oct 13, 2008 5:42 pm

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="908">
    <Macro Name="Generate Slot Events" Expanded="True">
        <Event Name="TCP.Changer1.*">
        </Event>
        <Action>
            EventGhost.PythonScript(u'event = eg.event.string\nparts = event.split(".")\nif len(parts) == 3 and parts[-2] == \'Changer1\':\n    device = parts[-2]\n    slot = parts[-1]\n    print device\n    if slot.isdigit():\n        slot = slot.zfill(3) \n        for digit in slot:\n            eg.TriggerEvent(\'Num\' + \'-\' + digit,prefix=device)')
        </Action>
    </Macro>
</EventGhost>
How do I subtract 400 from the parts[-1]?

Basically I have my changer mapped as channels 400-800 on my SageTV setup.

Sage generates the events just fine but it provides the channel in the guide, to keep confusion and channel remapping to a minimum I used slot#+400 so my DVDs show as channels 400-800. To come back to the DVD changer I need to subtract that 400 but I can't figure out how to do it.

So

slot = (parts[-1] - 400)
or
slot1 = parts[-1]
slot = int(slot1) - 400

is my guesses however I have no python knowledge and am basically self teaching. :lol: Obviously neither work. :(

CollinR
Experienced User
Posts: 265
Joined: Tue Sep 05, 2006 7:16 am
Location: Oklahoma
Contact:

Re: Gimme a hand with script

Post by CollinR » Mon Oct 13, 2008 6:15 pm

Nevermind
slot1 = parts[-1]
slot = unicode(int(slot1) - 400)

Post Reply