<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1722" Guid="{3C00A5F8-7F7D-49D0-90D2-CF2157074537}" Time="1481092444.8">
    <Autostart Name="Autostart" Expanded="True">
        <Plugin Identifier="Suntracker" Guid="{6AE8C0C3-93B4-4446-BC77-FDFA2528E531}" File="SunTracker">
            gAJdcQAoVQMwLjBxAWgBVQU2NjIwM3ECWB0AAAAwMTAxLDA1MDEsMDYwNiwxMjI0LDEyMjUsMTIyNnEDWCIAAAAwMTA2LDA0MDIsMDQwNSwwNTEyLDA1MjIsMDUyMywwNjI1cQRYAgAAADA2cQVYAgAAADEwcQaJiIhYBgAAACswMS4wMHEHWAgAAABpbXBlcmlhbHEISwWJWAQAAABNYWlucQmIZS4=
        </Plugin>
        <Plugin Enabled="False" Identifier="Sonos" Guid="Sonos" File="Sonos">
            gAJLAIVxAC4=
        </Plugin>
        <Plugin Identifier="XBMC2" Guid="{8C8B850C-773F-4583-AAD9-A568262B7933}" File="XBMCRepeat">
            gAJ9cQAoVQdKU09OUlBDcQF9cQIoVQZlbmFibGVxA4hVBHBvcnRxBE2CI3VVC0V2ZW50U2VydmVycQV9cQYoaAOIaARNMSZ1VQxsb2dSYXdFdmVudHNxB4lVCUJyb2FkY2FzdHEIfXEJKGgDiWgETVYgdVUEWEJNQ3EKfXELKFUIdXNlcm5hbWVxDFgAAAAAcQ1VAmlwcQ5VCTEyNy4wLjAuMXEPVQhwYXNzd29yZHEQaA1oBE2QH3VVCGxvZ0RlYnVncRGJdYmGcRIu
        </Plugin>
        <Plugin Identifier="XBMC22" Guid="{8C8B850C-773F-4583-AAD9-A568262B7933}" File="XBMCRepeat">
            gAJ9cQAoVQdKU09OUlBDcQF9cQIoVQZlbmFibGVxA4hVBHBvcnRxBE2CI3VVC0V2ZW50U2VydmVycQV9cQYoaAOIaARNMSZ1VQxsb2dSYXdFdmVudHNxB4lVCUJyb2FkY2FzdHEIfXEJKGgDiWgETVYgdVUEWEJNQ3EKfXELKFUIdXNlcm5hbWVxDFUAcQ1VAmlwcQ5YDQAAADE5Mi4xNjguMC4xMjVxD1UIcGFzc3dvcmRxEGgNaARNmB91VQhsb2dEZWJ1Z3ERiXWIhnESLg==
        </Plugin>
        <Plugin Identifier="Webserver" Guid="{E4305D8E-A3D3-4672-B06E-4EA1F0F6C673}" File="Webserver">
            gAIoWAAAAABxAE0rFFgMAAAARDpcV1MgLSBEZW1vcQFYCgAAAEV2ZW50R2hvc3RxAmgAaAB9cQMoWBMAAABrb2RpZGVmYXVsdHR2cG9zdGVycQRYEgAAAGltYWdlcy9UVl9pY29uLnBuZ3EFVRZQZXJzaXN0ZW50Z3JvY2VyeWl0ZW0xcQZYDgAAAEdyb2NlcnkgaXRlbSAxcQdYEAAAAGtvZGlhcnRkaXJlY3RvcnlxCFgdAAAARDovL1dTIC0gRGVtby9pbWFnZXMva29kaWFydC9xCVgQAAAAa29kaWFjdGl2ZXBsYXllcnEKWAEAAAAwcQtYCQAAAFdVemlwY29kZXEMWAUAAAA2NjIwM3ENWBYAAABrb2RpZGVmYXVsdG1vdmllcG9zdGVycQ5YEgAAAGltYWdlcy9tb19pY29uLnBuZ3EPWAgAAABrb2Rpcm9vbXEQWAgAAABCYXNlbWVudHERWA4AAABpVHVuZXNfcnVubmluZ3ESWAQAAABUcnVlcRNYFgAAAGtvZGlkZWZhdWx0YXJ0aXN0dGh1bWJxFFgRAAAAaW1hZ2VzL2FfaWNvbi5wbmdxFVgJAAAARDBzdW5yaXNlcRZYBAAAADc6MjVxF1gNAAAAZGF5bmlnaHRDeWNsZXEYWAQAAAB0aW1lcRlYDAAAAGlUdW5lc3JlcGVhdHEaWAQAAABUcnVlcRtYDgAAAGlUdW5lc3J1bl9pY29ucRxYBAAAAFRydWVxHVgUAAAAa29kaW1hdGNoZWRzZWFyY2hudW1xHlgBAAAAMXEfWBcAAABrb2RpZGVmYXVsdGFydGlzdGZhbmFydHEgWBYAAABpbWFnZXMvZmFuYXJ0X2ljb24ucG5ncSFYDAAAAGtvZGlydW5faWNvbnEiWAQAAABUcnVlcSNYCQAAAG1icnVubmluZ3EkWAQAAABUcnVlcSVYDQAAAGlUdW5lc3NodWZmbGVxJlgFAAAARmFsc2VxJ1gKAAAARDB0aWRlbGV2NHEoWEIAAAAwLjAyIDxkaXYgY2xhc3M9InRpZGVzdWZmaXgiIHN0eWxlPSJkaXNwbGF5OmlubGluZS1ibG9jayI+ZnQ8L2Rpdj5xKVgSAAAAa29kaWRlZmF1bHRjZHRodW1icSpYEQAAAGltYWdlcy9NX2ljb24ucG5ncStYCgAAAEQwdGlkZWxldjFxLFhCAAAAMS4yMiA8ZGl2IGNsYXNzPSJ0aWRlc3VmZml4IiBzdHlsZT0iZGlzcGxheTppbmxpbmUtYmxvY2siPmZ0PC9kaXY+cS1YCgAAAEQwdGlkZWxldjNxLlhCAAAAMC45NSA8ZGl2IGNsYXNzPSJ0aWRlc3VmZml4IiBzdHlsZT0iZGlzcGxheTppbmxpbmUtYmxvY2siPmZ0PC9kaXY+cS9YCgAAAEQwdGlkZWxldjJxMFhCAAAAMC4wNiA8ZGl2IGNsYXNzPSJ0aWRlc3VmZml4IiBzdHlsZT0iZGlzcGxheTppbmxpbmUtYmxvY2siPmZ0PC9kaXY+cTFYBQAAAFdVa2V5cTJYEAAAAGQxNTVkOTIxOWE2MjY2NDJxM1gRAAAAa29kaV9wbGF5bGlzdGVkaXRxNFgFAAAARmFsc2VxNVgLAAAARDB0aWRldGltZTFxNlhTAAAAOTowOTxkaXYgY2xhc3M9InRpZGVzdWZmaXgiIHN0eWxlPSJkaXNwbGF5OmlubGluZS1ibG9jazsgbWFyZ2luLWxlZnQ6M3B4OyI+YW08L2Rpdj5xN1gIAAAARDBzdW5zZXRxOFgEAAAANDo1NnE5WAsAAABEMHRpZGV0aW1lMnE6WFMAAAAyOjQ0PGRpdiBjbGFzcz0idGlkZXN1ZmZpeCIgc3R5bGU9ImRpc3BsYXk6aW5saW5lLWJsb2NrOyBtYXJnaW4tbGVmdDozcHg7Ij5wbTwvZGl2PnE7WAsAAABEMHRpZGV0aW1lM3E8WFMAAAA5OjM1PGRpdiBjbGFzcz0idGlkZXN1ZmZpeCIgc3R5bGU9ImRpc3BsYXk6aW5saW5lLWJsb2NrOyBtYXJnaW4tbGVmdDozcHg7Ij5wbTwvZGl2PnE9WBMAAABrb2RpYXJ0YWN0aXZlcGxheWVycT5YAQAAADBxP1gKAAAAaVR1bmVzbXV0ZXFAWAUAAABGYWxzZXFBWAgAAAB0aWRlaGlkZXFCWAUAAABGYWxzZXFDWAsAAABEMHRpZGV0aW1lNHFEWFMAAAAzOjQ4PGRpdiBjbGFzcz0idGlkZXN1ZmZpeCIgc3R5bGU9ImRpc3BsYXk6aW5saW5lLWJsb2NrOyBtYXJnaW4tbGVmdDozcHg7Ij5hbTwvZGl2PnFFdYhYAQAAACxxRlgCAAAAOztxR2gAaACJdHFILg==
        </Plugin>
        <Plugin Identifier="Timer" Guid="{6149CA99-1FCD-4450-9160-7543BC20CFD3}" File="Timer">
            gAIpLg==
        </Plugin>
        <Plugin Identifier="NetworkSender" Guid="{B4F0DAFE-2E0B-47F3-A155-ED72C7A4E270}" File="NetworkSender">
            gAJYDQAAADE5Mi4xNjguMC4xMjVxAE0ABFgAAAAAcQGHcQIu
        </Plugin>
        <Plugin Identifier="iTunes" Guid="iTunes" File="iTunes">
            gAIpLg==
        </Plugin>
    </Autostart>
    <Folder Name="WebApp" Expanded="True">
        <Folder Name="Demo">
            <Macro Name="Webserver: Set temporary value: DemoImgButton: False">
                <Event Name="Main.OnInit" />
                <Event Name=".WsClientConnected" />
                <Action>
                    Webserver.SetValue(u'DemoImgButton', u'True', False, False, 1)
                </Action>
                <Action>
                    Webserver.BroadcastValue(u'DemoImgButton', None, u'', None)
                </Action>
                <Action>
                    Webserver.SetValue(u'demohideholder', u'show', False, False, 1)
                </Action>
            </Macro>
            <Folder Name="Set Variables Manual">
                <Macro Name="Webserver: Set temporary value: checktoggle: True">
                    <Action>
                        Webserver.SetValue(u'checktoggle', u'True', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'checktoggle', None, u'', None)
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set temporary value: DemoImgButton: False">
                    <Action>
                        Webserver.SetValue(u'DemoImgButton', u'True', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'DemoImgButton', None, u'', None)
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set temporary value: DemoSwitchselect: False">
                    <Action>
                        Webserver.SetValue(u'DemoSwitchselect', u'False', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'DemoSwitchselect', None, u'', None)
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set temporary value: DemoSlider: 55">
                    <Action>
                        Webserver.SetValue(u'DemoSlider', u'55', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'DemoSlider', None, u'', None)
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set temporary value: demotxt: demotext">
                    <Action>
                        Webserver.SetValue(u'demotxt', u'New Demo Text.', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'demotxt', None, u'', None)
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set temporary value: demohideholder: hide">
                    <Action>
                        Webserver.SetValue(u'demohideholder', u'hide', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'demohideholder', None, u'', None)
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="Evaluated Actions">
                <Macro Name="Show/hide">
                    <Event Name="demo.showhidebtn" />
                    <Action>
                        EventGhost.PythonScript(u'state = eg.plugins.Webserver.GetValue(u\'demohideholder\', False)\nif state == "hide":\n    eg.plugins.Webserver.SetValue(u\'demohideholder\', u\'show\', False, False, 1)\nelif state == "show":\n        eg.plugins.Webserver.SetValue(u\'demohideholder\', u\'hide\', False, False, 1)\neg.plugins.Webserver.BroadcastValue(u\'demohideholder\', None, u\'\', None)')
                    </Action>
                </Macro>
                <Macro Name="Show OSD: FlipSwitch Value">
                    <Event Name="Flip.DemoSwitchselect" />
                    <Action>
                        EventGhost.PythonScript(u'payload = eg.event.payload\nif payload == "True":\n    eg.plugins.EventGhost.ShowOSD(u\'FlipSwitch value = True\', u\'0;-37;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', (0, 0, 0), None, 0, (500, 300), 0, 4.0, False)\n    eg.plugins.Webserver.SetValue(u\'DemoSwitchselect\', u\'True\', False, False, 1)\nelif payload == "False":\n    eg.plugins.EventGhost.ShowOSD(u\'FlipSwitch value = False\', u\'0;-37;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', (0, 0, 0), None, 0, (500, 300), 0, 4.0, False)\n    eg.plugins.Webserver.SetValue(u\'DemoSwitchselect\', u\'False\', False, False, 1)\neg.plugins.Webserver.BroadcastValue(u\'DemoSwitchselect\', None, u\'\', None)')
                    </Action>
                </Macro>
                <Macro Name="Show OSD: SelectMenu Value">
                    <Event Name="Demo.SelectMenu" />
                    <Action>
                        EventGhost.PythonScript(u"payload = eg.event.payload\neg.plugins.EventGhost.ShowOSD(u'Select value = ' + payload, u'0;-37;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (0, 0, 0), None, 0, (500, 300), 0, 4.0, False)\n")
                    </Action>
                </Macro>
                <Macro Name="Show OSD: Check Value">
                    <Event Name="Basic.checktoggle" />
                    <Action>
                        EventGhost.PythonScript(u'payload = eg.event.payload\nif payload == "True":\n    eg.plugins.EventGhost.ShowOSD(u\'Check value = True\', u\'0;-37;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', (0, 0, 0), None, 0, (500, 300), 0, 4.0, False)\n    eg.plugins.Webserver.SetValue(u\'checktoggle\', u\'True\', False, False, 1)\nelif payload == "False":\n    eg.plugins.EventGhost.ShowOSD(u\'Check value = False\', u\'0;-37;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', (0, 0, 0), None, 0, (500, 300), 0, 4.0, False)\n    eg.plugins.Webserver.SetValue(u\'checktoggle\', u\'False\', False, False, 1)\neg.plugins.Webserver.BroadcastValue(u\'checktoggle\', None, u\'\', None)')
                    </Action>
                </Macro>
                <Macro Name="Show OSD:  DemoImgButton Value">
                    <Event Name="button.DemoImgButton" />
                    <Action>
                        EventGhost.PythonScript(u'payload = eg.plugins.Webserver.GetValue(u\'DemoImgButton\', False)\nif payload == "True":\n    eg.plugins.EventGhost.ShowOSD(u\'DemoImgButton value = False\', u\'0;-37;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', (0, 0, 0), None, 0, (500, 300), 0, 4.0, False)\n    eg.plugins.Webserver.SetValue(u\'DemoImgButton\', u\'False\', False, False, 1)\n    eg.plugins.Webserver.BroadcastValue(u\'DemoImgButton\', None, u\'\', None)\nelif payload == "False":\n    eg.plugins.EventGhost.ShowOSD(u\'DemoImgButton value = True\', u\'0;-37;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', (0, 0, 0), None, 0, (500, 300), 0, 4.0, False)\n    eg.plugins.Webserver.SetValue(u\'DemoImgButton\', u\'True\', False, False, 1)\n    eg.plugins.Webserver.BroadcastValue(u\'DemoImgButton\', None, u\'\', None)\n')
                    </Action>
                </Macro>
                <Macro Name="Show OSD:  DemoSlider Value">
                    <Event Name="Demo.DemoSlider" />
                    <Action>
                        EventGhost.PythonScript(u"payload = eg.event.payload\neg.plugins.EventGhost.ShowOSD(u'DemoSlider value = ' + payload, u'0;-37;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (0, 0, 0), None, 0, (500, 300), 0, 4.0, False)\neg.plugins.Webserver.SetValue(u'DemoSlider', payload, False, False, 1)\neg.plugins.Webserver.BroadcastValue(u'DemoSlider', None, u'', None)")
                    </Action>
                </Macro>
                <Macro Name="Show OSD:  DemoButton Value">
                    <Event Name="Demo.WSbutton" />
                    <Event Name="dynamic.button" />
                    <Action>
                        EventGhost.PythonScript(u"payload = eg.event.payload\neg.plugins.EventGhost.ShowOSD(u'WSbutton value = ' + payload, u'0;-37;0;0;0;700;0;0;0;0;3;2;1;34;Arial', (0, 0, 0), None, 0, (500, 300), 0, 4.0, False)")
                    </Action>
                </Macro>
                <Macro Name="Show OSD: Ajax Values">
                    <Event Name="Demo.Ajax" />
                    <Action>
                        EventGhost.PythonScript(u'payload1 = eg.event.payload[0]\npayload2 = eg.event.payload[1]\neg.plugins.EventGhost.ShowOSD("Payload1 = " + payload1 + ", Payload2 = " + payload2, u\'0;-37;0;0;0;700;0;0;0;0;3;2;1;34;Arial\', (0, 0, 0), None, 0, (500, 300), 0, 4.0, False)')
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="Set variable no evaluation">
                <Macro Name="Webserver: Set temporary value: DemoSlider: {eg.event.payload}">
                    <Event Name="Demo.DemoSlider" />
                    <Action>
                        Webserver.SetValue(u'DemoSlider', u'{eg.event.payload}', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'DemoSlider', None, u'', None)
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="Broadcast Data">
                <Macro Name="Webserver: Broadcast data: WSdemoSelect">
                    <Event Name="demo.updateselectbtn" />
                    <Action>
                        Webserver.WsBroadcastData(u'DemoSelectData', u'     {u"item name 1": u"item 1 value", u\'item name 2\': u\'item 2 value\', u\'item name 3\': u\'item 3 value\', u"item name 4": u"item 4 value", u\'item name 5\': u\'item 5 value\'}', u'', None, None)
                    </Action>
                </Macro>
                <Macro Name="Webserver: Broadcast data: WSdemoMenu">
                    <Event Name="demo.updatemenubtn" />
                    <Action>
                        Webserver.WsBroadcastData(u'DemoMenuData', u'     {u"item name 1": u"item 1 value", u\'item name 2\': u\'item 2 value\', u\'item name 3\': u\'item 3 value\', u"item name 4": u"item 4 value", u\'item name 5\': u\'item 5 value\'}', u'', None, None)
                    </Action>
                </Macro>
            </Folder>
        </Folder>
        <Folder Name="iTunes">
            <Folder Name="Actions">
                <Macro Name="iTunes Close">
                    <Event Name=".close_iTunes" />
                    <Action>
                        iTunes.Exit()
                    </Action>
                    <Action>
                        Webserver.SetValue(u'iTunesleftRating', u'&lt;img src="images/buttons/eqFalse.gif" width="48" height="24" alt=""/&gt;', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.SetValue(u'iTunesrun_icon', u'False', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.SetValue(u'iTunesplaypause', u'Stopped', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.SetValue(u'playstate', u'Paused', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.SetPersistentValue(u'iTunesrun_icon', u'True', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'iTunesrun_icon, iTunesplaypause, playstate, iTunesleftRating', None, u'', None)
                    </Action>
                    <Action>
                        Webserver.WsStopAllNamedPeriodicTasks(u'iTunesprogress')
                    </Action>
                </Macro>
                <Macro Name="iTunes: Start">
                    <Event Name=".start_iTunes" />
                    <Action>
                        iTunes.StartApp()
                    </Action>
                    <Action>
                        Webserver.SetValue(u'iTunesplaypause', u'Playing', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.SetPersistentValue(u'iTunesrun_icon', u'True', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'iTunesrun_icon, iTunesplaypause', None, u'', None)
                    </Action>
                </Macro>
                <Macro Name="iTunes: Shuffle">
                    <Event Name="iTunes.iTunesshuffled" />
                    <Action>
                        EventGhost.PythonScript(u'p = eg.plugins.iTunes.GetPlaylistShuffle()\np = str(p)\n\nif p == "True":\n    eg.plugins.iTunes.ShuffleOff()\n    print "Turning iTunes Shuffle On Now"\nelse:\n    eg.plugins.iTunes.ShuffleOn()')
                    </Action>
                    <Action>
                        EventGhost.NewJumpIf(XmlIdLink(176), 2, False)
                    </Action>
                </Macro>
                <Macro Name="iTunes: Repeat">
                    <Event Name="iTunes.iTunesrepeated" />
                    <Action>
                        EventGhost.PythonScript(u'p = eg.plugins.iTunes.GetPlaylistRepeat()\nif p == 2:\n    eg.plugins.iTunes.RepeatOff()\nelif p == 0:\n    eg.plugins.iTunes.RepeatAll()')
                    </Action>
                    <Action>
                        EventGhost.NewJumpIf(XmlIdLink(176), 2, False)
                    </Action>
                </Macro>
                <Macro Name="iTunes: Toggle mute">
                    <Event Name="iTunes.iTunesmuted" />
                    <Action>
                        EventGhost.PythonScript(u'eg.plugins.iTunes.ToggleMute()')
                    </Action>
                    <Action>
                        EventGhost.NewJumpIf(XmlIdLink(176), 2, False)
                    </Action>
                </Macro>
                <Macro Name="iTunes Set Volume">
                    <Event Name="iTunesVolumeLevelChanged" />
                    <Action>
                        EventGhost.PythonScript(u"p = eg.event.payload\nlevel = p[0]\nlevel = int(level)\nif level &lt; 10:\n    level = p\neg.plugins.iTunes.SetVolume(level)\nlevel = str(level)\nprint ('Volume set to ' + level)\n\n")
                    </Action>
                </Macro>
                <Macro Name="iTunes: Rating">
                    <Event Name="iTunes.star1" />
                    <Event Name="iTunes.star2" />
                    <Event Name="iTunes.star3" />
                    <Event Name="iTunes.star4" />
                    <Event Name="iTunes.star5" />
                    <Action>
                        EventGhost.PythonScript(u"p = str(eg.event.suffix)\np = p.split('r')\np = p[1]\nrating = p\np = int(p)\nstar = p * 20\nstar = str(star)\neg.plugins.iTunes.rating(star)\neg.plugins.Webserver.SetValue(u'iTunesrating', rating, False, False)\neg.plugins.Webserver.BroadcastValue(u'iTunesrating')\nprint ('Rating = ' + rating)")
                    </Action>
                </Macro>
                <Macro Name="iTunes: Next/Prev">
                    <Event Name="Web.iTunes" />
                    <Action Name="iTunes Next/Prev">
                        EventGhost.PythonScript(u'cmd = eg.event.payload\nif cmd == "next":\n    eg.plugins.iTunes.Skip()\n    \nelif cmd == "prev":\n    eg.plugins.iTunes.Replay()\n    ')
                    </Action>
                    <Action>
                        EventGhost.NewJumpIf(XmlIdLink(176), 2, False)
                    </Action>
                </Macro>
                <Macro Name="iTunes: Play/Pause">
                    <Event Name="iTunes.iTunesplaypaused" />
                    <Action Name="iTunes Play/Pause">
                        EventGhost.PythonScript(u'playstate = eg.plugins.iTunes.GetPlayerState()\neg.plugins.Webserver.WsStopAllNamedPeriodicTasks(u\'iTunesprogress\')\n\nif playstate == 1:\n    eg.plugins.iTunes.Pause()\n    eg.plugins.Webserver.SetValue(u\'iTunesleftRating\', \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesleftRating\')\n    eg.plugins.Webserver.SetValue(u\'iTunesplaypause\', \'Paused\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesplaypause\')\n    eg.plugins.Webserver.SetValue(u\'iTunesplaystate\', "Paused", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesplaystate\')\nelif playstate == 0: \n    eg.plugins.iTunes.Play()\n    eg.plugins.Webserver.SetValue(u\'iTunesleftRating\', \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesleftRating\')\n    eg.plugins.Webserver.SetValue(u\'iTunesplaypause\', \'Playing\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesplaypause\')\n    eg.plugins.Webserver.SetValue(u\'iTunesplaystate\', "Playing", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesplaystate\')\n    eg.plugins.Webserver.WsPeriodicallyBroadcastData(u\'iTunesprogress\', u\'{"itunesprogress", str(eg.plugins.iTunes.GetPlayerPosition()+1) + \\\'||\\\' + str(eg.plugins.iTunes.GetPlayerPosition()+1) + \\\'||\\\' + str(eg.plugins.iTunes.GetDuration() - (eg.plugins.iTunes.GetPlayerPosition()+1))}\', u\'\', True, 1.0)')
                    </Action>
                </Macro>
                <Macro Name="iTunes: Load Playlist">
                    <Event Name="iTunes.Playlist" />
                    <Action>
                        EventGhost.PythonScript(u'p = eg.event.payload\nprint p\neg.plugins.iTunes.LoadPlaylist(p)')
                    </Action>
                    <Action>
                        EventGhost.NewJumpIf(XmlIdLink(176), 0, False)
                    </Action>
                </Macro>
                <Macro Name="iTunes: Play Track">
                    <Event Name="iTunes.TracksMenu" />
                    <Event Name="iTunes.Track" />
                    <Action>
                        EventGhost.PythonScript(u'x = eg.event.payload\nb = eg.plugins.iTunes.GetPlaylistName()\nb = str(b)\nx = str(x)\neg.plugins.iTunes.PlaySongInPlaylist(x, b)')
                    </Action>
                    <Action>
                        EventGhost.TriggerEvent(u'reload.variables', 0.59999999999999998)
                    </Action>
                </Macro>
                <Macro Name="iTunes: Set Position">
                    <Event Name="iTunes.itunesprogress" />
                    <Action>
                        EventGhost.PythonScript(u'p = eg.event.payload\neg.plugins.iTunes.playerPos(p)\n')
                    </Action>
                </Macro>
                <Folder Name="Search &amp; Play">
                    <Macro Name="iTunes: Search (Artists}">
                        <Event Name="Search.iTunesArtistSearch" />
                        <Action>
                            EventGhost.PythonScript(u'p = eg.event.payload\nsearch = "Starting Playback of Artist " + p + " Now."\neg.plugins.iTunes.SearchAndPlay(\'Artists\', p, False, u\'eventghostTemp\')\neg.plugins.Webserver.SetValue(u\'iTunesLastSearchResult\', search, False, False)\n')
                        </Action>
                    </Macro>
                    <Macro Name="iTunes: Search (Album)">
                        <Event Name="Search.iTunesAlbumSearch" />
                        <Action>
                            EventGhost.PythonScript(u'p = eg.event.payload\nsearch = "Starting Playback of Matched Album " + p + " Now."\neg.plugins.iTunes.SearchAndPlay(\'Album\', p, False, u\'eventghostTemp\')\neg.plugins.Webserver.SetValue(u\'iTunesLastSearchResult\', search, False, False)    ')
                        </Action>
                    </Macro>
                    <Macro Name="iTunes: Search (Song)">
                        <Event Name="Search.iTunesSongSearch" />
                        <Action>
                            EventGhost.PythonScript(u'p = eg.event.payload\nsearch = "Starting playback of songs with " + p + " in the title Now."\neg.plugins.iTunes.SearchAndPlay(\'Album\', p, False, u\'eventghostTemp\')\neg.plugins.Webserver.SetValue(u\'iTunesLastSearchResult\', search, False, False)\n\n')
                        </Action>
                    </Macro>
                    <Macro Name="iTunes: Search (Nothing Found)">
                        <Event Name="Main.Nothing Found" />
                        <Action>
                            EventGhost.PythonScript(u'eg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Nothing Found", False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')')
                        </Action>
                    </Macro>
                    <Macro Name="iTunes: Search (Found)">
                        <Event Name="Main.iTunesSearchFound" />
                        <Action>
                            EventGhost.PythonScript(u"\na = eg.plugins.Webserver.GetValue(u'iTunesLastSearchResult', False)\neg.plugins.Webserver.SetValue(u'iTunesSearchResult', a, False, False)\neg.plugins.Webserver.BroadcastValue(u'iTunesSearchResult')")
                        </Action>
                        <Action>
                            EventGhost.PythonScript(u'\na = eg.plugins.Webserver.GetValue(u\'iTunesLastSearchResult\', False)\neg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "tesssssting", False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')')
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
            <Folder Name="Get/Set Variables">
                <Folder Name="Set Running Status">
                    <Macro Name="Webserver: Set Persistent value: iTunes_running True (Event)">
                        <Event Name="Main.iTunesRunning" />
                        <Action>
                            Webserver.SetPersistentValue(u'iTunes_running', u'True', False, False, 1)
                        </Action>
                        <Action>
                            Webserver.SetPersistentValue(u'mbrunning', u'True', False, False, 1)
                        </Action>
                        <Action>
                            Webserver.BroadcastValue(u'iTunes_running', None, u'', None)
                        </Action>
                        <Action>
                            Webserver.BroadcastValue(u'mbrunning', None, u'', None)
                        </Action>
                        <Action>
                            Webserver.SetPersistentValue(u'iTunesrun_icon', u'True', False, False, 1)
                        </Action>
                        <Action>
                            Webserver.BroadcastValue(u'iTunesrun_icon', None, u'', None)
                        </Action>
                    </Macro>
                    <Macro Name="Webserver: Set Persistent value: iTunes_running: False (Event)">
                        <Event Name="iTunes.Closing" />
                        <Event Name="Main.iTunesNotRunning" />
                        <Action>
                            Webserver.SetPersistentValue(u'iTunes_running', u'False', False, False, 1)
                        </Action>
                        <Action>
                            Webserver.BroadcastValue(u'iTunes_running', None, u'', None)
                        </Action>
                        <Action>
                            Webserver.SetPersistentValue(u'iTunesrun_icon', u'False', False, False, 1)
                        </Action>
                        <Action>
                            Webserver.BroadcastValue(u'iTunesrun_icon', None, u'', None)
                        </Action>
                        <Action>
                            Webserver.WsStopAllNamedPeriodicTasks(u'Slider')
                        </Action>
                        <Action>
                            Webserver.WsStopAllNamedPeriodicTasks(u'Time')
                        </Action>
                    </Macro>
                </Folder>
                <Macro Name="iTunes running, no playlist started">
                    <Event Name="Main.Nothing Playing" />
                    <Event Name="Main.iTunes Stopped" Enabled="False" />
                    <Action Name="Set coverart, eqimg, volume  to default">
                        EventGhost.PythonScript(u'volume = eg.plugins.iTunes.GetSoundVolume()\nvolume = str(volume)\neqimg = \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\'\n\ncover = \'&lt;a id="iTunes.reloadtracks" name="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" name="x" href="#iTunestracks"&gt;&lt;img style="text-align:center;" id= art" src="images/artSM/null.jpg" width="250" height="250" alt=""/&gt;&lt;/a&gt;\'\n\neg.plugins.Webserver.SetValue(u\'iTunescoverart\', cover, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunescoverart\')\neg.plugins.Webserver.SetValue(u\'iTunesartist\', "Nothing Playing...", False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesartist\')\neg.plugins.Webserver.SetValue(u\'iTunesleftRating\', eqimg, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesleftRating\')\neg.plugins.Webserver.SetValue(u\'iTunesplayicon\', "Paused", False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesplayicon\')\neg.plugins.Webserver.SetValue(u\'iTunesplaystate\', "Paused", False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesplaystate\')\neg.plugins.Webserver.SetValue(u\'iTunesVolumeLevelChanged\', volume, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesVolumeLevelChanged\')\neg.plugins.EventGhost.TriggerEvent(u\'get.tracks\', 5.3)\n')
                    </Action>
                    <Action>
                        Webserver.WsStopAllNamedPeriodicTasks(u'iTunesprogress')
                    </Action>
                </Macro>
                <Macro Name="Webserver: initialize on first load" id="176">
                    <Event Name="Main.reload.variables" />
                    <Event Name="iTunes.reloadtracks" />
                    <Event Name=".WsClientConnected" />
                    <Action Name="Initialiaze iTunes shuffle/repeat/mute toggles">
                        EventGhost.PythonScript(u't = eg.plugins.iTunes.GetPlaylistShuffle()\nh = eg.plugins.iTunes.GetPlaylistRepeat()\nu = eg.plugins.iTunes.GetMute()\nu = str(u)\n\nt = str(t)\nif h == 2:\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesrepeat\', u\'True\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesrepeat\')\n\nelse:\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesrepeat\', u\'False\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesrepeat\')\n\nif t == "True":\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesshuffle\', u\'True\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesshuffle\')\n\nelse:\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesshuffle\', u\'False\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesshuffle\')\n\nif u == "True":\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesmute\', u\'True\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesmute\')\n\nelse:\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesmute\', u\'False\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesmute\')')
                    </Action>
                    <Action Name="Initialize iTunes vol, coverart, artist, album, songtitle, rating, year, rating, freq, bitrate, type, timesplayed">
                        EventGhost.PythonScript(u'import datetime\nimport os, sys\nimport re\nimport os.path\neg.plugins.Webserver.SetValue(u\'itunesprogress\', u\'{eg.plugins.iTunes.GetPlayerPosition()}\', False, False, 1)\neg.plugins.Webserver.BroadcastValue(u\'itunesprogress\', None, u\'\', None)\n\nplaystate = eg.plugins.iTunes.GetPlayerState()\nif playstate == 1:\n    playstate = "Playing"\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\nelif playstate == 2:\n    playstate = "Paused"\n    eqimg = \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\'\nelif playstate == 0:\n    playstate = "Stopped"\n    eg.TriggerEvent ("iTunes Stopped")\n    sys.exit()\n\ngenre = eg.plugins.iTunes.GetGenre()\ntitle = eg.plugins.iTunes.GetTitle()\nartist = eg.plugins.iTunes.GetArtist()\nalbum = eg.plugins.iTunes.GetAlbum()\nyear = eg.plugins.iTunes.GetYear()\nyear = str(year)\nduration = eg.plugins.iTunes.GetDuration()\nduration = str(duration)\nrating = eg.plugins.iTunes.GetRating()\nrating = rating / 20\nrating = str(rating)\nvolume = eg.plugins.iTunes.GetSoundVolume()\nvolume = str(volume)\ntype = eg.plugins.iTunes.GetUniversal(19)\nsample = eg.plugins.iTunes.GetUniversal(20)\nbit = eg.plugins.iTunes.GetUniversal(21)\ntimesplayed = eg.plugins.iTunes.GetUniversal(17)\nif type == "MPEG audio file":\n    type = "Mp3"\nsample = sample * .001\nsample = str(sample)\nbit = str(bit)\ntimesplayed = str(timesplayed)\nx = os.path.exists(\'D:/WS - Demo/images/kodiart/\' + artist + \' - \' + album + \'.jpg\')\nx = str(x)\n\nif x != "False":\n    cover = \'&lt;a id="iTunes.reloadtracks" name="iTunes" title="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" href="#iTunestracks"&gt;&lt;img style="text-align:center;" id="art" src="images/kodiart/\' + artist + \' - \' + album + \'.jpg" width="250" height="250" alt=""/&gt;&lt;/a&gt;\'\nelse:\n    cover = \'&lt;a id="iTunes.reloadtracks" name="iTunes" title="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" href="#iTunestracks"&gt;&lt;img style="text-align:center;" id= art" src="images/artSM/null.jpg" width="250" height="250" alt=""/&gt;&lt;/a&gt;\'\n\neg.plugins.Webserver.SetValue(u\'iTunescoverart\', cover, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunescoverart\')\neg.plugins.Webserver.SetValue(u\'iTunesplaypause\', playstate, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesplaypause\')\neg.plugins.Webserver.SetValue(u\'iTunesplaystate\', playstate, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesplaystate\')   \neg.plugins.Webserver.SetValue(u\'iTunesartist\', artist, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesartist\')\neg.plugins.Webserver.SetValue(u\'iTunesalbum\', album, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesalbum\')\neg.plugins.Webserver.SetValue(u\'iTunestrackTitle\', title, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunestrackTitle\')\neg.plugins.Webserver.SetValue(u\'iTunesyear\', year, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesyear\')\neg.plugins.Webserver.SetValue(u\'iTunesrating\', rating, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesrating\')\neg.plugins.Webserver.SetValue(u\'iTunesleftRating\', eqimg, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesleftRating\')\neg.plugins.Webserver.SetValue(u\'itunesprogress_max\', duration, False, False)\neg.plugins.Webserver.SetValue(u\'iTunesVolumeLevelChanged\', volume, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesVolumeLevelChanged\')\neg.plugins.Webserver.SetValue(u\'itunestracksample\', sample, False, False)\neg.plugins.Webserver.BroadcastValue(u\'itunestracksample\')\neg.plugins.Webserver.SetValue(u\'itunestrackbitrate\', bit, False, False)\neg.plugins.Webserver.BroadcastValue(u\'itunestrackbitrate\')\neg.plugins.Webserver.SetValue(u\'itunestracktype\', type, False, False)\neg.plugins.Webserver.BroadcastValue(u\'itunestracktype\')\neg.plugins.Webserver.SetValue(u\'itunestrackplaycount\', timesplayed, False, False)\neg.plugins.Webserver.BroadcastValue(u\'itunestrackplaycount\')\neg.plugins.Webserver.BroadcastValue(u\'iTunesrun_icon\')\n\neg.plugins.EventGhost.TriggerEvent(u\'get.tracks\', 0.5)\n')
                    </Action>
                    <Action>
                        Webserver.GetValue(u'iTunesplaypause', False)
                    </Action>
                    <Action>
                        EventGhost.PythonCommand(u'eg.result == "Playing"')
                    </Action>
                    <Action>
                        EventGhost.NewJumpIf(XmlIdLink(214), 1, False)
                    </Action>
                    <Action>
                        Webserver.WsStopAllNamedPeriodicTasks(u'iTunesprogress')
                    </Action>
                    <Action>
                        Webserver.WsPeriodicallyBroadcastData(u'iTunesprogress', u'{"itunesprogress", str(eg.plugins.iTunes.GetPlayerPosition()+1) + \'||\' + str(eg.plugins.iTunes.GetPlayerPosition()+1) + \'||\' + str(eg.plugins.iTunes.GetDuration() - (eg.plugins.iTunes.GetPlayerPosition()+1))}', u'', True, 1.0)
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set track info on track change">
                    <Event Name="iTunes.TrackChanged" />
                    <Action Name="Initialize iTunes vol, coverart, artist, album, songtitle, rating, year, rating">
                        EventGhost.PythonScript(u'import datetime\nimport os, sys\nimport re\nimport os.path\npay = eg.event.payload\ngenre = pay["genre"]\ntitle = pay["name"]\nartist = pay["artist"]\nalbum = pay["album"]\nyear = pay["year"]\nyear = str(year)\nduration = pay["duration"]\nduration = str(duration)\nrating = (pay["rating"] / 20)\nrating = str(rating)\nvolume = eg.plugins.iTunes.GetSoundVolume()\nvolume = str(volume)\nplaystate = eg.plugins.iTunes.GetPlayerState()\n\nif playstate == 1:\n    playstate = "Playing"\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\nelse:\n    playstate = "Paused"\n    eqimg = \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\'\n\nx = os.path.exists(\'D:/WS - Demo/images/kodiart/\' + artist + \' - \' + album + \'.jpg\')\nx = str(x)\n\nif x != "False":\n    cover = \'&lt;a id="iTunes.reloadtracks" name="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" name="x" href="#iTunestracks"&gt;&lt;img style="text-align:center;" id="art" src="images/kodiart/\' + artist + \' - \' + album + \'.jpg" width="250" height="250" alt=""/&gt;&lt;/a&gt;\'\nelse:\n    cover = \'&lt;a id="iTunes.reloadtracks" name="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" name="x" href="#iTunestracks"&gt;&lt;img style="text-align:center;" id= art" src="images/M_icon.png" width="250" height="250" alt=""/&gt;&lt;/a&gt;\'\n\neg.plugins.Webserver.SetValue(u\'iTunescoverart\', cover, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunescoverart\')\neg.plugins.Webserver.SetValue(u\'iTunesartist\', artist, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesartist\')\neg.plugins.Webserver.SetValue(u\'iTunesalbum\', album, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesalbum\')\neg.plugins.Webserver.SetValue(u\'iTunestrackTitle\', title, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunestrackTitle\')\neg.plugins.Webserver.SetValue(u\'iTunesyear\', year, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesyear\')\neg.plugins.Webserver.SetValue(u\'iTunesrating\', rating, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesrating\')\neg.plugins.Webserver.SetValue(u\'iTunesleftRating\', eqimg, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesleftRating\')\neg.plugins.Webserver.SetValue(u\'iTunesplaypause\', playstate, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesplaypause\')\neg.plugins.Webserver.SetValue(u\'iTunesplaystate\', playstate, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesplaystate\')\neg.plugins.Webserver.SetValue(u\'itunesprogress_max\', duration, False, False)\neg.plugins.Webserver.BroadcastValue(u\'itunesprogress_max\')\neg.plugins.Webserver.SetValue(u\'iTunesVolumeLevelChanged\', volume, False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesVolumeLevelChanged\')\neg.plugins.Webserver.BroadcastValue(u\'iTunesrun_icon\')\n\n')
                    </Action>
                    <Action Name="Initialize iTunes freq, sample, bitrate, playcount">
                        EventGhost.PythonScript(u'type = eg.plugins.iTunes.GetUniversal(19)\nsample = eg.plugins.iTunes.GetUniversal(20)\nbit = str(eg.plugins.iTunes.GetUniversal(21))\ntimesplayed = str(eg.plugins.iTunes.GetUniversal(17))\nif type == "MPEG audio file":\n    type = "Mp3"\nsample = str(sample * .001)\n\neg.plugins.Webserver.SetValue(u\'itunestracksample\', sample, False, False)\neg.plugins.Webserver.BroadcastValue(u\'itunestracksample\')\neg.plugins.Webserver.SetValue(u\'itunestrackbitrate\', bit, False, False)\neg.plugins.Webserver.BroadcastValue(u\'itunestrackbitrate\')\neg.plugins.Webserver.SetValue(u\'itunestracktype\', type, False, False)\neg.plugins.Webserver.BroadcastValue(u\'itunestracktype\')\neg.plugins.Webserver.SetValue(u\'itunestrackplaycount\', timesplayed, False, False)\neg.plugins.Webserver.BroadcastValue(u\'itunestrackplaycount\')\n')
                    </Action>
                    <Action Name="Initialiaze iTunes shuffle/repeat/mute toggles">
                        EventGhost.PythonScript(u't = eg.plugins.iTunes.GetPlaylistShuffle()\nh = eg.plugins.iTunes.GetPlaylistRepeat()\nu = eg.plugins.iTunes.GetMute()\nu = str(u)\n\nt = str(t)\nif h == 2:\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesrepeat\', u\'True\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesrepeat\')\n\nelse:\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesrepeat\', u\'False\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesrepeat\')\n\nif t == "True":\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesshuffle\', u\'True\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesshuffle\')\n\nelse:\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesshuffle\', u\'False\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesshuffle\')\n\nif u == "True":\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesmute\', u\'True\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesmute\')\n\nelse:\n    eg.plugins.Webserver.SetPersistentValue(u\'iTunesmute\', u\'False\', False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesmute\')')
                    </Action>
                    <Action>
                        Webserver.WsStopAllNamedPeriodicTasks(u'iTunesprogress')
                    </Action>
                    <Action>
                        Webserver.WsPeriodicallyBroadcastData(u'iTunesprogress', u'{"itunesprogress", str(eg.plugins.iTunes.GetPlayerPosition()+1) + \'||\' + str(eg.plugins.iTunes.GetPlayerPosition()+1) + \'||\' + str(eg.plugins.iTunes.GetDuration() - (eg.plugins.iTunes.GetPlayerPosition()+1))}', u'', True, 1.0)
                    </Action>
                    <Action>
                        EventGhost.TriggerEvent(u'get.tracks', 0.5)
                    </Action>
                </Macro>
                <Macro Name="Webserver: Get/Set playlist">
                    <Event Name="Main.get.playlists" />
                    <Event Name=".iTunesPlaylists.reload" />
                    <Action Name="Get/Set Playlists Build list menus">
                        EventGhost.PythonScript(u'eg.plugins.Webserver.BroadcastValue(u\'itunesprogress_max\')\n#Filter out large/unecessary Playlists that choke the plugin\na = eg.plugins.iTunes.GetPlaylists()\nfor x in a:\n    playlists = (a)\nwhile "Library" in playlists: playlists.remove("Library")\nwhile "Music" in playlists: playlists.remove("Music")\nwhile "Movies" in playlists: playlists.remove("Movies")\nwhile "Home Videos" in playlists: playlists.remove("Home Videos")\nwhile "TV Shows" in playlists: playlists.remove("TV Shows")\nwhile "Podcasts" in playlists: playlists.remove("Podcasts")\nwhile "Books" in playlists: playlists.remove("Books")\nwhile "PDFs" in playlists: playlists.remove("PDFs")\nwhile "Audiobooks" in playlists: playlists.remove("Audiobooks")\nwhile "Genius" in playlists: playlists.remove("Genius")\nwhile "eventghostTemp" in playlists: playlists.remove("eventghostTemp")\n\n#Format/Send the playlists to webserver\nplist = {}\nfor x in playlists:\n    plist[x] = [x]\nplist = str(plist)\nplist = "    " + plist\neg.plugins.Webserver.WsBroadcastData(u\'iTunesPlaylists\', plist, u\'\', None, None)\n')
                    </Action>
                </Macro>
                <Macro Name="Webserver: Get/Set tracks">
                    <Event Name="Main.get.tracks" />
                    <Event Name=".UpdateiTunesTracks" />
                    <Action Name="Get/Set Tracks2">
                        EventGhost.PythonScript(u'import os\n\n#Parse/Format/Send current playlist tracksfull to webserver+++\ncurrentplaylist = eg.plugins.iTunes.GetPlaylistName()\n\nif currentplaylist != None:\n    if currentplaylist != "Music":\n        p = eg.plugins.iTunes.GetPlaylistTracks(currentplaylist)\n        tracks = []\n        for x in p:\n            artwork = "/images/kodiart/" + x[\'Artist\'] + " - " + x[\'Album\'] + ".jpg"\n            track = x[\'Name\']\n            artist = x[\'Artist\']\n            duration = x[\'Duration\']\n            number = x[\'TrackNumber\']\n            number = str(number)\n            rating = x[\'Rating\']\n            rating = rating / 20\n            rating = str(rating)\n            if len(number) &lt; 2:\n                number = "0" + number\n            m, s = divmod(duration, 60)\n            duration = "%2d:%02d" % (m, s)\n            duration = str(duration)\n            x = os.path.exists(\'D:/WS - Demo\' + artwork)\n            x = str(x)\n            if x == "False":\n                artwork = \'images/artSM/null.jpg\'\n            Payload = {}\n            Payload = [track + \'||\' + artwork + \'||\' + artist + \'||\' + duration + \'||\' + number + \'||\' + rating]\n            tracks.append(Payload)\n    tracks = str(tracks)\n    tracksfull = "    " + tracks\n    eg.plugins.Webserver.WsBroadcastData(u\'iTunesTracks\', tracksfull, u\'\', None, None)\nif currentplaylist == "eventghostTemp":\n    currentplaylist = "Matched Search"\nelif currentplaylist == "None":\n    currentplaylist = "No Playlist set"\neg.plugins.Webserver.SetValue(u\'itunescurrentplaylist\', currentplaylist, False, False)\neg.plugins.Webserver.BroadcastValue(u\'itunescurrentplaylist\')\neg.plugins.EventGhost.TriggerEvent(u\'get.playlists\', 1.5)')
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set playstate iTunes stopped playback">
                    <Event Name="iTunes.Stopped" />
                    <Action>
                        Webserver.SetValue(u'playstate', u'Paused', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'playstate', None, u'', None)
                    </Action>
                    <Action>
                        Webserver.SetValue(u'iTunesplaypause', u'Paused', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'iTunesplaypause', None, u'', None)
                    </Action>
                    <Action>
                        Webserver.WsStopAllNamedPeriodicTasks(u'iTunesprogress')
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set temporary value: iTunes Volume Slider">
                    <Event Name="iTunes.VolumeChanged" />
                    <Action>
                        Webserver.SetValue(u'iTunesVolumeLevelChanged', u'{eg.event.payload}', False, False, 1)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'iTunesVolumeLevelChanged', None, u'', None)
                    </Action>
                </Macro>
                <Macro Name="Null" id="214" />
            </Folder>
        </Folder>
        <Folder Name="Kodi" Expanded="True">
            <Macro Name='Set KodiArt Directory (EDIT THIS THEN RUN FIRST: Set to your "HTML/images/kodiart" folder)'>
                <Action>
                    Webserver.SetPersistentValue(u'kodiartdirectory', u'D://WS - Demo/images/kodiart/', True, False, 1)
                </Action>
                <Action>
                    Webserver.SetPersistentValue(u'kodiroom', u'Basement', False, False, 1)
                </Action>
                <Action>
                    Webserver.SetPersistentValue(u'kodi_playlistedit', u'False', False, False, 1)
                </Action>
            </Macro>
            <Macro Name="Kodi Get Progress()">
                <Event Name="Main.OnInit" />
                <Action Name="Kodi Get Progress Function():">
                    EventGhost.PythonScript(u'import urllib2\n\ndef getkodi_progress():\n\n    try:\n        p = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n    except urllib2.HTTPError, e:\n        print e.code\n        eg.Triggerevent("KodiClosed")\n    except urllib2.URLError, e:\n        print e.args\n        eg.TriggerEvent("KodiClosed")\n\n    try:\n        id = str(p[0][\'playerid\'])\n        type = p[0][\'type\']\n    except IndexError:\n        id = "none"\n        print "id = None"\n    if id != "none":\n    \n        p = eg.plugins.XBMC2.JSONRPC(u\'Player.GetProperties\', u\'{"playerid": \' + id + \', "properties": ["repeat", "shuffled", "percentage", "position", "time", "totaltime", "type", "playlistid"]}\', False, True)\n        progress = p[\'percentage\']\n\n        # Math to get remaining Minutes/Seconds\n        remainsec =  (((p[\'totaltime\'][\'minutes\'] * 60) + p[\'totaltime\'][\'seconds\']) - ((p[\'time\'][\'minutes\'] * 60) + p[\'time\'][\'seconds\']))\n        startsec = ((p[\'time\'][\'minutes\'] * 60) + p[\'time\'][\'seconds\'])\n    \n        # Convert Seconds to Minutes\n        m, s = divmod(startsec, 60)\n        h, m = divmod(m, 60)\n        start = "%d:%02d" % (m, s)\n\n        m, s = divmod(remainsec, 60)\n        h, m = divmod(m, 60)\n        end = "%d:%02d" % (m, s)\n        end = "-" + str(end)\n        \n        return {"Progress": progress, "timeElapsed": start, "timeRemain": end}\n    else:\n        return "Nothing Playing"\n    \neg.globals.getkodi_progress = getkodi_progress')
                </Action>
            </Macro>
            <Folder Name="Enable exclusive Room">
                <Macro Name="Enable exclusive: Basement">
                    <Event Name="Main.kodi.basement" />
                    <Action>
                        EventGhost.EnableExclusive(XmlIdLink(233))
                    </Action>
                    <Action>
                        EventGhost.NewJumpIf(XmlIdLink(634), 2, False)
                    </Action>
                </Macro>
                <Macro Name="Enable exclusive: Bedroom">
                    <Event Name="Main.kodi.bedroom" />
                    <Action>
                        EventGhost.EnableExclusive(XmlIdLink(710))
                    </Action>
                    <Action>
                        EventGhost.NewJumpIf(XmlIdLink(1104), 2, False)
                    </Action>
                </Macro>
            </Folder>
            <Folder Name="Rooms">
                <Folder Name="Basement (XBMC2)" id="233">
                    <Macro Name="Webserver: Set temporary value: kodiplaypause:">
                        <Event Name="Main.OnInit" />
                        <Action>
                            EventGhost.PythonScript(u'p = eg.plugins.XBMC2.JSONRPC(u\'Player.GetProperties\', u\'{"playerid": 0, "properties": ["speed", "audiostreams"]}\', True, True)\nspeed = str(p[\'speed\'])\nif speed != "0":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', u\'Playing\', False, False, 1)\nelse:\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', u\'Paused\', False, False, 1)')
                        </Action>
                    </Macro>
                    <Folder Name="Actions">
                        <Folder Name="System (Popup)">
                            <Macro Name="Switch Kodi Device Control (Swith Room)">
                                <Event Name="input.Kodi_Room" />
                                <Action>
                                    EventGhost.PythonScript(u'p = eg.event.payload\nif p == "kodi.Basement":\n    eg.plugins.EventGhost.TriggerEvent(u\'kodi.basement\', 0.0)\n    eg.plugins.Webserver.SetPersistentValue(u\'kodiroom\', "Basement", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiroom\')\nif p == "kodi.Bedroom":\n    eg.plugins.EventGhost.TriggerEvent(u\'kodi.bedroom\', 0.0)\n    eg.plugins.Webserver.SetPersistentValue(u\'kodiroom\', "Bedroom", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiroom\')')
                                </Action>
                            </Macro>
                            <Macro Name="Kodi: Start">
                                <Event Name=".start_kodi" />
                                <Action>
                                    System.Execute(u'C:\\Program Files (x86)\\Kodi\\Kodi.exe', u'', 0, False, 2, u'', False, True, u'', False, False, False, True)
                                </Action>
                                <Action>
                                    Webserver.SetPersistentValue(u'kodirun_icon', u'True', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodirun_icon', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.Wait(0.5)
                                </Action>
                                <Action>
                                    Window.FindWindow(u'Kodi.exe', None, None, None, None, None, False, 0.0, 0)
                                </Action>
                                <Action>
                                    Window.BringToFront()
                                </Action>
                            </Macro>
                            <Macro Name="Kodi: Quit">
                                <Event Name=".close_kodi" />
                                <Action>
                                    XBMC2.Quit()
                                </Action>
                                <Action>
                                    System.Command(u'taskkill /IM Kodi.exe /F', False, False, u'', True, False, False, True, False)
                                </Action>
                                <Action>
                                    Webserver.SetPersistentValue(u'kodirun_icon', u'False', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodirun_icon', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(649), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: UpdateLibrary: Audio">
                                <Event Name=".Update_kodiAudio" />
                                <Action>
                                    XBMC2.UpdateLibrary(u'Audio', u'')
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: UpdateLibrary: Video">
                                <Event Name=".Update_kodiVideo" />
                                <Action>
                                    XBMC2.UpdateLibrary(u'Video', u'')
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Set Video Resolution">
                                <Event Name="input.Kodi_VideoResolution" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', True)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action Enabled="False">
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action>
                                    EventGhost.PythonScript(u'payload = eg.event.payload\nif payload == "kodi.Resolution.TV":\n    eg.plugins.Window.SendKeys(u\'{WIN+P}\', False, 2)\n    eg.plugins.Window.SendKeys(u\'{Right}\', False, 2)\n    eg.plugins.Window.SendKeys(u\'{Enter}\', False, 2)\nif payload == "kodi.Resolution.Monitor":\n    eg.plugins.Window.SendKeys(u\'{WIN+P}\', False, 2)\n    eg.plugins.Window.SendKeys(u\'{Left}\', False, 2)\n    eg.plugins.Window.SendKeys(u\'{Enter}\', False, 2)')
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Set Audio Output">
                                <Event Name="input.Kodi_AudioSource" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', True)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action>
                                    EventGhost.PythonScript(u'payload = eg.event.payload\nif payload == "kodi.Audio.HDMI":\n    eg.plugins.XBMC2.JSONRPC(u\'Settings.SetSettingValue\', u\'{"setting":\\\'audiooutput.audiodevice\\\', \\\'value\\\':\\\'WASAPI:{6F356A63-8017-4A66-989D-4B81965D46BC}\\\'}\', False, True)\nif payload == "kodi.Audio.SPDIF":\n    eg.plugins.XBMC2.JSONRPC(u\'Settings.SetSettingValue\', u\'{"setting":\\\'audiooutput.audiodevice\\\', \\\'value\\\':\\\'DIRECTSOUND:{7FB3A4CE-1F8C-46F4-87A4-B7D7652890FA}\\\'}\', False, True)')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="D-Pad">
                            <Macro Name="XBMC2: Left">
                                <Event Name="kodi.left" />
                                <Action>
                                    XBMC2.RemoteLeft()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Right">
                                <Event Name="kodi.right" />
                                <Action>
                                    XBMC2.RemoteRight()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Up">
                                <Event Name="kodi.up" />
                                <Action>
                                    XBMC2.RemoteUp()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Down">
                                <Event Name="kodi.down" />
                                <Action>
                                    XBMC2.RemoteDown()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Select">
                                <Event Name="kodi.enter" />
                                <Action>
                                    XBMC2.RemoteSelect()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Back">
                                <Event Name="kodi.back" />
                                <Action>
                                    XBMC2.RemoteBack()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Menu">
                                <Event Name="kodi.menu" />
                                <Action>
                                    XBMC2.RemoteMenu()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Display">
                                <Event Name="kodi.title" />
                                <Action>
                                    XBMC2.RemoteDisplay()
                                </Action>
                            </Macro>
                            <Macro Name="Toggle fullscreen">
                                <Event Name="kodi.fullscreentoggle" />
                                <Action>
                                    EventGhost.PythonScript(u'state = eg.plugins.XBMC2.JSONRPC(u\'Settings.GetSettingValue\', u\'{"setting":\\\'videoscreen.screen\\\'}\', False, True)\nif state[\'value\'] == -1:\n    eg.plugins.XBMC2.JSONRPC(u\'Settings.SetSettingValue\', u\'{"setting":\\\'videoscreen.screen\\\', \\\'value\\\':0}\', True, True)\nif state[\'value\'] == 0:\n    eg.plugins.XBMC2.JSONRPC(u\'Settings.SetSettingValue\', u\'{"setting":\\\'videoscreen.screen\\\', \\\'value\\\':-1}\', True, True)')
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: PageUp">
                                <Event Name="kodi.pageup" />
                                <Action>
                                    XBMC2.PageUp()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: PageDown">
                                <Event Name="kodi.pagedown" />
                                <Action>
                                    XBMC2.PageDown()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Music">
                                <Event Name="kodi.musicpage" />
                                <Action>
                                    XBMC2.Music()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Show TV Shows Screen">
                                <Event Name="kodi.tvshowspage" />
                                <Action>
                                    XBMC2.MyTVShows()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Favourites">
                                <Event Name="kodi.favorites" />
                                <Action>
                                    XBMC2.Favourites()
                                </Action>
                                <Action Enabled="False">
                                    XBMC2.JSONRPC(u'Addons.ExecuteAddon', u'{ "addonid": "script.hdhomerun.view"}', True, True)
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Show Movies Screen">
                                <Event Name="kodi.moviespage" />
                                <Action>
                                    XBMC2.MyMovies()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Show Home Screen">
                                <Event Name="kodi.home" />
                                <Action>
                                    XBMC2.Home()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Show Systemsettings Screen">
                                <Event Name="kodi.settings" />
                                <Action>
                                    XBMC2.Systemsettings()
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Playback">
                            <Macro Name="XBMC2: Rewind">
                                <Event Name="kodi.kodirwnd" />
                                <Action>
                                    XBMC2.Rewind()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: SkipPrevious">
                                <Event Name="kodi.kodiprev" />
                                <Action>
                                    XBMC2.SkipPrevious()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Play/Pause">
                                <Event Name="kodi.kodiplaypaused" />
                                <Action Name="Get/Set Play/Pause">
                                    EventGhost.PythonScript(u'state = eg.plugins.Webserver.GetValue(u\'kodiplaypause\', False)\nif state == None:\n    state = "Playing"\nif state == "Playing":\n    eg.plugins.XBMC2.Pause()\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Paused", False, False)\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', u\'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', u\'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\nelif state == "Paused":\n    eg.plugins.XBMC2.Play()\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', u\'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', u\'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\n\nelif state == "Stopped":\n    eg.plugins.XBMC2.Play()\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', u\'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', u\'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\neg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\neg.plugins.Webserver.BroadcastValue(u\'kodileftRating\', None, u\'\', None)\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoleftRating\', None, u\'\', None)')
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Stop">
                                <Event Name="kodi.stop" />
                                <Action>
                                    XBMC2.RemoteStop()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: SkipNext">
                                <Event Name="kodi.kodinext" />
                                <Action>
                                    XBMC2.SkipNext()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: FastForward">
                                <Event Name="kodi.kodiffwd" />
                                <Action>
                                    XBMC2.FastForward()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Mute">
                                <Event Name="kodi.kodimuted" />
                                <Action>
                                    XBMC2.Mute()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Repeat">
                                <Event Name="kodi.kodirepeated" />
                                <Action>
                                    XBMC2.Repeat()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Shuffle">
                                <Event Name="kodi.kodishuffled" />
                                <Action>
                                    XBMC2.Random()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Party Mode">
                                <Event Name="kodi.partymode" />
                                <Action>
                                    XBMC2.PartyMode()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Set Volume">
                                <Event Name="Volume.kodiVolumeLevelChanged" />
                                <Action Name="Get/Set current playback info">
                                    EventGhost.PythonScript(u"payload = str(eg.event.payload)\neg.plugins.XBMC2.JSONRPC(u'Application.SetVolume', '['  + payload + ']', False, True)\n")
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Set progress">
                                <Event Name="kodi.kodiprogress" />
                                <Event Name="kodi.kodiVideoprogress" />
                                <Action Name="Set progress">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\npayload = str(eg.event.payload)\ntry:\n    id = str(p[0][\'playerid\'])\n    type = p[0][\'type\']\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\neg.plugins.XBMC2.JSONRPC(u\'Player.Seek\', u\'{"playerid": \' + id + \', "value":{ "percentage":\' + payload + \'}}\', False, True)')
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Set rating">
                                <Event Name="kodi.star*" />
                                <Event Name="kodi.star5" />
                                <Event Name="kodi.star4" />
                                <Event Name="kodi.star3" />
                                <Event Name="kodi.star2" />
                                <Event Name="kodi.star1" />
                                <Action Name="Get/Set rating">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\nsuffix = str(eg.event.suffix)\nsuffix = suffix.split(\'star\')\nsuffix = suffix[1]\n\ntry:\n    id = p[0][\'playerid\']\n    id = str(id)\n    type = p[0][\'type\']\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\nif id != "none":\n    current = eg.plugins.XBMC2.JSONRPC(u\'Player.GetItem\', u\'{ "properties": ["title", "album", "artist", "duration", "year", "rating", "playcount", "genre", "thumbnail", "file", "fanart", "streamdetails"], "playerid":\' + id + \'}\', False, True)\n    id = str(current[\'item\'][\'id\'])\n    type = str(current[\'item\'][\'type\'])\n    if type == "song":\n        eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.SetSongDetails\', u\'{"songid":\' + id + \', "rating":\' + suffix + \'}\', True, True)\n        eg.plugins.Webserver.SetValue(u\'kodirating\', suffix, False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'kodirating\')\n    if type == "episode":\n        eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.SetEpisodeDetails\', u\'{"episodeid":\' + id + \', "rating":\' + suffix + \'}\', True, True)\n        eg.plugins.Webserver.SetValue(u\'kodiVideorating\', suffix, False, False)\n        suffix = str(int(suffix) * 2)\n        eg.plugins.Webserver.BroadcastValue(u\'kodiVideorating\')\n    if type == "movie":\n        eg.plugins.Webserver.SetValue(u\'kodiVideorating\', suffix, False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'kodiVideorating\')\n        suffix = str(int(suffix) * 2)\n        eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.SetMovieDetails\', u\'{"movieid":\' + id + \', "rating":\' + suffix + \'}\', True, True)\n    \n    eg.plugins.Webserver.SetValue(u\'kodirating\', suffix, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodirating\')\n')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Play File">
                            <Macro Name="Play Movie">
                                <Event Name="kodi.Movies" />
                                <Action Name="Play Movie" Enabled="False">
                                    EventGhost.PythonScript(u'payload = eg.event.payload\neg.plugins.XBMC2.JSONRPC(u\'Player.Open\', u\'{"item":{"movieid":\' + payload + \'}}\', False, True)')
                                </Action>
                                <Action Name="Resume Movie">
                                    EventGhost.PythonScript(u'payload = eg.event.payload\neg.plugins.XBMC2.JSONRPC(u\'Player.Open\', u\'{"item":{"movieid":\' + payload + \'}, "options":{"resume":True}}\', False, True)')
                                </Action>
                            </Macro>
                            <Macro Name="Play TV Episode">
                                <Event Name="kodi.Episode" />
                                <Action Name="Playback episode (single)" Enabled="False">
                                    EventGhost.PythonScript(u'payload = str(eg.event.payload)\neg.plugins.XBMC2.JSONRPC(u\'Player.Open\', u\'{"item":{"episodeid":\' + payload + \'}, "options":{"resume":True}}\', False, True)')
                                </Action>
                                <Action Name="Playback episode (&amp; all subsequent episodes in the Season)">
                                    EventGhost.PythonScript(u'payload = str(eg.event.payload)\n\neg.plugins.XBMC2.JSONRPC(u\'Playlist.Clear\', u\'{"playlistid":1}\', False, True)\neg.plugins.XBMC2.JSONRPC(u\'Player.Open\', u\'{"item":{"episodeid":\' + payload + \'}, "options":{"resume":True}}\', False, True)\n\n\nx = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetEpisodeDetails\', u\'{"episodeid":\' + payload + \', "properties": ["season", "episode", "tvshowid"]}\', False, True)\n\nepisodenum = str(x[\'episodedetails\'][\'episode\'])\nepisodeid  = str(x[\'episodedetails\'][\'episodeid\'])\nseasonnum = str(x[\'episodedetails\'][\'season\'])\nshowid = str(x[\'episodedetails\'][\'tvshowid\'])\n\nu = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetEpisodes\', u\'{ "tvshowid": \' + showid + \', "season": \' + seasonnum + \', "properties": ["episode"]}\', False, True)\nepisodenum = int(episodenum)\nfor item in u[\'episodes\']:\n    episodeplaylistnum = int(item[\'episode\'])\n    episodeplaylistid = int(item[\'episodeid\'])\n    if episodeplaylistnum &gt; episodenum:\n        eg.plugins.XBMC2.JSONRPC(u\'Playlist.Add\', u\'{"playlistid":1,"item":{"episodeid":\' + str(episodeplaylistid) + \'}}\', False, True)\n')
                                </Action>
                            </Macro>
                            <Macro Name="Tune Channel">
                                <Event Name="kodi.Channel" />
                                <Action Name="Play Album">
                                    EventGhost.PythonScript(u'channel = eg.event.payload\neg.plugins.XBMC2.JSONRPC(u\'Player.Open\', u\'{"item":{"channelid":\' + channel + \'}}\', True, True)\neg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n\n')
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodichannelchanged', 3.0)
                                </Action>
                            </Macro>
                            <Macro Name="Start Playlist">
                                <Event Name="kodi.Playlist" />
                                <Action Name="Start Playlist">
                                    EventGhost.PythonScript(u'playlist = str(eg.event.payload)\neg.plugins.XBMC2.JSONRPC(u\'Player.Open\', u\'{"item":{"file":"\' + playlist + \'"}}\', True, True)')
                                </Action>
                            </Macro>
                            <Macro Name="Play Album">
                                <Event Name="kodi.Album" />
                                <Action Name="Play Album">
                                    EventGhost.PythonScript(u'album = eg.event.payload\neg.plugins.XBMC2.JSONRPC(u\'Player.Open\', u\'{"item":{"albumid":\' + album + \'}}\', True, True)\neg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n\n')
                                </Action>
                            </Macro>
                            <Macro Name="Play Song in Current Playlist" Expanded="True">
                                <Event Name="kodi.playlisttrack" />
                                <Action Name="GoTo Playlist #">
                                    EventGhost.PythonScript(u'player = str(eg.plugins.Webserver.GetPersistentValue(u\'kodiactiveplayer\', False))\nprint player\ntrack = eg.event.payload\ntrack = int(track) - 1\ntrack = str(track)\n\neg.plugins.XBMC2.JSONRPC(u\'Player.GoTo\', u\'{"playerid":\' + player + \', "to": \' + track + \'}\', False, True)')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Playlist manipulation Audio" id="396">
                            <Macro Name="Add selected songs to Current Playlist">
                                <Event Name="kodicheckedsongs.addtoplaylist" />
                                <Action Name="add songs to current playlist">
                                    EventGhost.PythonScript(u'pay = eg.event.payload\npayload = pay.split(\',\')\ncurrent = eg.plugins.XBMC2.JSONRPC(u\'Playlist.GetItems\', u\'{"playlistid":0, "properties": ["title"]}\', False, True)\neg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Songs Added to the Playlist", False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\nsongs = []\nfor song in payload[:-1]:\n    song = str(song)\n    eg.plugins.XBMC2.JSONRPC(u\'Playlist.Add\', u\'{"playlistid":0,"item":{"songid":\' + song + \'}}\', False, True)\nelse:\n    x = ""\n    ')
                                </Action>
                            </Macro>
                            <Macro Name="Create new playlist from selected songs">
                                <Event Name="kodicheckedsongsnew.addtoplaylist" />
                                <Action Name="Create new playlist">
                                    EventGhost.PythonScript(u'pay = eg.event.payload\npayload = pay.split(\',\')\neg.plugins.XBMC2.JSONRPC(u\'Playlist.Clear\', u\'{"playlistid":0}\', False, True)\neg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Songs Added to a new playlist", False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\nsongs = []\nfor song in payload[:-1]:\n    song = str(song)\n    eg.plugins.XBMC2.JSONRPC(u\'Playlist.Add\', u\'{"playlistid":0,"item":{"songid":\' + song + \'}}\', False, True)\nelse:\n    x = ""')
                                </Action>
                            </Macro>
                            <Macro Name="Delete Playlist item">
                                <Event Name="kodidelete.*" />
                                <Action Name="Delete playlist item">
                                    EventGhost.PythonScript(u'if eg.event.payload == "undefined":\n    payload = "0"\nelse:\n    payload = str(int(eg.event.payload) - 1)\neg.plugins.XBMC2.JSONRPC(u\'Playlist.Remove\', u\'{"playlistid":0, "position":\' + payload + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(587), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Move Playlist item Up">
                                <Event Name="kodimoveup.*" />
                                <Action Name="Move playlist item Up">
                                    EventGhost.PythonScript(u'pos1 = str(int(eg.event.payload) - 1)\npos2 = str(int(eg.event.payload) - 2)\nprint pos1\nprint pos2\neg.plugins.XBMC2.JSONRPC(u\'Playlist.Swap\', u\'{"playlistid":0, "position1":\' + pos1 + \', "position2":\' + pos2 + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(587), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Move Playlist item Down">
                                <Event Name="kodimovedown.*" />
                                <Action Name="Move playlist item Down">
                                    EventGhost.PythonScript(u'if eg.event.payload == "undefined":\n    eg.event.payload = 0\npos1 = str(int(eg.event.payload) - 1)\npos2 = str(eg.event.payload)\nprint pos1\nprint pos2\neg.plugins.XBMC2.JSONRPC(u\'Playlist.Swap\', u\'{"playlistid":0, "position1":\' + pos1 + \', "position2":\' + pos2 + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(587), 2, False)
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Playlist manipulation Video" id="415" Enabled="False">
                            <Macro Name="Delete Playlist item">
                                <Event Name="kodidelete.*" />
                                <Action Name="Delete playlist item">
                                    EventGhost.PythonScript(u'if eg.event.payload == "undefined":\n    payload = "0"\nelse:\n    payload = str(int(eg.event.payload) - 1)\neg.plugins.XBMC2.JSONRPC(u\'Playlist.Remove\', u\'{"playlistid":1, "position":\' + payload + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(595), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Move Playlist item Up">
                                <Event Name="kodimoveup.*" />
                                <Action Name="Move playlist item Up">
                                    EventGhost.PythonScript(u'pos1 = str(int(eg.event.payload) - 1)\npos2 = str(int(eg.event.payload) - 2)\nprint pos1\nprint pos2\neg.plugins.XBMC2.JSONRPC(u\'Playlist.Swap\', u\'{"playlistid":1, "position1":\' + pos1 + \', "position2":\' + pos2 + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(595), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Move Playlist item Down">
                                <Event Name="kodimovedown.*" />
                                <Action Name="Move playlist item Down">
                                    EventGhost.PythonScript(u'if eg.event.payload == "undefined":\n    eg.event.payload = 0\npos1 = str(int(eg.event.payload) - 1)\npos2 = str(eg.event.payload)\nprint pos1\nprint pos2\neg.plugins.XBMC2.JSONRPC(u\'Playlist.Swap\', u\'{"playlistid":1, "position1":\' + pos1 + \', "position2":\' + pos2 + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(595), 2, False)
                                </Action>
                            </Macro>
                        </Folder>
                    </Folder>
                    <Folder Name="Get/Set Variables">
                        <Folder Name="Plugin Events">
                            <Macro Name="Kodi System (start)">
                                <Event Name="Process.Created.Kodi" Enabled="False" />
                                <Event Name="XBMC2.System.OnStart" />
                                <Action>
                                    Webserver.SetPersistentValue(u'kodirun_icon', u'True', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiartist4', u'No Active Playback', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodicoverart4', u' &lt;a id="kodi.reloadtracks" name="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" href="#kodiplaylist"&gt;&lt;img style="text-align:center;" id="kodiart" src="/images/m_icon.png" width="250" height="250" alt=""/&gt;&lt;/a&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodirun_icon, kodiroom, kodiartist4, kodicoverart4', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(634), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Kodi System Change (quit)" id="438">
                                <Event Name="Process.Destroyed.Kodi" Enabled="False" />
                                <Event Name="XBMC2.System.OnQuit" />
                                <Action>
                                    Webserver.SetPersistentValue(u'kodirun_icon', u'False', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiartist', u'Kodi is Closed', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiartist2', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiartist4', u'Kodi is Closed', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodialbum', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiyear', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'koditrackTitle', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiplaypause', u'Paused', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiprogress', u'0', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiprogress_remain', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiprogress_start', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'koditrackplaycount', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodicoverart', u' &lt;a id="kodi.reloadtracks" name="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" href="#kodiplaylist"&gt;&lt;img style="text-align:center;" id="kodiart" src="/images/Tracks_icon.png" width="250" height="250" alt=""/&gt;&lt;/a&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodicoverart4', u' &lt;a id="kodi.reloadtracks" name="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" href="#kodiplaylist"&gt;&lt;img style="text-align:center;" id="kodiart" src="/images/Tracks_icon.png" width="250" height="250" alt=""/&gt;&lt;/a&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodileftRating', u'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiartist, kodialbum, kodiplaypause, koditrackTitle, kodirun_icon, koditrackplaycount, kodiprogress, kodiprogress_start, kodiprogress_remain, kodiyear, kodileftRating, kodicoverart, koditracktype, kodiroom', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiartist4, kodiartist2, kodicoverart4', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StopKodiProgress', 0.0)
                                </Action>
                            </Macro>
                            <Macro Name="Kodi Application Change (volume/mute)">
                                <Event Name="XBMC2.Application.OnVolumeChanged" />
                                <Action>
                                    Webserver.SetValue(u'kodiVolumeLevelChanged', u"{str(int(eg.event.payload['volume']))}", False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodimute', u"{str(eg.event.payload['muted'])}", False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiVolumeLevelChanged', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodimute', None, u'', None)
                                </Action>
                            </Macro>
                            <Macro Name="Kodi Property Change (repeat/shuffle/partymode)">
                                <Event Name="XBMC2.Player.OnPropertyChanged" />
                                <Action>
                                    EventGhost.PythonScript(u'p = eg.event.payload[\'property\']\nkey = p.keys()[0]\nvalue = str(p.values()[0])\n\nif key == "shuffled":\n    key = "shuffle"\nname = "kodi" + key\neg.plugins.Webserver.SetValue(name, value, False, False, 1)\neg.plugins.Webserver.BroadcastValue(name, None, u\'\', None)\n')
                                </Action>
                            </Macro>
                            <Macro Name='Kodi Player Change ("play" song)'>
                                <Event Name="XBMC2.Player.OnPlay.song" />
                                <Action>
                                    Webserver.SetValue(u'kodiplaypause', u'Playing', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetPersistentValue(u'kodiactiveplayer', u'0', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiplaypause, kodiactiveplayer', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StartKodiAudioProgress', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(602), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name='Kodi Player Change ("play" movie/tvepisode)'>
                                <Event Name="XBMC2.Player.OnPlay.episode" />
                                <Event Name="XBMC2.Player.OnPlay.movie" />
                                <Event Name="XBMC2.Player.OnPlay.channel" />
                                <Action>
                                    Webserver.SetValue(u'kodiplaypause', u'Playing', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetPersistentValue(u'kodiactiveplayer', u'1', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiplaypause, kodiactiveplayer', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StartKodiVideoProgress', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(616), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Kodi Player Change (Seek Position)">
                                <Event Name="XBMC2.Player.OnSeek.song" />
                            </Macro>
                            <Macro Name="Kodi Player Change (paused)">
                                <Event Name="XBMC2.Player.OnPause.song" />
                                <Event Name="XBMC2.Player.OnPause.movie" />
                                <Event Name="XBMC2.Player.OnPause.episode" />
                                <Action>
                                    Webserver.SetValue(u'kodileftRating', u'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiVideoleftRating', u'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiplaypause', u'Paused', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiplaypause', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodileftRating', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiVideoleftRating', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StopKodiProgress', 0.0)
                                </Action>
                            </Macro>
                            <Macro Name="Kodi Player Change (stopped)">
                                <Event Name="XBMC2.Player.OnStop.song" />
                                <Event Name="XBMC2.Player.OnStop.episode" />
                                <Event Name="XBMC2.Player.OnStop.movie" />
                                <Event Name="XBMC2.Player.OnStop.channel" />
                                <Action>
                                    EventGhost.Wait(1.0)
                                </Action>
                                <Action Name="Get Playstate">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = str(p[0][\'playerid\'])\n    type = p[0][\'type\']\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\ntry:\n    u = eg.plugins.XBMC2.JSONRPC(u\'Player.GetProperties\', u\'{"playerid":\' + id + \', "properties": [\\\'speed\\\']}\', False, True)\n    speed = str(u[\'speed\'])\nexcept ValueError:\n    speed = "0"\nif speed != "0":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', u\'Playing\', False, False, 1)\nelse:\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', u\'Paused\', False, False, 1)')
                                </Action>
                                <Action>
                                    Webserver.GetValue(u'kodiplaypause', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "Playing"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiplaypause', u'Paused', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player1holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player2holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player3holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player4holder', u'show', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodileftRating', u'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u' kodiplaypause, kodileftRating, kodi_player1holder, kodi_player2holder, kodi_player3holder, kodi_player4holder', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StopKodiProgress', 0.0)
                                </Action>
                            </Macro>
                            <Macro Name="Start playlist when new songs added">
                                <Event Name="XBMC2.Playlist.OnAdd.song" />
                                <Action Name="Start playlist">
                                    EventGhost.PythonScript(u'size = eg.event.payload[\'position\']\nif size == 0:\n    eg.plugins.XBMC2.JSONRPC(u\'Player.Open\', u\'{"item":{"playlistid":0}}\', False, True)')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Build Menus' (Broadcast Data) New http and cache">
                            <Macro Name="Get/Set Genres">
                                <Event Name="kodi.updatekodigenre" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get genres">
                                    EventGhost.PythonScript(u'getcount = "True"\nx = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetGenres\', u\'{"properties": ["thumbnail"]}\', False, True)\ngenres = []\nfor item in x[\'genres\']:\n    genre = item[\'label\']\n    if getcount == "True":\n        x = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetArtists\', u\'{ "filter": {"field": "genre", "operator": "is", "value": "\' + genre + \'"}, "limits": { "start" : 0, "end": 1000 }, "sort": { "order": "ascending", "method": "track" } }\', False, True)\n        total = str(x[\'limits\'][\'total\'])\n    else:\n        total = ""\n    thumbnail = item[\'thumbnail\']\n    Payload = {}\n    Payload = [genre + \'||\' + total + \'||\' + \'\' + \'||\' + \'\' + \'||\' + \'\' + \'||\' + \'\']\n    genres.append(Payload)\n\ngenres= str(genres)\ngenresfull = "    " + genres\neg.plugins.Webserver.WsBroadcastData(u\'kodigenres\', genresfull, u\'\', None, None)\neg.plugins.Webserver.SetValue(u\'kodiplaylistli\', "Playing", False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodiplaylistli\')')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Artist by Genre">
                                <Event Name="kodi.Genres" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', True)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get artist filtered by genre">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaultartistthumb\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\ngetcount = "False"\ngenre = eg.event.payload\nx = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetArtists\', u\'{ "filter": {"field": "genre", "operator": "is", "value": "\' + genre + \'"}, "limits": { "start" : 0, "end": 500 }, "properties": [ "thumbnail", "fanart", "born", "formed", "died", "disbanded", "yearsactive", "mood", "style", "genre"], "sort": { "order": "ascending", "method": "artist" }  }\', False, True)\nartists = []\nfor item in x[\'artists\']:\n    artist = item[\'label\']\n    if getcount == "True":\n        x = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetAlbums\', u\'{ "filter": {"field": "artist", "operator": "is", "value": "\' + artist + \'"}, "limits": { "start" : 0, "end": 200 }, "properties": ["title"], "sort": { "order": "ascending", "method": "track" } }\', False, True)\n        total = str(x[\'limits\'][\'total\'])\n    else:\n        total = "0"\n    artistid = str(item[\'artistid\'])\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sdfsdfs//sdfs/dfsdf/fgd"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        artwork = urllib2.unquote(cover[0]).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + artist + \'.jpg\'\n        cached = os.path.exists(directory + artist + \'.jpg\')\n        if cached != False:\n            artwork = artwork\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + artist + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + artist + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/a_icon.png\'\n            except IndexError:\n                try:\n                    cover = thumb[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/a_icon.png\'\n    Payload = {}\n    Payload = [artist + \'||\' + artwork + \'||\' + artistid + \'||\' + genre + \'||\' + artistid + \'||\' + total]\n    artists.append(Payload)\nartists = str(artists)\nartistsfull = "    " + artists\neg.plugins.Webserver.WsBroadcastData(u\'kodiartists\', artistsfull, u\'\', None, None)\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Album by Artist">
                                <Event Name="kodi.Artist" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get albums filtered by artist">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nartist = str(eg.event.payload)\nx = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetAlbums\', u\'{ "filter": {"field": "artist", "operator": "is", "value": "\' + artist + \'"}, "limits": { "start" : 0, "end": 50 }, "properties": ["playcount", "artist", "genre", "rating", "thumbnail", "year", "fanart"], "sort": { "order": "ascending", "method": "album" } }\', False, True)\nalbums = [] \n\nfor item in x[\'albums\']:\n    artist = str(item[\'artist\'][0])\n    try:\n        fanart = \'images/kodiart/\' +  artist + " - fanart.jpg"\n    except KeyError:\n        fanart = ""\n    try:\n        album = str(item[\'label\'])\n    except UnicodeEncodeError:\n        album = ""\n    try:\n        genre = item[\'genre\'][0]\n    except KeyError:\n        genre = "Unknown"\n    try:\n        rating = int(item[\'rating\'])\n        if rating &lt;= 0:\n            rating = "0"\n    except KeyError:\n        rating = "0"\n    rating = str(rating)\n    year = str(item[\'year\'])\n    playcount = item[\'playcount\']\n    albumid = str(item[\'albumid\'])\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sfsfsa//sfsda/f"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        fanart = item[\'fanart\']\n    except KeyError:\n        fanart = "sfsfsa//sfsda/f"\n    fanart = fanart.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n        c = fanart[1].startswith( \'http\' )\n        d = fanart[1].endswith( \'/\' )\n    except IndexError:\n\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n        c = fanart[0].startswith( \'http\' )\n        d = fanart[0].endswith( \'/\' )\n\n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n        fancover = fanart[1].rsplit("/", 1)\n        fancover = str(fancover[0])\n        fanwork = urllib2.unquote(fancover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n        cachedfanart = os.path.exists(directory + artist + \' - fanart.jpg\')\n        if cachedart != False:\n            artwork = artwork\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                try:\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except UnicodeEncodeError:\n                    artwork = \'images/M_icon.png\'\n                \n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n            except IndexError:\n                try:\n                    cover = thumb[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n        \n        if cachedfanart != False:\n            fanwork = fanwork\n        else:\n            try:\n                cover = fanart[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + artist + \' - fanart.jpg\'\n                try:\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    try:\n                        cover = fanart[1].rsplit("/", 1)\n                        cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                        cover = cover.split(":", 1)\n                        srcfile = str(cover[1])\n                        dstdir = directory + artist + \' - fanart.jpg\'\n                        shutil.copy(srcfile, dstdir)\n                        print "cached image: " + dstdir\n                    except IOError:\n                        fanwork = \'images/f_icon.png\'\n                \n            except IndexError:\n                try:\n                    cover = fanart[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n\n                except IOError:\n                    fanwork = \'images/f_icon.png\'\n    Payload = {}\n    Payload = [album + \'||\' + artwork + \'||\' + artist + \'||\' + year + \'||\' + albumid + \'||\' + rating]\n    albums.append(Payload)\n\nalbumsfull = "    " + str(albums)\nx = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetSongs\', u\'{ "filter": {"field": "artist", "operator": "is", "value": "\' + artist + \'"}, "limits": { "start" : 0, "end": 500 }, "properties": ["playcount", "album", "artist", "genre", "rating", "thumbnail", "year", "fanart"], "sort": { "order": "ascending", "method": "album" } }\', False, True)\ntotal = str(x[\'limits\'][\'total\'])\nfanwork = fanwork + \'||\' + artist + \'||\' + total\n\neg.plugins.Webserver.WsBroadcastData(u\'kodialbums\', albumsfull, u\'\', None, None)\neg.plugins.Webserver.SetValue(u\'kodisongplay\', artist, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodisongplay\')\neg.plugins.Webserver.SetValue(u\'kodialbumul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodialbumul\')\n\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Songs by Artist">
                                <Event Name="kodi.songs" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get songs filtered by artist">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nartist = str(eg.event.payload)\nx = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetSongs\', u\'{ "filter": {"field": "artist", "operator": "is", "value": "\' + artist + \'"}, "limits": { "start" : 0, "end": 500 }, "properties": ["playcount", "album", "artist", "genre", "rating", "thumbnail", "year", "fanart"], "sort": { "order": "ascending", "method": "album" } }\', False, True)\nsongs = [] \n\nfor item in x[\'songs\']:\n    artist = str(item[\'artist\'][0])\n    try:\n        fanart = \'images/kodiart/\' +  artist + " - fanart.jpg"\n    except KeyError:\n        fanart = ""\n    try:\n        song = str(item[\'label\'])\n    except UnicodeEncodeError:\n        song = ""\n    try:\n        album = str(item[\'album\'])\n    except UnicodeEncodeError:\n        album = ""\n    try:\n        genre = item[\'genre\'][0]\n    except KeyError:\n        genre = "Unknown"\n    try:\n        rating = int(item[\'rating\'])\n        if rating &lt;= 0:\n            rating = "0"\n    except KeyError:\n        rating = "0"\n    rating = str(rating)\n    year = str(item[\'year\'])\n    playcount = item[\'playcount\']\n    songid = str(item[\'songid\'])\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sfsfsa//sfsda/f"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        fanart = item[\'fanart\']\n    except KeyError:\n        fanart = "sfsfsa//sfsda/f"\n    fanart = fanart.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n        c = fanart[1].startswith( \'http\' )\n        d = fanart[1].endswith( \'/\' )\n    except IndexError:\n\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n        c = fanart[0].startswith( \'http\' )\n        d = fanart[0].endswith( \'/\' )\n\n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n        fancover = fanart[1].rsplit("/", 1)\n        fancover = str(fancover[0])\n        fanwork = urllib2.unquote(fancover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n        cachedfanart = os.path.exists(directory + artist + \' - fanart.jpg\')\n        if cachedart != False:\n            artwork = artwork\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                try:\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except UnicodeEncodeError:\n                    artwork = \'images/M_icon.png\'\n                \n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n            except IndexError:\n                try:\n                    cover = thumb[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n        \n        if cachedfanart != False:\n            fanwork = fanwork\n        else:\n            try:\n                cover = fanart[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + artist + \' - fanart.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                try:\n                    cover = fanart[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + artist + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/f_icon.png\'\n            except IndexError:\n                try:\n                    cover = fanart[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/f_icon.png\'\n    Payload = {}\n    Payload = [song + \'||\' + artwork + \'||\' + album + \'||\' + artist + \'||\' + songid + \'||\' + rating]\n    songs.append(Payload)\n\nsongsfull = "    " + str(songs)\nfanwork = fanwork + \'||\' + songid\neg.plugins.Webserver.WsBroadcastData(u\'kodisongs\', songsfull, u\'\', None, None)\neg.plugins.Webserver.SetValue(u\'kodisongul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodisongul\')\n\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Searched Music">
                                <Event Name="kodi.kodisearchbtn" />
                                <Action>
                                    Webserver.SetPersistentValue(u'kodimatchedsearchnum', u'0', False, False, 1)
                                </Action>
                                <Action Name="search popup">
                                    EventGhost.PythonScript(u'eg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Searching library", False, False)\neg.plugins.Webserver.SetValue(u\'kodisearchsongul\', "", False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\neg.plugins.Webserver.BroadcastValue(u\'kodisearchsongul\')\neg.plugins.Webserver.WsBroadcastData(u\'kodisearchsongs\', \'\', u\'\', None, None)\neg.plugins.Webserver.WsBroadcastData(u\'kodisearchartists\', \'\', u\'\', None, None)\n')
                                </Action>
                                <Action Name="Get artist ">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\npayload = eg.event.payload\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetArtists\', u\'{ "limits": { "start" : 0, "end":20000 }, "properties": [ "thumbnail", "fanart", "born", "formed", "died", "disbanded", "yearsactive", "mood", "style", "genre" ], "sort": { "order": "ascending", "method": "artist" }  }\', False, True)\nnumber = int(eg.plugins.Webserver.GetPersistentValue(u\'kodimatchedsearchnum\', False))\nartists = []\nfor item in x[\'artists\']:\n    artist = item[\'label\']\n    artistid = str(item[\'artistid\'])\n    try:\n        genre = item[\'genre\'][0]\n    except IndexError:\n        genre = ""\n    try:\n        rating = int(item[\'rating\'])\n        if rating &lt;= 0:\n            rating = "0"\n    except KeyError:\n        rating = "0"\n    rating = str(rating)\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sdfsdfs//sdfs/dfsdf/fgd"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        artwork = urllib2.unquote(cover[0]).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + artist + \'.jpg\'\n        cached = os.path.exists(directory + artist + \'.jpg\')\n        if cached != False:\n            artwork = artwork\n        else:\n            if b == True:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/a_icon.png\'\n    Payload = {}\n    Payload = [artist + \'||\' + artwork + \'||\' + artistid + \'||\' + genre + \'||\' + artistid + \'||\' + rating]\n    if payload.lower() == artist.lower():\n        artists.append(Payload)\n        print "Matched Artist: " + artist\n        eg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Matched Artist: " + artist, False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\n        number = number + 1\n    else:\n        x = ""\nartists = str(artists)\nartistsfull = "    " + artists\neg.plugins.Webserver.WsBroadcastData(u\'kodisearchartists\', artistsfull, u\'\', None, None)  \neg.plugins.Webserver.SetPersistentValue(u\'kodimatchedsearchnum\', str(number), False, False, 1)')
                                </Action>
                                <Action Name="Get albums">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\npayload = eg.event.payload\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetAlbums\', u\'{ "limits": { "start" : 0, "end": 20000 }, "properties": ["playcount", "artist", "genre", "rating", "thumbnail", "year"], "sort": { "order": "ascending", "method": "album" } }\', False, True)\nnumber = int(eg.plugins.Webserver.GetPersistentValue(u\'kodimatchedsearchnum\', False))\nalbums = []\nfor item in x[\'albums\']:\n    artist = item[\'artist\'][0]\n    try:\n        album = str(item[\'label\'])\n    except UnicodeEncodeError:\n        album = ""\n    try:\n        genre = item[\'genre\'][0]\n    except KeyError:\n        genre = "Unknown"\n    try:\n        rating = int(item[\'rating\'])\n        if rating &lt;= 0:\n            rating = "0"\n    except KeyError:\n        rating = "0"\n    rating = str(rating)\n    year = str(item[\'year\'])\n    albumid = str(item[\'albumid\'])\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sfsfsa//sfsda/f"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        fanart = item[\'fanart\']\n    except KeyError:\n        fanart = "sfsfsa//sfsda/f"\n    fanart = fanart.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n        c = fanart[1].startswith( \'http\' )\n        d = fanart[1].endswith( \'/\' )\n    except IndexError:\n\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n        c = fanart[0].startswith( \'http\' )\n        d = fanart[0].endswith( \'/\' )\n\n    if a == True and b == True:\n        try:\n            cover = thumb[1].rsplit("/", 1)\n            cover = str(cover[0])\n            artwork = urllib2.unquote(cover).decode(\'utf8\')\n            print artwork\n        except TypeError:\n            print cover\n    else:\n        artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n        if cachedart != False:\n            artwork = artwork\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                try:\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except UnicodeEncodeError:\n                    artwork = \'images/M_icon.png\'\n                \n            except IOError:\n                    artwork = \'images/M_icon.png\'\n            except IndexError:\n                try:\n                    cover = thumb[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n\n    Payload = {}\n    Payload = [album + \'||\' + artwork + \'||\' + artist + \'||\' + year + \'||\' + albumid + \'||\' + rating]\n    if payload.lower() == album.lower():\n        albums.append(Payload)\n        print "Matched Album: " + artist + \' - \' + album\n        eg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Matched Album: " + artist + \' - \' + album, False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\n        number = number + 1\n    else:\n        x = ""\nalbumsfull = "    " + str(albums)    \neg.plugins.Webserver.WsBroadcastData(u\'kodisearchalbums\', albumsfull, u\'\', None, None)\neg.plugins.Webserver.SetPersistentValue(u\'kodimatchedsearchnum\', str(number), False, False, 1)\n')
                                </Action>
                                <Action Name="Get songs">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\npayload = eg.event.payload\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetSongs\', u\'{ "limits": { "start" : 0, "end": 20000 }, "properties": ["playcount", "artist", "album", "genre", "rating", "thumbnail", "year"], "sort": { "order": "ascending", "method": "track" } }\', False, True)\nnumber = int(eg.plugins.Webserver.GetPersistentValue(u\'kodimatchedsearchnum\', False))\nsongs = []\nfor item in x[\'songs\']:\n    try:\n        song = item[\'label\']\n    except UnicodeEncodeError:\n        song = ""\n    songid = str(item[\'songid\'])\n    artist = item[\'artist\'][0]\n    album = item[\'album\']\n    year = str(item[\'year\'])\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sfsfsa//sfsda/f"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n        if cachedart != False:\n            artwork = artwork\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                try:\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except UnicodeEncodeError:\n                    artwork = \'images/M_icon.png\'\n                \n            except IndexError:\n                try:\n                    cover = thumb[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n            except IOError:\n                artwork = \'images/M_icon.png\'\n    \n    Payload = {}\n    Payload = [song + \'||\' + artwork + \'||\' + album + \'||\' + artist + \'||\' + songid + \'||\' + year]\n    if payload.lower() == song.lower():\n        songs.append(Payload)\n        eg.plugins.Webserver.SetValue(u\'kodisearchsongul\', \'anything\', False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'kodisearchsongul\')\n        print "Matched Song: " + song + \' - \' + artist + \' - \' + album\n        eg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Matched Song: " + song + " - " + artist, False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\n        number = number + 1\n    else:\n        x = ""\nif number == 0:\n    eg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "No Matches Found", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\nsongsfull = "    " + str(songs)\neg.plugins.Webserver.WsBroadcastData(u\'kodisearchsongs\', songsfull, u\'\', None, None)')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Playlists">
                                <Event Name="kodi.Playlists" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get  Playlists">
                                    EventGhost.PythonScript(u'location = "special://profile/playlists/music/"\nx = eg.plugins.XBMC2.JSONRPC(u\'Files.GetDirectory\', u\'{"directory": "\' + location + \'"}\', False, True)\nplaylists = {}\nfor item in x[\'files\']:\n    file = str(item[\'label\'])\n    name = file.split(\'music/\')\n    name = name[0].split(\'.m3u\')\n    name = name[0]\n    playlist =  location + file\n    playlists[name]  = [playlist]\n\nplaylists = str(playlists)\nplaylistsfull = "    " + playlists\neg.plugins.Webserver.WsBroadcastData(u\'kodiplaylists\', playlistsfull, u\'\', None, None)\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Movies">
                                <Event Name="kodi.updatekodimovies" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get movies">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetMovies\', u\'{ "limits": { "start" : 0, "end":1000 }, "properties": ["art", "rating", "resume", "thumbnail", "year", "genre", "playcount", "file", "director", "runtime"], "sort": { "order": "ascending", "method": "label" }  }\', False, True)\nmovies = []\nfor item in x[\'movies\']:\n    movie = item[\'label\']\n    movieid = str(item[\'movieid\'])\n    try:\n        runtime = str(int(item[\'runtime\'] / 60))\n    except KeyError:\n        runtime = ""\n    try:\n        genre = str(item[\'genre\'][0])\n    except IndexError:\n        try:\n            genre = str(item[\'genre\'])\n        except KeyError:\n            genre = ""\n    except KeyError:\n            genre = ""\n    try:\n        playcount = item[\'playcount\']\n    except KeyError:\n        playcount = ""\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = ""\n    try:\n        rating = str(item[\'rating\'])\n    except KeyError:\n        rating = "0"\n    try:\n        director = str(item[\'director\'][0])\n    except UnicodeEncodeError:\n        director = "Unknown"\n    except IndexError:\n        director = "unknown"\n    resume = item[\'resume\'][\'position\']\n    year = str(item[\'year\'])\n    try:\n        poster = item[\'art\'][\'poster\']\n    except KeyError:\n        artwork = \'images/MO_icon.jpg\'\n    thumb = poster.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + movie + ".jpg"\n        cached = os.path.exists(directory + movie + ".jpg")\n        \n        if cached != False:\n            artwork = \'images/kodiart/\' + movie + ".jpg"\n        else:\n            if b == True:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + movie + ".jpg"\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    try:\n                        cover = thumb[1].rsplit("/", 1)\n                        cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                        cover = cover.split(":", 1)\n                        srcfile = str(cover[1])\n                        dstdir = directory + movie + \'.jpg\'\n                        shutil.copy(srcfile, dstdir)\n                        print "cached image: " + dstdir\n                    except IOError:\n                        fanwork = \'images/MO_icon.png\'   \n    Payload = {}\n    Payload = [movie + \'||\' + artwork + \'||\' + year + \'||\' + director + \'||\' + movieid + \'||\' + rating + \'||\' + runtime + \'||\' + genre]\n    movies.append(Payload)\n\nmovies = str(movies)\nmoviesfull = "    " + movies\neg.plugins.Webserver.WsBroadcastData(u\'kodimovies\', moviesfull, u\'\', None, None)\n\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set TV Shows">
                                <Event Name="kodi.updatekoditvshow" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get TV shows">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetTVShows\', u\'{ "limits": { "start" : 0, "end":250 }, "properties": ["art", "genre", "plot", "title", "originaltitle", "year", "rating", "thumbnail", "playcount", "file", "fanart", "episode", "episodeguide", "studio"], "sort": { "order": "ascending", "method": "label" }  }\', False, True)\nshows = []\nfor item in x[\'tvshows\']:\n    tvshow = item[\'label\']\n    tvshowid = str(item[\'tvshowid\'])\n    playcount = item[\'playcount\']\n    plot = item[\'plot\']\n    episodecount = str(item[\'episode\'])\n    rating = str(item[\'rating\'])\n    year = str(item[\'year\'])\n    try:\n        network = str(item[\'studio\'][0])\n    except IndexError:\n        network = "unknown"\n    \n    thumbnail = item[\'thumbnail\']\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + tvshow + ".jpg"\n        cached = os.path.exists(directory + tvshow + ".jpg")\n        \n        if cached != False:\n            artwork = \'images/kodiart/\' + tvshow + ".jpg"\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + tvshow + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + tvshow + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/tv_icon.png\'\n    Payload = {}\n    Payload = [tvshow + \'||\' + artwork + \'||\' + episodecount + \'||\' + network + \'||\' + tvshowid + \'||\' + rating]\n    shows.append(Payload)\n\nshows = str(shows)\nshowsfull = "    " + shows\neg.plugins.Webserver.WsBroadcastData(u\'koditvshows\', showsfull, u\'\', None, None)\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set TV Seasons">
                                <Event Name="kodi.TVSeason" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get TV show Seasons">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\ntvshowid = eg.event.payload\nx = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetSeasons\', u\'{ "limits": { "start" : 0, "end": 500 }, "tvshowid": \' + tvshowid + \', "properties": ["season", "showtitle", "episode", "fanart", "thumbnail", "playcount", "art"], "sort": { "order": "ascending", "method": "season" }  }\', False, True)\nseasons = []\n\n\nfor item in x[\'seasons\']:\n    season = str(item[\'label\'])\n    seasonid = str(item[\'seasonid\'])\n    showtitle = str(item[\'showtitle\'])\n    thumbnail = item[\'thumbnail\']\n    fanart = item[\'fanart\']\n    episodecount = str(item[\'episode\'])\n    try:\n        network = str(item[\'studio\'][0])\n        \n    except KeyError:\n        network = "unknown"\n    thumbnail = item[\'thumbnail\']\n    thumb = thumbnail.split(\'//\', 1)\n    fan = fanart.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + showtitle + " - " + season + ".jpg"\n        cached = os.path.exists(directory + showtitle + " - " + season + ".jpg")\n        \n        if cached != False:\n            artwork = \'images/kodiart/\' + showtitle + " - " + season + ".jpg"\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + showtitle + " - " + season + ".jpg"\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + showtitle + \' - \' + season + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/tv_icon.png\'\n    Payload = {}\n    Payload = [season + \'||\' + artwork + \'||\' + tvshowid + \'||\' + showtitle + \'||\' + episodecount + \'||\' + \'\']\n    seasons.append(Payload)\n\nseasons = str(seasons)\nseasonsfull = "    " + seasons\n\ntry:\n    a = fan[1].startswith( \'http\' )\n    b = fan[1].endswith( \'/\' )\n\nexcept IndexError:\n    a = fan[0].startswith( \'http\' )\n    b = fan[0].endswith( \'/\' )\n\nif a == True and b == True:\n        cover = fan[1].rsplit("/", 1)\n        cover = str(cover[0])\n        fanwork = urllib2.unquote(cover).decode(\'utf8\')\nelse:\n    fanwork = \'images/kodiart/\' + showtitle + " - fanart.jpg"\n    cached = os.path.exists(directory + showtitle + " - fanart.jpg")\n    if cached != False:\n        fanwork = \'images/kodiart/\' + showtitle + " - fanart.jpg"\n    else:\n        try:\n            cover = fan[1].rsplit("/", 1)\n            cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n            srcfile = str(cover)\n            dstdir = directory + showtitle + " - fanart.jpg"\n            shutil.copy(srcfile, dstdir)\n            print "cached image: " + dstdir\n        except IOError:\n            try:\n                cover = fan[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                cover = cover.split(":", 1)\n                srcfile = str(cover[1])\n                dstdir = directory + showtitle + \' - fanart.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                fanwork = \'images/f_icon.png\'\n        \n        \neg.plugins.Webserver.WsBroadcastData(u\'koditvseasons\', seasonsfull, u\'\', None, None)\neg.plugins.Webserver.SetValue(u\'koditvseasonul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'koditvseasonul\')')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set TV Episode">
                                <Event Name="kodi.TVEpisode" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get TV episodes by shows id &amp; season number http:/local cached check">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\npayload = eg.event.payload\npay = payload.split("||")\nseasonid = pay[1].split(\'Season \')\nseasonid = seasonid[1]\ntvshowid = pay[0]\nx = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetEpisodes\', u\'{ "tvshowid": \' + tvshowid + \', "season": \' + seasonid + \', "properties": ["season", "resume", "title", "showtitle", "episode", "playcount", "plot", "fanart", "thumbnail", "rating"], "sort": { "order": "ascending", "method": "label" }  }\', False, True)\nepisodes = []\nfor item in x[\'episodes\']:\n    episode = item[\'title\']\n    episodenum = str(item[\'episode\'])\n    if len(episodenum) &lt; 2:\n        episodenum = "0" + episodenum\n    seasonnum = str(seasonid)\n    se = "s" + seasonnum + \'e\' + episodenum\n    episodeid = str(item[\'episodeid\'])\n    plot = item[\'plot\']\n    resume = item[\'resume\'][\'position\']\n    rating = str(item[\'rating\'])\n    thumbnail = item[\'thumbnail\']\n    showtitle = item[\'showtitle\']\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + showtitle + \' - \' + se + \'.jpg\'\n        cachedart = os.path.exists(directory + showtitle + \' - \' + se + \'.jpg\')\n        if cachedart != False:\n            artwork = \'images/kodiart/\'+ showtitle + \' - \' + se + \'.jpg\'\n        else:\n            try: \n                cover = thumb[1].rsplit(\'/\', 1)\n                srcfile = urllib2.unquote(cover[0]).decode(\'utf8\')\n                dstdir = directory + showtitle + \' - \' + se + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except UnicodeEncodeError:\n                cover = thumb[1].rsplit(\'/\', 1)\n                artwork = \'images/k_icon.png\'\n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + showtitle + \' - \' + se + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    print "error"\n                    artwork = \'images/k_icon.png\'\n    Payload = {}\n    Payload = [episode + \'||\' + artwork + \'||\' + se + \'||\' + showtitle + \'||\' + episodeid + \'||\' + rating]\n    episodes.append(Payload)\n    \nepisodes = str(episodes)\nepisodesfull = "    " + episodes\neg.plugins.Webserver.WsBroadcastData(u\'koditvepisodes\', episodesfull, u\'\', None, None)\n\nx = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetSeasons\', u\'{ "limits": { "start" : 0, "end": 500 }, "tvshowid": \' + tvshowid + \', "properties": ["season", "showtitle", "episode", "fanart", "thumbnail", "playcount", "art"], "sort": { "order": "ascending", "method": "season" }  }\', False, True)\n\nshowtitle = str(x[\'seasons\'][0][\'showtitle\'])\nfanart = x[\'seasons\'][0][\'fanart\']\nfanart = fanart.split(\'//\', 1)\nurl = str(fanart[1])\ncover = urllib2.unquote(url).decode(\'utf8\')\na = cover.startswith( \'http\' )\nb = cover.endswith( \'.jpg\' )\nc = cover.endswith( \'/\' )\n\nif a == True and b == True:\n    cover = cover.split(".jpg")\n    fanwork = str(cover[0]) + \'.jpg\'\n\nelif a == True and c == True:\n    cover = cover.rsplit("/", 1)\n    fanwork = str(cover[0])\n\nelse:\n    fanwork = \'images/kodiart/\' + showtitle + \' - fanart.jpg\'\n    cachedfanart = os.path.exists(directory + showtitle + \' - fanart.jpg\')\n        \n    if cachedfanart != False:\n        try:\n            fanwork = \'images/kodiart/\' + showtitle + \' - fanart.jpg\'\n        except IOError:\n            try:\n                cover = cover.rsplit("/", 1)\n                srcfile = str(cover[0])\n                dstdir = directory + showtitle + \' - fanart.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                try:\n                    cover = cover[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    print cover\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + showtitle + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/f_icon.png\'\n    else:\n        fanwork = \'images/f_icon.png\'   \neg.plugins.Webserver.SetValue(u\'koditvepisodeul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'koditvepisodeul\')')
                                </Action>
                                <Action Name="Get TV episodes by shows id &amp; season number http:/cache local without check" Enabled="False">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\npayload = eg.event.payload\npay = payload.split("||")\nseasonid = pay[1].split(\'Season \')\nseasonid = seasonid[1]\ntvshowid = pay[0]\nx = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetEpisodes\', u\'{ "tvshowid": \' + tvshowid + \', "season": \' + seasonid + \', "properties": ["season", "resume", "title", "showtitle", "episode", "playcount", "plot", "fanart", "thumbnail", "rating"], "sort": { "order": "ascending", "method": "label" }  }\', False, True)\nepisodes = []\nfor item in x[\'episodes\']:\n    episode = item[\'title\']\n    episodenum = str(item[\'episode\'])\n    if len(episodenum) &lt; 2:\n        episodenum = "0" + episodenum\n    seasonnum = str(seasonid)\n    se = "s" + seasonnum + \'e\' + episodenum\n    episodeid = str(item[\'episodeid\'])\n    plot = item[\'plot\']\n    rating = str(item[\'rating\'])\n    thumbnail = item[\'thumbnail\']\n    showtitle = item[\'showtitle\']\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + showtitle + \' - \' + se + \'.jpg\'\n        cover = thumb[1].rsplit(\'/\', 1)\n        try:\n            srcfile = urllib2.unquote(cover[0]).decode(\'utf8\')\n            dstdir = directory + showtitle + \' - \' + se + \'.jpg\'\n            shutil.copy(srcfile, dstdir)\n        except UnicodeEncodeError:\n            srcfile = ""\n        \n\n    Payload = {}\n    Payload = [episode + \'||\' + artwork + \'||\' + se + \'||\' + showtitle + \'||\' + episodeid + \'||\' + rating]\n    episodes.append(Payload)\n    \nepisodes = str(episodes)\nepisodesfull = "    " + episodes\neg.plugins.Webserver.WsBroadcastData(u\'koditvepisodes\', episodesfull, u\'\', None, None)\n\nx = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetSeasons\', u\'{ "limits": { "start" : 0, "end": 500 }, "tvshowid": \' + tvshowid + \', "properties": ["season", "showtitle", "episode", "fanart", "thumbnail", "playcount", "art"], "sort": { "order": "ascending", "method": "season" }  }\', False, True)\n\nshowtitle = str(x[\'seasons\'][0][\'showtitle\'])\nfanart = x[\'seasons\'][0][\'fanart\']\nfanart = fanart.split(\'//\', 1)\nurl = str(fanart[1])\ncover = urllib2.unquote(url).decode(\'utf8\')\na = cover.startswith( \'http\' )\nb = cover.endswith( \'.jpg\' )\nc = cover.endswith( \'/\' )\n\nif a == True and b == True:\n    cover = cover.split(".jpg")\n    fanwork = str(cover[0]) + \'.jpg\'\n\nelif a == True and c == True:\n    cover = cover.rsplit("/", 1)\n    fanwork = str(cover[0])\n\nelse:\n    fanwork = \'images/kodiart/\' + showtitle + \' - fanart.jpg\'\n    cover = cover.rsplit("/", 1)\n    srcfile = str(cover[0])\n    dstdir = directory + showtitle + \' - fanart.jpg\'\n    shutil.copy(srcfile, dstdir)\n    \neg.plugins.Webserver.SetValue(u\'koditvepisodeul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'koditvepisodeul\')')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set PVR channels">
                                <Event Name="kodi.updatekodipvr" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get Channels (current info)">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nchannels = eg.plugins.XBMC2.JSONRPC(u\'PVR.GetChannels\', u\'{"channelgroupid": 1, "properties": [ "thumbnail", "channel", \\\'lastplayed\\\', \\\'hidden\\\']}\', False, True)\nchannellist = []\nfor channel in channels[\'channels\']:\n    name = channel[\'label\']\n    hidden = channel[\'hidden\']\n    thumbnail = channel[\'thumbnail\']\n    channelid = str(channel[\'channelid\'])\n    chan = {}\n    chan[channelid] = {\'name\':name, \'id\':channelid, \'thumbnail\':thumbnail}\n    channellist.append(chan)\nmychannels = []\nfor item in channellist:\n    \n    channame = str(item.values()[0][\'name\'])\n    channame = channame.split(" ")\n    channelname = channame[1]\n    if channelname == "":\n        channelname = "???"\n    thumbnail = str(item.values()[0][\'thumbnail\'])\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + channelname + \'.jpg\'\n        cachedart = os.path.exists(directory + channelname + \'.jpg\')\n        if cachedart != False:\n            artwork = \'images/kodiart/\'+ channelname + \'.jpg\'\n        else:\n            try: \n                cover = thumb[1].rsplit(\'/\', 1)\n                srcfile = urllib2.unquote(cover[0]).decode(\'utf8\')\n                dstdir = directory + channelname + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                artwork = \'images/k_icon.png\'\n            except IndexError:\n                artwork = \'images/k_icon.png\'\n    channelid = str(item.values()[0][\'id\'])\n    getchan = str(item.keys()[0])\n    chan = eg.plugins.XBMC2.JSONRPC(u\'PVR.GetBroadcasts\', u\'{"channelid":\' + getchan + \', "properties": [ "thumbnail","title", "episodename","plot","runtime","starttime","endtime"]}\', False, True)\n    try:\n        details = chan[\'broadcasts\'][0]\n        broadcastid = str(details[\'broadcastid\'])\n        episodename = details[\'episodename\']\n        plot = details[\'plot\']\n        episodetitle = details[\'label\']\n        runtime = str(details[\'runtime\'])\n        start = details[\'starttime\']\n        end = details[\'endtime\']\n    except KeyError:\n        x = "y"\n    Payload = {}\n    Payload = [channelid + \'||\' + artwork + \'||\' + channelname + \'||\' + episodetitle + \'||\' + broadcastid + \'||\' + runtime]\n    mychannels.append(Payload)\n\nmychannelsfull = "    " + str(mychannels)\neg.plugins.Webserver.WsBroadcastData(u\'kodipvr\', mychannelsfull, u\'\', None, None)\n\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Current Audio Playlist" id="587">
                                <Event Name="XBMC2.Playlist.OnClear" />
                                <Event Name="kodi.reloadtracks" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get Current Playlist Tracks">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaultcdthumb\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC2.JSONRPC(u\'Playlist.GetItems\', u\'{"playlistid":0, "properties": ["title", "album", "artist", "duration", "rating", "track", "thumbnail", "fanart"]}\', False, True)\n\nsize = x[\'limits\'][\'total\']\nif size != 0:\n    tracks = []\n    postion = 0\n    for item in x[\'items\']:\n        position = str(postion + 1)\n        try:\n            artist = str(item[\'artist\'])\n        except KeyError:\n            artist = "???"\n        u = artist.startswith( \'[\' )\n        if u == True:\n            artist = str(item[\'artist\'][0])\n        try:\n            album = str(item[\'album\'])\n        except UnicodeEncodeError:\n            album = ""\n        artistlong = artist + \' - \' + album\n        duration = int(item[\'duration\'])\n        m, s = divmod(duration, 60)\n        duration = "%2d:%02d" % (m, s)\n        duration = str(duration)\n        songid = item[\'id\']\n        track = item[\'title\']\n        tracknum = item[\'track\']\n        tracknum = str(tracknum)\n        type = item[\'type\']\n        rating = str(item[\'rating\'])\n        thumb = item[\'thumbnail\']\n        thumb = thumb.split(\'//\', 1)\n        fanart = item[\'fanart\']\n        fanart = fanart.split(\'//\', 1)\n    \n        try:\n            a = thumb[1].startswith( \'http\' )\n            b = thumb[1].endswith( \'/\' )\n            c = fanart[1].startswith( \'http\' )\n            d = fanart[1].endswith( \'/\' )\n        except IndexError:\n            a = thumb[0].startswith( \'http\' )\n            b = thumb[0].endswith( \'/\' )\n            c = fanart[0].startswith( \'http\' )\n            d = fanart[0].endswith( \'/\' )\n        if a == True and b == True:\n            cover = thumb[1].rsplit("/", 1)\n            cover = str(cover[0])\n            artwork = urllib2.unquote(cover).decode(\'utf8\')\n            fanart = fanart[1].rsplit("/", 1)\n            fancover = str(fanart[0])\n            fanwork = urllib2.unquote(fancover).decode(\'utf8\')\n        else:\n            artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n            fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n            cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n            cachedfanart = os.path.exists(directory + artist + \' - fanart.jpg\')\n            if cachedart != False:\n                artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n            else:\n                if b == True:\n                    try:\n                        cover = thumb[1].rsplit("/", 1)\n                        cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                        srcfile = str(cover)\n                        dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                        shutil.copy(srcfile, dstdir)\n                        print "copied"\n                    except IOError:\n                        artwork = \'images/M_icon.png\'\n                artwork = \'images/M_icon.png\'\n        \n            if cachedfanart != False:\n                fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n            else:\n                if b == True:\n                    try:\n                        cover = fanart[1].rsplit("/", 1)\n                        cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                        srcfile = str(cover)\n                        dstdir = directory + artist + \' - fanart.jpg\'\n                        shutil.copy(srcfile, dstdir)\n                        print "cached image: " + dstdir\n                    except IOError:\n                        fanwork = \'images/f_icon.png\'\n    \n        Payload = {}\n        Payload = [track + \'||\' + artwork + \'||\' + artist + \'||\' + duration + \'||\' + tracknum + \'||\' + rating]\n        tracks.append(Payload)\n\n    tracks = str(tracks)\n    tracksfull = "     " + tracks\n    eg.plugins.Webserver.WsBroadcastData(u\'kodicurrenttracks\', tracksfull, u\'\', None, None)\n\nelse:\n    eg.plugins.Webserver.SetValue(u\'kodiclearcurrentplaylistul\', "", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiclearcurrentplaylistul\')\n    eg.Exit()')
                                </Action>
                                <Action Name="Get/Save/Set Fanart">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\nimport re\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaultcdthumb\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\np = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = p[0][\'playerid\']\n    id = str(id)\n    type = p[0][\'type\']\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\n\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\nif id == "0":\n    current = eg.plugins.XBMC2.JSONRPC(u\'Player.GetItem\', u\'{ "properties": ["title", "album", "artist", "duration", "year", "rating", "playcount", "genre", "thumbnail", "file", "fanart", "streamdetails"], "playerid": \' + id + \' }\', False, True)\n    artist = current[\'item\'][\'artist\'][0]\n    album = current[\'item\'][\'album\']\n    fanart = current[\'item\'][\'fanart\']\n    fanart = fanart.split(\'//\', 1)\n    \n    try:\n        c = fanart[1].startswith( \'http\' )\n        d = fanart[1].endswith( \'/\' )\n    except IndexError:\n        c = fanart[0].startswith( \'http\' )\n        d = fanart[0].endswith( \'/\' )\n    if c == True and d == True:\n        fanart = fanart[1].rsplit("/", 1)\n        fancover = str(fanart[0])\n        fanwork = urllib2.unquote(fancover).decode(\'utf8\')\n    else:\n        fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        cachedfanart = os.path.exists(directory + artist + \' - fanart.jpg\')\n        if cachedfanart != False:\n            fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        else:\n            if d == True:\n                try:\n                    cover = fanart[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/f_icon.png\'\n                    \n    eg.plugins.Webserver.SetValue(u\'kodicurrentplaylistul\', fanwork, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodicurrentplaylistul\')')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Current Video Playlist" id="595">
                                <Event Name="kodi.UpdatekodiVideoTracks" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get Current Playlist Tracks">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaultcdthumb\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC2.JSONRPC(u\'Playlist.GetItems\', u\'{"playlistid":1, "properties": ["originaltitle", "sorttitle", "uniqueid", "season", "tvshowid", "duration", "episode", "showtitle", "rating", "description", "episodeguide", "plotoutline", "thumbnail", "title", "track", "fanart"]}\', False, True)\ntracks = []\npostion = 0\n\ntry:\n    showtitle = str(x[\'items\'][0][\'showtitle\'])\nexcept KeyError:\n    eg.Exit()\nfanart = x[\'items\'][0][\'fanart\']\nfanart = fanart.split(\'//\', 1)\ncover = str(fanart[1])\n\na = cover.startswith( \'http\' )\nb = cover.endswith( \'/\' )\nif a == True and b == True:\n    cover = cover.rsplit("/", 1)\n    cover = str(cover[0])\n    fanwork = urllib2.unquote(cover).decode(\'utf8\')\nelse:\n    fanwork = \'images/kodiart/\' + showtitle + \' - fanart.jpg\'\n    cachedfanart = os.path.exists(directory + showtitle + \' - fanart.jpg\')\n    \n    if cachedfanart != False:\n        fanwork = \'images/kodiart/\' + showtitle + \' - fanart.jpg\'\n    else:\n        if b == True:\n            try:\n                cover = fanart[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + showtitle + \' - fanart.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                cover = cover.split(":")\n                srcfile = str(cover[1])\n                dstdir = directory + showtitle + \' - fanart.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                artwork = \'images/f_icon.png\'\n\n\nfor item in x[\'items\']:\n    position = str(postion + 1)\n    try:\n        season = int(item[\'season\'])\n    except UnicodeEncodeError:\n        season = ""\n    episode = int(item[\'episode\'])\n    try:\n        duration = int(item[\'duration\'])\n        m, s = divmod(duration, 60)\n        duration = "%2d:%02d" % (m, s)\n        duration = str(duration)\n    except KeyError:\n        duration = ""\n    sorttitle = str(item[\'sorttitle\'])\n    title = str(item[\'title\'])\n    tracknum = item[\'track\']\n    tracknum = str(tracknum)\n    tvshowid = str(item[\'tvshowid\'])\n    showtitle = str(item[\'showtitle\'])\n    plot = str(item[\'plotoutline\'])\n    thumbnail = str(item[\'thumbnail\'])\n    type = item[\'type\']\n    rating = str(int(round(item[\'rating\']) / 2))\n    try:\n        uniqueid = str(item[\'uniqueid\'])\n    except KeyError:\n        uniqueid = ""\n    try:\n        description = str(item[\'description\'])\n    except KeyError:\n        description = ""\n\n    if season &lt;= 9:\n        season = "0" + str(season)\n    else:\n        season = str(season)\n    if episode &lt;= 9:\n        episode = "0" + str(episode)\n    else:\n        episode = str(episode)\n\n    se = "S" + season + "E" + episode\n    \n    thumb = thumbnail.split(\'//\', 1)\n    \n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:  \n        artwork = \'images/kodiart/\'+ showtitle + \' - \' + "s" + season + "e" + episode + \'.jpg\'\n        cached = os.path.exists(directory + showtitle + \' - \' + "s" + season + "e" + episode + \'.jpg\')\n        if cached != False:\n            artwork = \'images/kodiart/\' + showtitle + \' - \' + "s" + season + "e" + episode + \'.jpg\'\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + showtitle + \' - \' + "s" + season + "e" + episode + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                cover = cover.split(":")\n                srcfile = str(cover[1])\n                dstdir = directory + showtitle + \' - \' + "s" + season + "e" + episode + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                artwork = \'images/k_icon.png\'\n    Payload = {}\n    Payload = [title + \'||\' + artwork + \'||\' + showtitle + " - " + se + \'||\' + duration + \'||\' + "" + \'||\' + rating]\n    tracks.append(Payload)\n\ntracks = str(tracks)\ntracksfull = "     " + tracks\n\neg.plugins.Webserver.WsBroadcastData(u\'kodicurrenttracks\', tracksfull, u\'\', None, None)\neg.plugins.Webserver.SetValue(u\'kodicurrentplaylistul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodicurrentplaylistul\')')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Main player info">
                            <Macro Name="Get/Set Current Audio Playback variables" id="602">
                                <Event Name="Main.kodiaucioplayeractive" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get/Save/Set Thumbnail">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\nimport re\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaultcdthumb\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\np = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = p[0][\'playerid\']\n    id = str(id)\n    type = p[0][\'type\']\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\n\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\nif id == "0":\n    current = eg.plugins.XBMC2.JSONRPC(u\'Player.GetItem\', u\'{ "properties": ["title", "album", "artist", "duration", "year", "rating", "playcount", "genre", "thumbnail", "file", "fanart", "streamdetails"], "playerid": \' + id + \' }\', False, True)\n    artist = current[\'item\'][\'artist\'][0]\n    album = current[\'item\'][\'album\']\n    thumb = current[\'item\'][\'thumbnail\']\n    fanart = current[\'item\'][\'fanart\']\n    thumb = thumb.split(\'//\', 1)\n    fanart = fanart.split(\'//\', 1)\n    \n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n        c = fanart[1].startswith( \'http\' )\n        d = fanart[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n        c = fanart[0].startswith( \'http\' )\n        d = fanart[0].endswith( \'/\' )\n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n        fanart = fanart[1].rsplit("/", 1)\n        fancover = str(fanart[0])\n        fanwork = urllib2.unquote(fancover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n        cachedfanart = os.path.exists(directory + artist + \' - fanart.jpg\')\n        if cachedart != False:\n            artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        else:\n            if b == True:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "copied"\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n                    \n        if cachedfanart != False:\n            fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        else:\n            if b == True:\n                try:\n                    cover = fanart[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/f_icon.png\'              \n    coverart = \'&lt;a id="kodi.reloadtracks" name="kodi" title="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" href="#kodiplaylist"&gt;&lt;img style="text-align:center;" id="art" src="\' + artwork + \'" width="250" height="250" alt=""/&gt;&lt;/a&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodicoverart\', coverart, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodicoverart\')\n')
                                </Action>
                                <Action Name="Get/Set current playback info">
                                    EventGhost.PythonScript(u'import urllib2\np = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = str(p[0][\'playerid\'])\n    type = p[0][\'type\']\nexcept IndexError:\n    id = "none"\n    print "id = None"\ncurrent = eg.plugins.XBMC2.JSONRPC(u\'Player.GetItem\', u\'{ "properties": ["title", "album", "artist", "duration", "year", "rating", "playcount", "genre", "thumbnail", "file", "fanart", "streamdetails"], "playerid": \' + id + \' }\', False, True)\nsongid = str(current[\'item\'][\'id\'])\ntype = current[\'item\'][\'type\']\nartist = current[\'item\'][\'artist\'][0]\nalbum = current[\'item\'][\'album\']\nsong = current[\'item\'][\'title\']\nyear = str(current[\'item\'][\'year\'])\nrating = str(current[\'item\'][\'rating\'])\nfanart = current[\'item\'][\'fanart\']\nu = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetSongDetails\', u\'{"songid": \' + songid + \', "properties": ["playcount", "lastplayed", "track", "duration", "albumid", "albumartistid", "artist", "album"]}\', False, True)\nplaycount = str(u[\'songdetails\'][\'playcount\'])\np = eg.plugins.XBMC2.JSONRPC(u\'Player.GetProperties\', u\'{"playerid": \' + id + \', "properties": ["repeat", "shuffled", "percentage", "time", "totaltime", "type", "playlistid", "partymode", "position", "speed"]}\', False, True)\ntry:\n    progress = p[\'percentage\']\nexcept TypeError:\n    progress = "0"\ntry:\n    partymode = p[\'partymode\']\nexcept TypeError:\n    partymode = "False"\ntry:\n    speed = p[\'speed\']\n    if speed == 0:\n        state = "Paused"\n    elif speed == 1:\n        state = "Playing"\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', state, False, False)\nexcept TypeError:\n    speed = "0"\n    \neg.plugins.Webserver.SetValue(u\'koditrackplaycount\', playcount, False, False)\neg.plugins.Webserver.BroadcastValue(u\'koditrackplaycount\')\n\nif state == None:\n    state = "Playing"\nif state == "Playing":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', eqimg, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodileftRating\')\nelif state == "Paused":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Paused", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\n    eqimg = \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', eqimg, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodileftRating\')\nelif state == "Stopped":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Stopped", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\n    eqimg = \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', eqimg, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodileftRating\')\n\neg.plugins.Webserver.SetValue(u\'kodiartist\', artist, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodiartist\')\neg.plugins.Webserver.SetValue(u\'kodialbum\', album, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodialbum\')\neg.plugins.Webserver.SetValue(u\'koditrackTitle\', song, False, False)\neg.plugins.Webserver.BroadcastValue(u\'koditrackTitle\')\neg.plugins.Webserver.SetValue(u\'kodiyear\', year, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodiyear\')\neg.plugins.Webserver.SetValue(u\'kodirating\', rating, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodirating\')\neg.plugins.Webserver.BroadcastValue(u\'kodiroom\', None, u\'\', None)\neg.plugins.Webserver.BroadcastValue(u\'kodirun_icon\', None, u\'\', None)\n\n\n')
                                </Action>
                                <Action>
                                    EventGhost.DisableItem(XmlIdLink(415))
                                </Action>
                                <Action>
                                    EventGhost.EnableItem(XmlIdLink(396))
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.hidedefaultplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.hidevideoplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.showaudioplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodiupdatetoggles', 0.5)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(587), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Current Video Playback variables" id="616">
                                <Event Name="Main.kodiVideoplayeractive" />
                                <Event Name="Main.kodichannelchanged" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action Name="Get/Set current playback info &amp; poster">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaulttvposter\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nepisodeshort = "Other Variable"\np = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = str(p[0][\'playerid\'])\n    type = p[0][\'type\']\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\ncurrent = eg.plugins.XBMC2.JSONRPC(u\'Player.GetItem\', u\'{ "properties": ["theme", "tagline", "premiered", "studio", "director", "title", "album", "artist", "duration", "year", "rating", "playcount", "genre", "thumbnail", "file", "fanart", "streamdetails", "tvshowid", "season", "episode", "showtitle"], "playerid": \' + id + \' }\', False, True)\ntry:\n    file = current[\'item\'][\'file\']\nexcept KeyError:\n    file = ""\n\n\nid = str(current[\'item\'][\'id\'])\nthumbnail = str(current[\'item\'][\'thumbnail\'])\ntry:\n    premiered = str(current[\'item\'][\'premiered\'])\nexcept KeyError:\n    premiered = ""\ntype = current[\'item\'][\'type\']\ntry:\n    genre = current[\'item\'][\'genre\'][0]\nexcept IndexError:\n    genre = "Unknown"\nyear = str(current[\'item\'][\'year\'])\nrating = current[\'item\'][\'rating\']\nrating = str(int(round(rating / 2)))\ntitle = str(current[\'item\'][\'title\'])\ntry:\n    director = str(current[\'item\'][\'director\'][0])\nexcept IndexError:\n    director = ""\nrating = str(rating)\nfanart = str(current[\'item\'][\'fanart\'])\ntry:\n    tvshowid = str(current[\'item\'][\'tvshowid\'])\nexcept KeyError:\n    tvshowid = ""\ntry:\n    studio = str(current[\'item\'][\'studio\'][0])\nexcept IndexError:\n    studio = "Unknown"\nexcept KeyError:\n    studio = ""\ntry:\n    duration = str(current[\'item\'][\'duration\'])\nexcept KeyError:\n    duration = ""\ntry:\n    showtitle = str(current[\'item\'][\'showtitle\'])\nexcept KeyError:\n    showtitle = ""\nstate = eg.plugins.Webserver.GetValue(u\'kodiplaypause\', False)\n\nif state == None:\n    state = "Playing"\nif state == "Playing":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', eqimg, False, False)\nelif state == "Paused":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Paused", False, False)\n    eqimg = \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', eqimg, False, False)\nelif state == "Stopped":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Stopped", False, False)\n    eqimg = \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', eqimg, False, False)\n\neg.plugins.Webserver.SetValue(u\'kodiVideotrackTitle\', showtitle, False, False)\neg.plugins.Webserver.SetValue(u\'kodiVideoshow\', title, False, False)\neg.plugins.Webserver.SetValue(u\'kodiVideorating\', rating, False, False)\n\neg.plugins.Webserver.BroadcastValue(u\'kodiVideorating\')\neg.plugins.Webserver.BroadcastValue(u\'kodiroom\', None, u\'\', None)\neg.plugins.Webserver.BroadcastValue(u\'kodirun_icon\', None, u\'\', None)\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoleftRating\')\neg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\n\nif type == "episode":\n    year = premiered[:4]\n    eg.plugins.Webserver.SetValue(u\'kodiVideonetworkgenre\', studio, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideogenre\', genre, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoyear\', year, False, False)\n    \n    season = current[\'item\'][\'season\']\n    if season &lt;= 9:\n        season = "0" + str(season)\n    else:\n        season = str(season)\n    episode = (current[\'item\'][\'episode\'])\n    if episode &lt;= 9:\n        episode = "0" + str(episode)\n    else:\n        episode = str(episode)\n    episodeshort = "S" + season + "E" + episode\n    season = int(season)\n    x = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetSeasons\', u\'{ "limits": { "start" : 0, "end": 500 }, "tvshowid": \' + tvshowid + \', "properties": ["season", "showtitle", "episode", "fanart", "thumbnail", "playcount", "art"], "sort": { "order": "ascending", "method": "season" }  }\', False, True)\n    try:\n        episodecount = str(x[\'seasons\'][season][\'episode\'])\n    except IndexError:\n        episodecount = "0"\n    try: \n        poster = x[\'seasons\'][season][\'art\'][\'poster\']\n    except IndexError:\n        poster = default\n    cover = poster.split(\'//\', 1)\n    season = str(season)\n    try:\n        a = cover[1].startswith( \'http\' )\n        b = cover[1].endswith( \'/\' )\n\n    except IndexError:\n        try:\n            a = cover.startswith( \'http\' )\n            b = cover.endswith( \'/\' )\n        except AttributeError:\n            a = cover[0].startswith( \'http\' )\n            b = cover[0].endswith( \'/\' )\n    if a == True and b == True:\n        cover = cover[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + showtitle + \' - Season \' + season + \'.jpg\'\n        cached = os.path.exists(directory + showtitle + \' - \' + season + \'.jpg\')\n        if cached != False:\n            artwork = \'images/kodiart/\' + showtitle + \' - Season \' + season + \'.jpg\'\n        else:\n            if b == True:\n                try:\n                    cover = cover[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + showtitle + " - " + season + ".jpg"\n                    shutil.copy(srcfile, dstdir)\n                    print "cached file: " + dstdir\n                except IOError:\n                    artwork = \'images/tv_icon.png\'\n    print artwork\n    coverart = \'&lt;a id="kodi.reloadtracks" name="kodi" title="UpdatekodiVideoTracks" class="dynamicdatasend" data-action="reload.tracks" href="#kodiplaylist"&gt;&lt;img style="text-align:center;" id="art" src="\' + artwork + \'" width="210" height="300" alt=""/&gt;&lt;/a&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideocoverart\', coverart, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiVideocoverart\')\n    eg.plugins.Webserver.SetValue(u\'kodiVideotrackTitle\', title, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoshow\', episodeshort, False, False)\nif type == "movie":\n    eg.plugins.Webserver.SetValue(u\'kodiVideogenre\', genre, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideonetworkgenre\', studio, False, False)\n    thumb = thumbnail.split(\'//\', 1)\n    url = str(thumb[1])\n    cover = urllib2.unquote(url).decode(\'utf8\')\n    try:\n        a = cover.startswith( \'http\' )\n        b = cover.endswith( \'/\' )\n\n    except IndexError:\n        a = cover.startswith( \'http\' )\n        b = cover.endswith( \'/\' )\n        \n    if a == True and b == True:\n        cover = cover.rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n        \n    else:\n        artwork = \'images/kodiart/\' + title + \'.jpg\'\n        cached = os.path.exists(directory + title + ".jpg")\n        \n        if cached != False:\n            artwork = \'images/kodiart/\' + title + ".jpg"\n        else:\n            if b == True:\n                try:\n                    cover = cover.rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + title + ".jpg"\n                    shutil.copy(srcfile, dstdir)\n                    print "copied"\n                except IOError:\n                    artwork = \'images/MO_icon.png\'\n    print artwork\n    coverart = \'&lt;a id="moviees" name="kodi" title="UpdatekodiVideoTracks" class="dynamicdatasend" data-action="" href="#"&gt;&lt;img style="text-align:center;" id="art" src="\' + artwork + \'" width="210" height="300" alt=""/&gt;&lt;/a&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideocoverart\', coverart, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiVideocoverart\')\n    eg.plugins.Webserver.SetValue(u\'kodiVideotrackTitle\', title, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoshow\', director, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoyear\', year, False, False)\n    \nif type == "channel":\n    label = str(current[\'item\'][\'label\'])\n    thumbnail = str(current[\'item\'][\'thumbnail\'])\n    rating = "0"\n\n    cover = urllib2.unquote(thumbnail).decode(\'utf8\')\n    cover = cover.split(\'//\', 1)\n    cover = cover[1].rsplit("/", 1)\n    cover = cover[0]\n    coverart = \'&lt;a id="kodi.reloadchannels" title="UpdatekodiVideoTracks" name="kodi" class="dynamicdatasend" data-action="reload.channels" href="#kodi_pvr"&gt;&lt;img style="text-align:center;" id="art" src="\' + cover + \'" width="210" height="300" alt=""/&gt;&lt;/a&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideocoverart\', coverart, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiVideocoverart\')\n    eg.plugins.Webserver.SetValue(u\'kodiVideotrackTitle\', label, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoshow\', title, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoinfoholder\', "hide", False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoratingContainer\', "hide", False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoprogressholder\', "hide", False, False)\n\n\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoshow\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideogenre\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideonetworkgenre\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideotrackTitle\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoinfoholder\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoratingContainer\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoprogressholder\')\n\n')
                                </Action>
                                <Action>
                                    EventGhost.DisableItem(XmlIdLink(396))
                                </Action>
                                <Action>
                                    EventGhost.EnableItem(XmlIdLink(415))
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.hideaudioplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.hidedefaultplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.showvideoplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodiupdatetoggles', 0.5)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(595), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set toggles/volume variables">
                                <Event Name="Main.kodiupdatetoggles" />
                                <Action Name="Get/Set propeties mute, volume">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC2.JSONRPC(u\'Application.GetProperties\', u\'{"properties": ["volume", "muted", "name"]}\', False, True)\nvolume = str(int(p[\'volume\']))\neg.plugins.Webserver.SetValue(u\'kodiVolumeLevelChanged\', volume, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodiVolumeLevelChanged\')\nmute = str(p[\'muted\'])\neg.plugins.Webserver.SetValue(u\'kodimute\', mute, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodimute\')')
                                </Action>
                                <Action Name="Get player shuffle, repeat, speed, partymode">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = p[0][\'playerid\']\n    id = str(id)\n    type = p[0][\'type\']\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\nexcept IndexError:\n    id = "none"\n    print "id = None"\n    \nj = eg.plugins.XBMC2.JSONRPC(u\'Player.GetProperties\', u\'{"playerid": \' + id + \', "properties": ["repeat", "shuffled", "percentage", "position", "time", "totaltime", "type", "playlistid", "speed", "partymode"]}\', False, True)\nrepeat = str(j[\'repeat\'])\nshuffle = str(j[\'shuffled\'])\nspeed = str(j[\'speed\'])\npartymode = str(j[\'partymode\'])\n\neg.plugins.Webserver.SetValue(u\'kodishuffle\', shuffle, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodishuffle\')\neg.plugins.Webserver.SetValue(u\'kodirepeat\', repeat, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodirepeat\')\neg.plugins.Webserver.SetValue(u\'kodispeed\', speed, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodispeed\')\neg.plugins.Webserver.SetValue(u\'kodipartymode\', partymode, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodipartymode\')\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Kodi running status" id="634">
                                <Event Name="Main.OnInit" />
                                <Event Name=".WsClientConnected" />
                                <Event Name=".kodi" />
                                <Action>
                                    Window.FindWindow(u'Kodi.exe', None, None, None, None, None, False, 0.0, 2)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(438), 1, False)
                                </Action>
                                <Action Enabled="False">
                                    Window.BringToFront()
                                </Action>
                                <Action>
                                    Webserver.SetPersistentValue(u'kodirun_icon', u'True', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodirun_icon, kodiroom', None, u'', None)
                                </Action>
                                <Action Name="Get/Set active player">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = str(p[0][\'playerid\'])\n    type = p[0][\'type\']\n    eg.plugins.Webserver.SetPersistentValue(u\'kodiartactiveplayer\', id, False, False, 1)\n    if id == "0":\n        eg.TriggerEvent("kodiaucioplayeractive")\n        eg.TriggerEvent("kodi.hidedefaultplayback")\n    if id == "1":\n        eg.TriggerEvent("kodiVideoplayeractive")\n        eg.TriggerEvent("kodi.hidedefaultplayback")\nexcept IndexError:\n    id = "none"\n    eg.plugins.Webserver.SetPersistentValue(u\'kodiartactiveplayer\', "None", False, False, 1)\n    eg.TriggerEvent("kodishowdefaultplayback")\n')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Show/Hide Players">
                            <Macro Name="Hide Default Playback variables (When audio/video player are Active)">
                                <Event Name="Main.kodi.hidedefaultplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_player4holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player4holder', None, u'', None)
                                </Action>
                            </Macro>
                            <Macro Name="Show Default Playback variables (When no player is Active)" id="649">
                                <Event Name="Main.kodishowdefaultplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_player2holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player1holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player4holder', u'show', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player1holder, kodi_player2holder, kodi_player4holder', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StopKodiProgress', 0.0)
                                </Action>
                            </Macro>
                            <Macro Name="Hide Audio Playback variables (When video player is Active)">
                                <Event Name="Main.kodi.hideaudioplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_player1holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player1holder', None, u'', None)
                                </Action>
                            </Macro>
                            <Macro Name="Show Audio Playback variables (When video player is Inactive)">
                                <Event Name="Main.kodi.showaudioplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_playeractive', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player1holder', u'show', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_playeractive', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player1holder', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.GetValue(u'kodiplaypause', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "Paused"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StartKodiAudioProgress', 0.0)
                                </Action>
                            </Macro>
                            <Macro Name="Hide Video Playback variables (When audio player is Active)">
                                <Event Name="Main.kodi.hidevideoplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_player2holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player2holder', None, u'', None)
                                </Action>
                            </Macro>
                            <Macro Name="Show Video Playback variables (When audio player is Inactive)">
                                <Event Name="Main.kodi.showvideoplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_playeractive', u'show', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_playeractive', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player2holder', u'show', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiVideoinfoholder', u'show', False, True, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiVideoratingContainer', u'show', False, True, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiVideoprogressholder', u'show', False, True, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player2holder, kodiVideoratingContainer, kodiVideoinfoholder, kodiVideoprogressholder, kodi_playeractive', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.GetValue(u'kodiplaypause', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "Paused"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(709), 0, False)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StartKodiVideoProgress', 0.0)
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Get/Set Progress variables">
                            <Macro Name="Stop All Periodic Progress ">
                                <Event Name="Main.StopKodiProgress" />
                                <Event Name="Main.KodiClosed" />
                                <Action>
                                    Webserver.WsStopNamedBroadcastPeriodicTasks(u'kodiprogress')
                                </Action>
                            </Macro>
                            <Macro Name="Start Kodi Audio Progress Slider Periodic Broadcast">
                                <Event Name="Main.StartKodiAudioProgress" />
                                <Action>
                                    Webserver.WsStopNamedBroadcastPeriodicTasks(u'kodiprogress')
                                </Action>
                                <Action>
                                    Webserver.WsPeriodicallyBroadcastData(u'kodiprogress', u'{"kodiprogress", str(eg.globals.getkodi_progress()[\'Progress\']) + "||" + str(eg.globals.getkodi_progress()[\'timeElapsed\']) + "||" + str(eg.globals.getkodi_progress()[\'timeRemain\'])}', u'', False, 1.0)
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Videoprogress variables">
                                <Event Name="Main.StartKodiVideoProgress" />
                                <Action>
                                    Webserver.WsStopNamedBroadcastPeriodicTasks(u'kodiprogress')
                                </Action>
                                <Action>
                                    Webserver.WsPeriodicallyBroadcastData(u'kodiprogress', u'{"kodiVideoprogress", str(eg.globals.getkodi_progress()[\'Progress\']) + "||" + str(eg.globals.getkodi_progress()[\'timeElapsed\']) + "||" + str(eg.globals.getkodi_progress()[\'timeRemain\'])}', u'', False, 1.0)
                                </Action>
                            </Macro>
                        </Folder>
                        <Macro Name="Set playlist edit mode">
                            <Event Name="kodi.editplaylist" />
                            <Action>
                                EventGhost.PythonScript(u'import urllib2\ntry:\n    p = eg.plugins.XBMC2.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\nexcept urllib2.HTTPError, e:\n    print e.code\n    eg.Triggerevent("KodiClosed")\nexcept urllib2.URLError, e:\n    print e.args\n    eg.TriggerEvent("KodiClosed")\n\ntry:\n    kodiplayerid = str(p[0][\'playerid\'])\n    eg.plugins.Webserver.SetValue(u\'kodiplayerid\', kodiplayerid, False, False, 1)\n    type = p[0][\'type\']\nexcept IndexError:\n    eg.plugins.Webserver.SetValue(u\'kodiplayerid\', u\'none\', False, False, 1)\n    print "id = None"\n    \nstate = eg.plugins.Webserver.GetPersistentValue(u\'kodi_playlistedit\', False)\n\nif state == "True":\n    eg.plugins.Webserver.SetPersistentValue(u\'kodi_playlistedit\', u\'False\', False, False, 1)\nelif state == "False":\n    eg.plugins.Webserver.SetPersistentValue(u\'kodi_playlistedit\', u\'True\', False, False, 1)\neg.plugins.Webserver.BroadcastValue(u\'kodi_playlistedit\', None, u\'\', None)')
                            </Action>
                            <Action>
                                Webserver.GetValue(u'kodiplayerid', False)
                            </Action>
                            <Action>
                                EventGhost.PythonCommand(u'eg.result == "0"')
                            </Action>
                            <Action>
                                EventGhost.NewJumpIf(XmlIdLink(587), 0, False)
                            </Action>
                            <Action>
                                Webserver.GetValue(u'kodiplayerid', False)
                            </Action>
                            <Action>
                                EventGhost.PythonCommand(u'eg.result == "1"')
                            </Action>
                            <Action>
                                EventGhost.NewJumpIf(XmlIdLink(595), 0, False)
                            </Action>
                        </Macro>
                        <Macro Name="Null macro" id="709" />
                    </Folder>
                </Folder>
                <Folder Name="Bedroom (XBMC2 #2)" id="710" Enabled="False">
                    <Macro Name="Webserver: Set temporary value: kodiplaypause:">
                        <Event Name="Main.OnInit" />
                        <Action>
                            EventGhost.PythonScript(u'p = eg.plugins.XBMC2.JSONRPC(u\'Player.GetProperties\', u\'{"playerid": 0, "properties": ["speed", "audiostreams"]}\', True, True)\nspeed = str(p[\'speed\'])\nif speed != "0":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', u\'Playing\', False, False, 1)\nelse:\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', u\'Paused\', False, False, 1)')
                        </Action>
                    </Macro>
                    <Folder Name="Actions">
                        <Folder Name="System (Popup)">
                            <Macro Name="Switch Kodi Device Control (Swith Room)">
                                <Event Name="input.Kodi_Room" />
                                <Action>
                                    EventGhost.PythonScript(u'p = eg.event.payload\nif p == "kodi.Basement":\n    eg.plugins.EventGhost.TriggerEvent(u\'kodi.basement\', 0.0)\n    eg.plugins.Webserver.SetPersistentValue(u\'kodiroom\', "Basement", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiroom\')\nif p == "kodi.Bedroom":\n    eg.plugins.EventGhost.TriggerEvent(u\'kodi.bedroom\', 0.0)\n    eg.plugins.Webserver.SetPersistentValue(u\'kodiroom\', "Bedroom", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiroom\')')
                                </Action>
                            </Macro>
                            <Macro Name="Kodi: Start">
                                <Event Name=".start_kodi" />
                                <Action Enabled="False">
                                    System.Execute(u'C:\\Program Files (x86)\\Kodi\\Kodi.exe', u'', 0, False, 2, u'', False, True, u'', False, False, False, True)
                                </Action>
                                <Action>
                                    Webserver.SetPersistentValue(u'kodirun_icon', u'True', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodirun_icon', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.Wait(0.5)
                                </Action>
                                <Action>
                                    Window.FindWindow(u'Kodi.exe', None, None, None, None, None, False, 0.0, 0)
                                </Action>
                                <Action>
                                    Window.BringToFront()
                                </Action>
                            </Macro>
                            <Macro Name="Kodi: Quit">
                                <Event Name=".close_kodi" />
                                <Action>
                                    XBMC2.Quit()
                                </Action>
                                <Action Enabled="False">
                                    System.Command(u'taskkill /IM Kodi.exe /F', False, False, u'', True, False, False, True, False)
                                </Action>
                                <Action>
                                    Webserver.SetPersistentValue(u'kodirun_icon', u'False', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodirun_icon', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1114), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: UpdateLibrary: Audio">
                                <Event Name=".Update_kodiAudio" />
                                <Action>
                                    XBMC22.UpdateLibrary(u'Audio', u'')
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: UpdateLibrary: Video">
                                <Event Name=".Update_kodiVideo" />
                                <Action>
                                    XBMC22.UpdateLibrary(u'Video', u'')
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Set Audio Output">
                                <Event Name="input.Kodi_AudioSource" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', True)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action>
                                    EventGhost.PythonScript(u'payload = eg.event.payload\nif payload == "kodi.Audio.HDMI":\n    eg.plugins.XBMC22.JSONRPC(u\'Settings.SetSettingValue\', u\'{"setting":\\\'audiooutput.audiodevice\\\', \\\'value\\\':\\\'WASAPI:{6F356A63-8017-4A66-989D-4B81965D46BC}\\\'}\', False, True)\nif payload == "kodi.Audio.SPDIF":\n    eg.plugins.XBMC22.JSONRPC(u\'Settings.SetSettingValue\', u\'{"setting":\\\'audiooutput.audiodevice\\\', \\\'value\\\':\\\'DIRECTSOUND:{7FB3A4CE-1F8C-46F4-87A4-B7D7652890FA}\\\'}\', False, True)')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="D-Pad">
                            <Macro Name="XBMC2: Left">
                                <Event Name="kodi.left" />
                                <Action>
                                    XBMC22.RemoteLeft()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Right">
                                <Event Name="kodi.right" />
                                <Action>
                                    XBMC22.RemoteRight()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Up">
                                <Event Name="kodi.up" />
                                <Action>
                                    XBMC22.RemoteUp()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Down">
                                <Event Name="kodi.down" />
                                <Action>
                                    XBMC22.RemoteDown()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Select">
                                <Event Name="kodi.enter" />
                                <Action>
                                    XBMC22.RemoteSelect()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Back">
                                <Event Name="kodi.back" />
                                <Action>
                                    XBMC22.RemoteBack()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Menu">
                                <Event Name="kodi.menu" />
                                <Action>
                                    XBMC22.RemoteMenu()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Display">
                                <Event Name="kodi.title" />
                                <Action>
                                    XBMC22.RemoteTitle()
                                </Action>
                            </Macro>
                            <Macro Name="Toggle fullscreen">
                                <Event Name="kodi.fullscreentoggle" />
                                <Action>
                                    EventGhost.PythonScript(u'state = eg.plugins.XBMC22.JSONRPC(u\'Settings.GetSettingValue\', u\'{"setting":\\\'videoscreen.screen\\\'}\', False, True)\nif state[\'value\'] == -1:\n    eg.plugins.XBMC22.JSONRPC(u\'Settings.SetSettingValue\', u\'{"setting":\\\'videoscreen.screen\\\', \\\'value\\\':0}\', True, True)\nif state[\'value\'] == 0:\n    eg.plugins.XBMC22.JSONRPC(u\'Settings.SetSettingValue\', u\'{"setting":\\\'videoscreen.screen\\\', \\\'value\\\':-1}\', True, True)')
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: PageUp">
                                <Event Name="kodi.pageup" />
                                <Action>
                                    XBMC22.Remotepageplus()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: PageDown">
                                <Event Name="kodi.pagedown" />
                                <Action>
                                    XBMC22.Remotepageminus()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Music">
                                <Event Name="kodi.musicpage" />
                                <Action>
                                    XBMC22.Music()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Show TV Shows Screen">
                                <Event Name="kodi.tvshowspage" />
                                <Action>
                                    XBMC22.MyTVShows()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Favourites">
                                <Event Name="kodi.favorites" />
                                <Action>
                                    XBMC22.Favourites()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Show Movies Screen">
                                <Event Name="kodi.moviespage" />
                                <Action>
                                    XBMC22.MyMovies()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Show Home Screen">
                                <Event Name="kodi.home" />
                                <Action>
                                    XBMC22.Home()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Show Systemsettings Screen">
                                <Event Name="kodi.settings" />
                                <Action>
                                    XBMC22.Settings()
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Playback">
                            <Macro Name="XBMC2: Rewind">
                                <Event Name="kodi.kodirwnd" />
                                <Action>
                                    XBMC22.RemoteReverse()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: SkipPrevious">
                                <Event Name="kodi.kodiprev" />
                                <Action>
                                    XBMC22.RemoteSkipMinus()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Play/Pause">
                                <Event Name="kodi.kodiplaypaused" />
                                <Action Name="Get/Set Play/Pause">
                                    EventGhost.PythonScript(u'state = eg.plugins.Webserver.GetValue(u\'kodiplaypause\', False)\nif state == None:\n    state = "Playing"\nif state == "Playing":\n    eg.plugins.XBMC22.Pause()\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Paused", False, False)\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', u\'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', u\'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\nelif state == "Paused":\n    eg.plugins.XBMC22.Play()\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', u\'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', u\'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\n\nelif state == "Stopped":\n    eg.plugins.XBMC22.Play()\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', u\'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', u\'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\', False, False, 1)\neg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\neg.plugins.Webserver.BroadcastValue(u\'kodileftRating\', None, u\'\', None)\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoleftRating\', None, u\'\', None)')
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Stop">
                                <Event Name="kodi.stop" />
                                <Action>
                                    XBMC22.RemoteStop()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: SkipNext">
                                <Event Name="kodi.kodinext" />
                                <Action>
                                    XBMC22.RemoteSkipPlus()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: FastForward">
                                <Event Name="kodi.kodiffwd" />
                                <Action>
                                    XBMC22.RemoteForward()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Mute">
                                <Event Name="kodi.kodimuted" />
                                <Action>
                                    XBMC22.RemoteMute()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Repeat">
                                <Event Name="kodi.kodirepeated" />
                                <Action>
                                    XBMC22.Repeat()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Shuffle">
                                <Event Name="kodi.kodishuffled" />
                                <Action>
                                    XBMC22.Random()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Party Mode">
                                <Event Name="kodi.partymode" />
                                <Action>
                                    XBMC22.PartyMode()
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Set Volume">
                                <Event Name="Volume.kodiVolumeLevelChanged" />
                                <Action Name="Get/Set current playback info">
                                    EventGhost.PythonScript(u"payload = str(eg.event.payload)\neg.plugins.XBMC22.JSONRPC(u'Application.SetVolume', '['  + payload + ']', False, True)\n")
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Set progress">
                                <Event Name="kodi.kodiprogress" />
                                <Event Name="kodi.kodiVideoprogress" />
                                <Action Name="Set progress">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC22.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\npayload = str(eg.event.payload)\ntry:\n    id = str(p[0][\'playerid\'])\n    type = p[0][\'type\']\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\neg.plugins.XBMC22.JSONRPC(u\'Player.Seek\', u\'{"playerid": \' + id + \', "value":{ "percentage":\' + payload + \'}}\', False, True)')
                                </Action>
                            </Macro>
                            <Macro Name="XBMC2: Set rating">
                                <Event Name="kodi.star*" />
                                <Event Name="kodi.star5" />
                                <Event Name="kodi.star4" />
                                <Event Name="kodi.star3" />
                                <Event Name="kodi.star2" />
                                <Event Name="kodi.star1" />
                                <Action Name="Get/Set rating">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC22.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\nsuffix = str(eg.event.suffix)\nsuffix = suffix.split(\'star\')\nsuffix = suffix[1]\n\ntry:\n    id = p[0][\'playerid\']\n    id = str(id)\n    type = p[0][\'type\']\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\nif id != "none":\n    current = eg.plugins.XBMC22.JSONRPC(u\'Player.GetItem\', u\'{ "properties": ["title", "album", "artist", "duration", "year", "rating", "playcount", "genre", "thumbnail", "file", "fanart", "streamdetails"], "playerid":\' + id + \'}\', False, True)\n    id = str(current[\'item\'][\'id\'])\n    type = str(current[\'item\'][\'type\'])\n    if type == "song":\n        eg.plugins.XBMC22.JSONRPC(u\'AudioLibrary.SetSongDetails\', u\'{"songid":\' + id + \', "rating":\' + suffix + \'}\', True, True)\n        eg.plugins.Webserver.SetValue(u\'kodirating\', suffix, False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'kodirating\')\n    if type == "episode":\n        eg.plugins.XBMC22.JSONRPC(u\'VideoLibrary.SetEpisodeDetails\', u\'{"episodeid":\' + id + \', "rating":\' + suffix + \'}\', True, True)\n        eg.plugins.Webserver.SetValue(u\'kodiVideorating\', suffix, False, False)\n        suffix = str(int(suffix) * 2)\n        eg.plugins.Webserver.BroadcastValue(u\'kodiVideorating\')\n    if type == "movie":\n        eg.plugins.Webserver.SetValue(u\'kodiVideorating\', suffix, False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'kodiVideorating\')\n        suffix = str(int(suffix) * 2)\n        eg.plugins.XBMC22.JSONRPC(u\'VideoLibrary.SetMovieDetails\', u\'{"movieid":\' + id + \', "rating":\' + suffix + \'}\', True, True)\n    \n    eg.plugins.Webserver.SetValue(u\'kodirating\', suffix, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodirating\')\n')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Play File">
                            <Macro Name="Play Movie">
                                <Event Name="kodi.Movies" />
                                <Action Name="Resume Movie">
                                    EventGhost.PythonScript(u'payload = eg.event.payload\neg.plugins.XBMC22.JSONRPC(u\'Player.Open\', u\'{"item":{"movieid":\' + payload + \'}, "options":{"resume":True}}\', False, True)')
                                </Action>
                                <Action Name="Play Movie" Enabled="False">
                                    EventGhost.PythonScript(u'payload = eg.event.payload\neg.plugins.XBMC22.JSONRPC(u\'Player.Open\', u\'{"item":{"movieid":\' + payload + \'}}\', False, True)')
                                </Action>
                            </Macro>
                            <Macro Name="Play TV Episode">
                                <Event Name="kodi.Episode" />
                                <Action Name="Playback episode (&amp; all subsequent episodes in the Season)">
                                    EventGhost.PythonScript(u'payload = str(eg.event.payload)\n\neg.plugins.XBMC22.JSONRPC(u\'Playlist.Clear\', u\'{"playlistid":1}\', False, True)\neg.plugins.XBMC22.JSONRPC(u\'Player.Open\', u\'{"item":{"episodeid":\' + payload + \'}, "options":{"resume":True}}\', False, True)\n\n\nx = eg.plugins.XBMC22.JSONRPC(u\'VideoLibrary.GetEpisodeDetails\', u\'{"episodeid":\' + payload + \', "properties": ["season", "episode", "tvshowid"]}\', False, True)\n\nepisodenum = str(x[\'episodedetails\'][\'episode\'])\nepisodeid  = str(x[\'episodedetails\'][\'episodeid\'])\nseasonnum = str(x[\'episodedetails\'][\'season\'])\nshowid = str(x[\'episodedetails\'][\'tvshowid\'])\n\nu = eg.plugins.XBMC22.JSONRPC(u\'VideoLibrary.GetEpisodes\', u\'{ "tvshowid": \' + showid + \', "season": \' + seasonnum + \', "properties": ["episode"]}\', False, True)\nepisodenum = int(episodenum)\nfor item in u[\'episodes\']:\n    episodeplaylistnum = int(item[\'episode\'])\n    episodeplaylistid = int(item[\'episodeid\'])\n    if episodeplaylistnum &gt; episodenum:\n        eg.plugins.XBMC22.JSONRPC(u\'Playlist.Add\', u\'{"playlistid":1,"item":{"episodeid":\' + str(episodeplaylistid) + \'}}\', False, True)\n')
                                </Action>
                                <Action Name="Playback episode (single)" Enabled="False">
                                    EventGhost.PythonScript(u'payload = str(eg.event.payload)\neg.plugins.XBMC22.JSONRPC(u\'Player.Open\', u\'{"item":{"episodeid":\' + payload + \'}, "options":{"resume":True}}\', False, True)')
                                </Action>
                            </Macro>
                            <Macro Name="Tune Channel">
                                <Event Name="kodi.Channel" />
                                <Action Name="Play Channel">
                                    EventGhost.PythonScript(u'channel = eg.event.payload\neg.plugins.XBMC22.JSONRPC(u\'Player.Open\', u\'{"item":{"channelid":\' + channel + \'}}\', True, True)\neg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n\n')
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodichannelchanged', 3.0)
                                </Action>
                            </Macro>
                            <Macro Name="Start Playlist">
                                <Event Name="kodi.Playlist" />
                                <Action Name="Start Playlist">
                                    EventGhost.PythonScript(u'playlist = str(eg.event.payload)\neg.plugins.XBMC22.JSONRPC(u\'Player.Open\', u\'{"item":{"file":"\' + playlist + \'"}}\', True, True)')
                                </Action>
                            </Macro>
                            <Macro Name="Play Album">
                                <Event Name="kodi.Album" />
                                <Action Name="Play Album">
                                    EventGhost.PythonScript(u'album = eg.event.payload\neg.plugins.XBMC22.JSONRPC(u\'Player.Open\', u\'{"item":{"albumid":\' + album + \'}}\', True, True)\neg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n\n')
                                </Action>
                            </Macro>
                            <Macro Name="Play Song in Current Playlist">
                                <Event Name="kodi.playlisttrack" />
                                <Action Name="GoTo Playlist #">
                                    EventGhost.PythonScript(u'player = str(eg.plugins.Webserver.GetPersistentValue(u\'kodiactiveplayer\', False))\ntrack = str(int(eg.event.payload) - 1)\n\neg.plugins.XBMC22.JSONRPC(u\'Player.GoTo\', u\'{"playerid":\' + player + \', "to": \' + track + \'}\', False, True)')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Playlist manipulation Audio" id="866">
                            <Macro Name="Add selected songs to Current Playlist">
                                <Event Name="kodicheckedsongs.addtoplaylist" />
                                <Action Name="add songs to current playlist">
                                    EventGhost.PythonScript(u'pay = eg.event.payload\npayload = pay.split(\',\')\ncurrent = eg.plugins.XBMC22.JSONRPC(u\'Playlist.GetItems\', u\'{"playlistid":0, "properties": ["title"]}\', False, True)\neg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Songs Added to the Playlist", False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\nsongs = []\nfor song in payload[:-1]:\n    song = str(song)\n    eg.plugins.XBMC22.JSONRPC(u\'Playlist.Add\', u\'{"playlistid":0,"item":{"songid":\' + song + \'}}\', False, True)\nelse:\n    x = ""\n    ')
                                </Action>
                            </Macro>
                            <Macro Name="Create new playlist from selected songs">
                                <Event Name="kodicheckedsongsnew.addtoplaylist" />
                                <Action Name="Create new playlist">
                                    EventGhost.PythonScript(u'pay = eg.event.payload\npayload = pay.split(\',\')\neg.plugins.XBMC22.JSONRPC(u\'Playlist.Clear\', u\'{"playlistid":0}\', False, True)\neg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Songs Added to a new playlist", False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\nsongs = []\nfor song in payload[:-1]:\n    song = str(song)\n    eg.plugins.XBMC22.JSONRPC(u\'Playlist.Add\', u\'{"playlistid":0,"item":{"songid":\' + song + \'}}\', False, True)\nelse:\n    x = ""')
                                </Action>
                            </Macro>
                            <Macro Name="Delete Playlist item">
                                <Event Name="kodidelete.*" />
                                <Action Name="Delete playlist item">
                                    EventGhost.PythonScript(u'if eg.event.payload == "undefined":\n    payload = "0"\nelse:\n    payload = str(int(eg.event.payload) - 1)\neg.plugins.XBMC22.JSONRPC(u\'Playlist.Remove\', u\'{"playlistid":0, "position":\' + payload + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1057), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Move Playlist item Up">
                                <Event Name="kodimoveup.*" />
                                <Action Name="Move playlist item Up">
                                    EventGhost.PythonScript(u'pos1 = str(int(eg.event.payload) - 1)\npos2 = str(int(eg.event.payload) - 2)\n\neg.plugins.XBMC22.JSONRPC(u\'Playlist.Swap\', u\'{"playlistid":0, "position1":\' + pos1 + \', "position2":\' + pos2 + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1057), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Move Playlist item Down">
                                <Event Name="kodimovedown.*" />
                                <Action Name="Move playlist item Down">
                                    EventGhost.PythonScript(u'if eg.event.payload == "undefined":\n    eg.event.payload = 0\npos1 = str(int(eg.event.payload) - 1)\n\neg.plugins.XBMC22.JSONRPC(u\'Playlist.Swap\', u\'{"playlistid":0, "position1":\' + pos1 + \', "position2":\' + pos2 + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1057), 2, False)
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Playlist manipulation Video" id="885" Enabled="False">
                            <Macro Name="Delete Playlist item">
                                <Event Name="kodidelete.*" />
                                <Action Name="Delete playlist item">
                                    EventGhost.PythonScript(u'if eg.event.payload == "undefined":\n    payload = "0"\nelse:\n    payload = str(int(eg.event.payload) - 1)\neg.plugins.XBMC22.JSONRPC(u\'Playlist.Remove\', u\'{"playlistid":1, "position":\' + payload + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1065), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Move Playlist item Up">
                                <Event Name="kodimoveup.*" />
                                <Action Name="Move playlist item Up">
                                    EventGhost.PythonScript(u'pos1 = str(int(eg.event.payload) - 1)\npos2 = str(int(eg.event.payload) - 2)\n\neg.plugins.XBMC22.JSONRPC(u\'Playlist.Swap\', u\'{"playlistid":1, "position1":\' + pos1 + \', "position2":\' + pos2 + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1065), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Move Playlist item Down">
                                <Event Name="kodimovedown.*" />
                                <Action Name="Move playlist item Down">
                                    EventGhost.PythonScript(u'if eg.event.payload == "undefined":\n    eg.event.payload = 0\npos1 = str(int(eg.event.payload) - 1)\npos2 = str(eg.event.payload)\n\neg.plugins.XBMC22.JSONRPC(u\'Playlist.Swap\', u\'{"playlistid":1, "position1":\' + pos1 + \', "position2":\' + pos2 + \'}\', True, True)')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1065), 2, False)
                                </Action>
                            </Macro>
                        </Folder>
                    </Folder>
                    <Folder Name="Get/Set Variables">
                        <Folder Name="Plugin Events">
                            <Macro Name="Kodi System (start)">
                                <Event Name="Process.Created.Kodi" Enabled="False" />
                                <Event Name="XBMC22.System.OnStart" />
                                <Action>
                                    Webserver.SetPersistentValue(u'kodirun_icon', u'True', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiartist4', u'No Active Playback', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodicoverart4', u' &lt;a id="kodi.reloadtracks" name="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" href="#kodiplaylist"&gt;&lt;img style="text-align:center;" id="kodiart" src="/images/m_icon.png" width="250" height="250" alt=""/&gt;&lt;/a&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodirun_icon, kodiroom, kodiartist4, kodicoverart4', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1104), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Kodi System Change (quit)">
                                <Event Name="Process.Destroyed.Kodi" Enabled="False" />
                                <Event Name="XBMC22.System.OnQuit" />
                                <Action>
                                    Webserver.SetPersistentValue(u'kodirun_icon', u'False', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiartist', u'Kodi is Closed', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiartist2', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiartist4', u'Kodi is Closed', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodialbum', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiyear', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'koditrackTitle', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiplaypause', u'Paused', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiprogress', u'0', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiprogress_remain', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiprogress_start', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'koditrackplaycount', u'', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodicoverart', u' &lt;a id="kodi.reloadtracks" name="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" href="#kodiplaylist"&gt;&lt;img style="text-align:center;" id="kodiart" src="/images/Tracks_icon.png" width="250" height="250" alt=""/&gt;&lt;/a&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodicoverart4', u' &lt;a id="kodi.reloadtracks" name="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" href="#kodiplaylist"&gt;&lt;img style="text-align:center;" id="kodiart" src="/images/Tracks_icon.png" width="250" height="250" alt=""/&gt;&lt;/a&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodileftRating', u'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiartist, kodialbum, kodiplaypause, koditrackTitle, kodirun_icon, koditrackplaycount, kodiprogress, kodiprogress_start, kodiprogress_remain, kodiyear, kodileftRating, kodicoverart, koditracktype, kodiroom', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiartist4, kodiartist2, kodicoverart4', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StopKodiProgress', 0.0)
                                </Action>
                            </Macro>
                            <Macro Name="Kodi Application Change (volume/mute)">
                                <Event Name="XBMC22.Application.OnVolumeChanged" />
                                <Action>
                                    Webserver.SetValue(u'kodiVolumeLevelChanged', u"{str(int(eg.event.payload['volume']))}", False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodimute', u"{str(eg.event.payload['muted'])}", False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiVolumeLevelChanged', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodimute', None, u'', None)
                                </Action>
                            </Macro>
                            <Macro Name="Kodi Property Change (repeat/shuffle/partymode)">
                                <Event Name="XBMC22.Player.OnPropertyChanged" />
                                <Action>
                                    EventGhost.PythonScript(u'p = eg.event.payload[\'property\']\nkey = p.keys()[0]\nvalue = str(p.values()[0])\n\nif key == "shuffled":\n    key = "shuffle"\nname = "kodi" + key\neg.plugins.Webserver.SetValue(name, value, False, False, 1)\neg.plugins.Webserver.BroadcastValue(name, None, u\'\', None)\n')
                                </Action>
                            </Macro>
                            <Macro Name='Kodi Player Change ("play" song)'>
                                <Event Name="XBMC22.Player.OnPlay.song" />
                                <Action>
                                    Webserver.SetValue(u'kodiplaypause', u'Playing', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetPersistentValue(u'kodiactiveplayer', u'0', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiplaypause, kodiactiveplayer', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StartKodiAudioProgress', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1072), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name='Kodi Player Change ("play" movie/tvepisode)'>
                                <Event Name="XBMC22.Player.OnPlay.episode" />
                                <Event Name="XBMC22.Player.OnPlay.movie" />
                                <Event Name="XBMC22.Player.OnPlay.channel" />
                                <Action>
                                    Webserver.SetValue(u'kodiplaypause', u'Playing', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetPersistentValue(u'kodiactiveplayer', u'1', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiplaypause, kodiactiveplayer', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StartKodiVideoProgress', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1086), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Kodi Player Change (Seek Position)">
                                <Event Name="XBMC22.Player.OnSeek.song" />
                            </Macro>
                            <Macro Name="Kodi Player Change (paused)">
                                <Event Name="XBMC22.Player.OnPause.song" />
                                <Event Name="XBMC22.Player.OnPause.movie" />
                                <Event Name="XBMC22.Player.OnPause.episode" />
                                <Action>
                                    Webserver.SetValue(u'kodileftRating', u'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiVideoleftRating', u'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiplaypause', u'Paused', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiplaypause', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodileftRating', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodiVideoleftRating', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StopKodiProgress', 0.0)
                                </Action>
                            </Macro>
                            <Macro Name="Kodi Player Change (stopped)">
                                <Event Name="XBMC22.Player.OnStop.song" />
                                <Event Name="XBMC22.Player.OnStop.episode" />
                                <Event Name="XBMC22.Player.OnStop.movie" />
                                <Event Name="XBMC22.Player.OnStop.channel" />
                                <Action>
                                    EventGhost.Wait(1.0)
                                </Action>
                                <Action Name="Get Playstate">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC22.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = str(p[0][\'playerid\'])\n    type = p[0][\'type\']\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\ntry:\n    u = eg.plugins.XBMC22.JSONRPC(u\'Player.GetProperties\', u\'{"playerid":\' + id + \', "properties": [\\\'speed\\\']}\', False, True)\n    speed = str(u[\'speed\'])\nexcept ValueError:\n    speed = "0"\nif speed != "0":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', u\'Playing\', False, False, 1)\nelse:\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', u\'Paused\', False, False, 1)')
                                </Action>
                                <Action>
                                    Webserver.GetValue(u'kodiplaypause', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "Playing"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiplaypause', u'Paused', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player1holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player2holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player3holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player4holder', u'show', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodileftRating', u'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u' kodiplaypause, kodileftRating, kodi_player1holder, kodi_player2holder, kodi_player3holder, kodi_player4holder', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StopKodiProgress', 0.0)
                                </Action>
                            </Macro>
                            <Macro Name="Start playlist when new songs added">
                                <Event Name="XBMC22.Playlist.OnAdd.song" />
                                <Action Name="Start playlist">
                                    EventGhost.PythonScript(u'size = eg.event.payload[\'position\']\nif size == 0:\n    eg.plugins.XBMC22.JSONRPC(u\'Player.Open\', u\'{"item":{"playlistid":0}}\', False, True)')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Build Menus' (Broadcast Data) New http and cache">
                            <Macro Name="Get/Set Genres">
                                <Event Name="kodi.updatekodigenre" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get genres">
                                    EventGhost.PythonScript(u'getcount = "True"\nx = eg.plugins.XBMC22.JSONRPC(u\'AudioLibrary.GetGenres\', u\'{"properties": ["thumbnail"]}\', False, True)\ngenres = []\nfor item in x[\'genres\']:\n    genre = item[\'label\']\n    if getcount == "True":\n        x = eg.plugins.XBMC22.JSONRPC(u\'AudioLibrary.GetArtists\', u\'{ "filter": {"field": "genre", "operator": "is", "value": "\' + genre + \'"}, "limits": { "start" : 0, "end": 1000 }, "sort": { "order": "ascending", "method": "track" } }\', False, True)\n        total = str(x[\'limits\'][\'total\'])\n    else:\n        total = ""\n    thumbnail = item[\'thumbnail\']\n    Payload = {}\n    Payload = [genre + \'||\' + total + \'||\' + \'\' + \'||\' + \'\' + \'||\' + \'\' + \'||\' + \'\']\n    genres.append(Payload)\n\ngenres= str(genres)\ngenresfull = "    " + genres\neg.plugins.Webserver.WsBroadcastData(u\'kodigenres\', genresfull, u\'\', None, None)\neg.plugins.Webserver.SetValue(u\'kodiplaylistli\', "Playing", False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodiplaylistli\')')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Artist by Genre">
                                <Event Name="kodi.Genres" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', True)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get artist filtered by genre">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaultartistthumb\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\ngetcount = "False"\ngenre = eg.event.payload\nx = eg.plugins.XBMC22.JSONRPC(u\'AudioLibrary.GetArtists\', u\'{ "filter": {"field": "genre", "operator": "is", "value": "\' + genre + \'"}, "limits": { "start" : 0, "end": 500 }, "properties": [ "thumbnail", "fanart", "born", "formed", "died", "disbanded", "yearsactive", "mood", "style", "genre"], "sort": { "order": "ascending", "method": "artist" }  }\', False, True)\nartists = []\nfor item in x[\'artists\']:\n    artist = item[\'label\']\n    if getcount == "True":\n        x = eg.plugins.XBMC22.JSONRPC(u\'AudioLibrary.GetAlbums\', u\'{ "filter": {"field": "artist", "operator": "is", "value": "\' + artist + \'"}, "limits": { "start" : 0, "end": 200 }, "properties": ["title"], "sort": { "order": "ascending", "method": "track" } }\', False, True)\n        total = str(x[\'limits\'][\'total\'])\n    else:\n        total = "0"\n    artistid = str(item[\'artistid\'])\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sdfsdfs//sdfs/dfsdf/fgd"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        artwork = urllib2.unquote(cover[0]).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + artist + \'.jpg\'\n        cached = os.path.exists(directory + artist + \'.jpg\')\n        if cached != False:\n            artwork = artwork\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + artist + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + artist + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/a_icon.png\'\n            except IndexError:\n                try:\n                    cover = thumb[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/a_icon.png\'\n    Payload = {}\n    Payload = [artist + \'||\' + artwork + \'||\' + artistid + \'||\' + genre + \'||\' + artistid + \'||\' + total]\n    artists.append(Payload)\nartists = str(artists)\nartistsfull = "    " + artists\neg.plugins.Webserver.WsBroadcastData(u\'kodiartists\', artistsfull, u\'\', None, None)\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Album by Artist">
                                <Event Name="kodi.Artist" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get albums filtered by artist">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nartist = str(eg.event.payload)\nx = eg.plugins.XBMC22.JSONRPC(u\'AudioLibrary.GetAlbums\', u\'{ "filter": {"field": "artist", "operator": "is", "value": "\' + artist + \'"}, "limits": { "start" : 0, "end": 50 }, "properties": ["playcount", "artist", "genre", "rating", "thumbnail", "year", "fanart"], "sort": { "order": "ascending", "method": "album" } }\', False, True)\nalbums = [] \n\nfor item in x[\'albums\']:\n    artist = str(item[\'artist\'][0])\n    try:\n        fanart = \'images/kodiart/\' +  artist + " - fanart.jpg"\n    except KeyError:\n        fanart = ""\n    try:\n        album = str(item[\'label\'])\n    except UnicodeEncodeError:\n        album = ""\n    try:\n        genre = item[\'genre\'][0]\n    except KeyError:\n        genre = "Unknown"\n    try:\n        rating = int(item[\'rating\'])\n        if rating &lt;= 0:\n            rating = "0"\n    except KeyError:\n        rating = "0"\n    rating = str(rating)\n    year = str(item[\'year\'])\n    playcount = item[\'playcount\']\n    albumid = str(item[\'albumid\'])\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sfsfsa//sfsda/f"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        fanart = item[\'fanart\']\n    except KeyError:\n        fanart = "sfsfsa//sfsda/f"\n    fanart = fanart.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n        c = fanart[1].startswith( \'http\' )\n        d = fanart[1].endswith( \'/\' )\n    except IndexError:\n\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n        c = fanart[0].startswith( \'http\' )\n        d = fanart[0].endswith( \'/\' )\n\n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n        fancover = fanart[1].rsplit("/", 1)\n        fancover = str(fancover[0])\n        fanwork = urllib2.unquote(fancover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n        cachedfanart = os.path.exists(directory + artist + \' - fanart.jpg\')\n        if cachedart != False:\n            artwork = artwork\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                try:\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except UnicodeEncodeError:\n                    artwork = \'images/M_icon.png\'\n                \n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n            except IndexError:\n                try:\n                    cover = thumb[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n        \n        if cachedfanart != False:\n            fanwork = fanwork\n        else:\n            try:\n                cover = fanart[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + artist + \' - fanart.jpg\'\n                try:\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    try:\n                        cover = fanart[1].rsplit("/", 1)\n                        cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                        cover = cover.split(":", 1)\n                        srcfile = str(cover[1])\n                        dstdir = directory + artist + \' - fanart.jpg\'\n                        shutil.copy(srcfile, dstdir)\n                        print "cached image: " + dstdir\n                    except IOError:\n                        fanwork = \'images/f_icon.png\'\n                \n            except IndexError:\n                try:\n                    cover = fanart[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n\n                except IOError:\n                    fanwork = \'images/f_icon.png\'\n    Payload = {}\n    Payload = [album + \'||\' + artwork + \'||\' + artist + \'||\' + year + \'||\' + albumid + \'||\' + rating]\n    albums.append(Payload)\n\nalbumsfull = "    " + str(albums)\nx = eg.plugins.XBMC22.JSONRPC(u\'AudioLibrary.GetSongs\', u\'{ "filter": {"field": "artist", "operator": "is", "value": "\' + artist + \'"}, "limits": { "start" : 0, "end": 500 }, "properties": ["playcount", "album", "artist", "genre", "rating", "thumbnail", "year", "fanart"], "sort": { "order": "ascending", "method": "album" } }\', False, True)\ntotal = str(x[\'limits\'][\'total\'])\nfanwork = fanwork + \'||\' + artist + \'||\' + total\n\neg.plugins.Webserver.WsBroadcastData(u\'kodialbums\', albumsfull, u\'\', None, None)\neg.plugins.Webserver.SetValue(u\'kodisongplay\', artist, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodisongplay\')\neg.plugins.Webserver.SetValue(u\'kodialbumul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodialbumul\')\n\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Songs by Artist">
                                <Event Name="kodi.songs" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get songs filtered by artist">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nartist = str(eg.event.payload)\nx = eg.plugins.XBMC22.JSONRPC(u\'AudioLibrary.GetSongs\', u\'{ "filter": {"field": "artist", "operator": "is", "value": "\' + artist + \'"}, "limits": { "start" : 0, "end": 500 }, "properties": ["playcount", "album", "artist", "genre", "rating", "thumbnail", "year", "fanart"], "sort": { "order": "ascending", "method": "album" } }\', False, True)\nsongs = [] \n\nfor item in x[\'songs\']:\n    artist = str(item[\'artist\'][0])\n    try:\n        fanart = \'images/kodiart/\' +  artist + " - fanart.jpg"\n    except KeyError:\n        fanart = ""\n    try:\n        song = str(item[\'label\'])\n    except UnicodeEncodeError:\n        song = ""\n    try:\n        album = str(item[\'album\'])\n    except UnicodeEncodeError:\n        album = ""\n    try:\n        genre = item[\'genre\'][0]\n    except KeyError:\n        genre = "Unknown"\n    try:\n        rating = int(item[\'rating\'])\n        if rating &lt;= 0:\n            rating = "0"\n    except KeyError:\n        rating = "0"\n    rating = str(rating)\n    year = str(item[\'year\'])\n    playcount = item[\'playcount\']\n    songid = str(item[\'songid\'])\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sfsfsa//sfsda/f"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        fanart = item[\'fanart\']\n    except KeyError:\n        fanart = "sfsfsa//sfsda/f"\n    fanart = fanart.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n        c = fanart[1].startswith( \'http\' )\n        d = fanart[1].endswith( \'/\' )\n    except IndexError:\n\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n        c = fanart[0].startswith( \'http\' )\n        d = fanart[0].endswith( \'/\' )\n\n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n        fancover = fanart[1].rsplit("/", 1)\n        fancover = str(fancover[0])\n        fanwork = urllib2.unquote(fancover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n        cachedfanart = os.path.exists(directory + artist + \' - fanart.jpg\')\n        if cachedart != False:\n            artwork = artwork\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                try:\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except UnicodeEncodeError:\n                    artwork = \'images/M_icon.png\'\n                \n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n            except IndexError:\n                try:\n                    cover = thumb[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n        \n        if cachedfanart != False:\n            fanwork = fanwork\n        else:\n            try:\n                cover = fanart[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + artist + \' - fanart.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                try:\n                    cover = fanart[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + artist + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/f_icon.png\'\n            except IndexError:\n                try:\n                    cover = fanart[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/f_icon.png\'\n    Payload = {}\n    Payload = [song + \'||\' + artwork + \'||\' + album + \'||\' + artist + \'||\' + songid + \'||\' + rating]\n    songs.append(Payload)\n\nsongsfull = "    " + str(songs)\nfanwork = fanwork + \'||\' + songid\neg.plugins.Webserver.WsBroadcastData(u\'kodisongs\', songsfull, u\'\', None, None)\neg.plugins.Webserver.SetValue(u\'kodisongul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodisongul\')\n\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Searched Music">
                                <Event Name="kodi.kodisearchbtn" />
                                <Action>
                                    Webserver.SetPersistentValue(u'kodimatchedsearchnum', u'0', False, False, 1)
                                </Action>
                                <Action Name="search popup">
                                    EventGhost.PythonScript(u'eg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Searching library", False, False)\neg.plugins.Webserver.SetValue(u\'kodisearchsongul\', "", False, False)\neg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\neg.plugins.Webserver.BroadcastValue(u\'kodisearchsongul\')\neg.plugins.Webserver.WsBroadcastData(u\'kodisearchsongs\', \'\', u\'\', None, None)\neg.plugins.Webserver.WsBroadcastData(u\'kodisearchartists\', \'\', u\'\', None, None)\n')
                                </Action>
                                <Action Name="Get artist ">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\npayload = eg.event.payload\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC22.JSONRPC(u\'AudioLibrary.GetArtists\', u\'{ "limits": { "start" : 0, "end":20000 }, "properties": [ "thumbnail", "fanart", "born", "formed", "died", "disbanded", "yearsactive", "mood", "style", "genre" ], "sort": { "order": "ascending", "method": "artist" }  }\', False, True)\nnumber = int(eg.plugins.Webserver.GetPersistentValue(u\'kodimatchedsearchnum\', False))\nartists = []\nfor item in x[\'artists\']:\n    artist = item[\'label\']\n    artistid = str(item[\'artistid\'])\n    try:\n        genre = item[\'genre\'][0]\n    except IndexError:\n        genre = ""\n    try:\n        rating = int(item[\'rating\'])\n        if rating &lt;= 0:\n            rating = "0"\n    except KeyError:\n        rating = "0"\n    rating = str(rating)\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sdfsdfs//sdfs/dfsdf/fgd"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        artwork = urllib2.unquote(cover[0]).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + artist + \'.jpg\'\n        cached = os.path.exists(directory + artist + \'.jpg\')\n        if cached != False:\n            artwork = artwork\n        else:\n            if b == True:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/a_icon.png\'\n    Payload = {}\n    Payload = [artist + \'||\' + artwork + \'||\' + artistid + \'||\' + genre + \'||\' + artistid + \'||\' + rating]\n    if payload.lower() == artist.lower():\n        artists.append(Payload)\n        print "Matched Artist: " + artist\n        eg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Matched Artist: " + artist, False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\n        number = number + 1\n    else:\n        x = ""\nartists = str(artists)\nartistsfull = "    " + artists\neg.plugins.Webserver.WsBroadcastData(u\'kodisearchartists\', artistsfull, u\'\', None, None)  \neg.plugins.Webserver.SetPersistentValue(u\'kodimatchedsearchnum\', str(number), False, False, 1)')
                                </Action>
                                <Action Name="Get albums">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\npayload = eg.event.payload\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC22.JSONRPC(u\'AudioLibrary.GetAlbums\', u\'{ "limits": { "start" : 0, "end": 20000 }, "properties": ["playcount", "artist", "genre", "rating", "thumbnail", "year"], "sort": { "order": "ascending", "method": "album" } }\', False, True)\nnumber = int(eg.plugins.Webserver.GetPersistentValue(u\'kodimatchedsearchnum\', False))\nalbums = []\nfor item in x[\'albums\']:\n    artist = item[\'artist\'][0]\n    try:\n        album = str(item[\'label\'])\n    except UnicodeEncodeError:\n        album = ""\n    try:\n        genre = item[\'genre\'][0]\n    except KeyError:\n        genre = "Unknown"\n    try:\n        rating = int(item[\'rating\'])\n        if rating &lt;= 0:\n            rating = "0"\n    except KeyError:\n        rating = "0"\n    rating = str(rating)\n    year = str(item[\'year\'])\n    albumid = str(item[\'albumid\'])\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sfsfsa//sfsda/f"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        fanart = item[\'fanart\']\n    except KeyError:\n        fanart = "sfsfsa//sfsda/f"\n    fanart = fanart.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n        c = fanart[1].startswith( \'http\' )\n        d = fanart[1].endswith( \'/\' )\n    except IndexError:\n\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n        c = fanart[0].startswith( \'http\' )\n        d = fanart[0].endswith( \'/\' )\n\n    if a == True and b == True:\n        try:\n            cover = thumb[1].rsplit("/", 1)\n            cover = str(cover[0])\n            artwork = urllib2.unquote(cover).decode(\'utf8\')\n            print artwork\n        except TypeError:\n            print cover\n    else:\n        artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n        if cachedart != False:\n            artwork = artwork\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                try:\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except UnicodeEncodeError:\n                    artwork = \'images/M_icon.png\'\n                \n            except IOError:\n                    artwork = \'images/M_icon.png\'\n            except IndexError:\n                try:\n                    cover = thumb[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n\n    Payload = {}\n    Payload = [album + \'||\' + artwork + \'||\' + artist + \'||\' + year + \'||\' + albumid + \'||\' + rating]\n    if payload.lower() == album.lower():\n        albums.append(Payload)\n        print "Matched Album: " + artist + \' - \' + album\n        eg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Matched Album: " + artist + \' - \' + album, False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\n        number = number + 1\n    else:\n        x = ""\nalbumsfull = "    " + str(albums)    \neg.plugins.Webserver.WsBroadcastData(u\'kodisearchalbums\', albumsfull, u\'\', None, None)\neg.plugins.Webserver.SetPersistentValue(u\'kodimatchedsearchnum\', str(number), False, False, 1)\n')
                                </Action>
                                <Action Name="Get songs">
                                    EventGhost.PythonScript(u'import urllib2\nimport os.path\nimport shutil\npayload = eg.event.payload\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC22.JSONRPC(u\'AudioLibrary.GetSongs\', u\'{ "limits": { "start" : 0, "end": 20000 }, "properties": ["playcount", "artist", "album", "genre", "rating", "thumbnail", "year"], "sort": { "order": "ascending", "method": "track" } }\', False, True)\nnumber = int(eg.plugins.Webserver.GetPersistentValue(u\'kodimatchedsearchnum\', False))\nsongs = []\nfor item in x[\'songs\']:\n    try:\n        song = item[\'label\']\n    except UnicodeEncodeError:\n        song = ""\n    songid = str(item[\'songid\'])\n    artist = item[\'artist\'][0]\n    album = item[\'album\']\n    year = str(item[\'year\'])\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = "sfsfsa//sfsda/f"\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n        if cachedart != False:\n            artwork = artwork\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                try:\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except UnicodeEncodeError:\n                    artwork = \'images/M_icon.png\'\n                \n            except IndexError:\n                try:\n                    cover = thumb[0].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n            except IOError:\n                artwork = \'images/M_icon.png\'\n    \n    Payload = {}\n    Payload = [song + \'||\' + artwork + \'||\' + album + \'||\' + artist + \'||\' + songid + \'||\' + year]\n    if payload.lower() == song.lower():\n        songs.append(Payload)\n        eg.plugins.Webserver.SetValue(u\'kodisearchsongul\', \'anything\', False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'kodisearchsongul\')\n        print "Matched Song: " + song + \' - \' + artist + \' - \' + album\n        eg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "Matched Song: " + song + " - " + artist, False, False)\n        eg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\n        number = number + 1\n    else:\n        x = ""\nif number == 0:\n    eg.plugins.Webserver.SetValue(u\'iTunesSearchResult\', "No Matches Found", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'iTunesSearchResult\')\nsongsfull = "    " + str(songs)\neg.plugins.Webserver.WsBroadcastData(u\'kodisearchsongs\', songsfull, u\'\', None, None)')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Playlists">
                                <Event Name="kodi.Playlists" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get  Playlists">
                                    EventGhost.PythonScript(u'location = "special://profile/playlists/music/"\nx = eg.plugins.XBMC22.JSONRPC(u\'Files.GetDirectory\', u\'{"directory": "\' + location + \'"}\', False, True)\nplaylists = {}\nfor item in x[\'files\']:\n    file = str(item[\'label\'])\n    name = file.split(\'music/\')\n    name = name[0].split(\'.m3u\')\n    name = name[0]\n    playlist =  location + file\n    playlists[name]  = [playlist]\n\nplaylists = str(playlists)\nplaylistsfull = "    " + playlists\neg.plugins.Webserver.WsBroadcastData(u\'kodiplaylists\', playlistsfull, u\'\', None, None)\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Movies">
                                <Event Name="kodi.updatekodimovies" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get movies">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC22.JSONRPC(u\'VideoLibrary.GetMovies\', u\'{ "limits": { "start" : 0, "end":1000 }, "properties": ["art", "rating", "resume", "thumbnail", "year", "genre", "playcount", "file", "director", "runtime"], "sort": { "order": "ascending", "method": "label" }  }\', False, True)\nmovies = []\nfor item in x[\'movies\']:\n    movie = item[\'label\']\n    movieid = str(item[\'movieid\'])\n    try:\n        runtime = str(int(item[\'runtime\'] / 60))\n    except KeyError:\n        runtime = ""\n    try:\n        genre = str(item[\'genre\'][0])\n    except IndexError:\n        try:\n            genre = str(item[\'genre\'])\n        except KeyError:\n            genre = ""\n    except KeyError:\n            genre = ""\n    try:\n        playcount = item[\'playcount\']\n    except KeyError:\n        playcount = ""\n    try:\n        thumbnail = item[\'thumbnail\']\n    except KeyError:\n        thumbnail = ""\n    try:\n        rating = str(item[\'rating\'])\n    except KeyError:\n        rating = "0"\n    try:\n        director = str(item[\'director\'][0])\n    except UnicodeEncodeError:\n        director = "Unknown"\n    except IndexError:\n        director = "unknown"\n    resume = item[\'resume\'][\'position\']\n    year = str(item[\'year\'])\n    try:\n        poster = item[\'art\'][\'poster\']\n    except KeyError:\n        artwork = \'images/MO_icon.jpg\'\n    thumb = poster.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + movie + ".jpg"\n        cached = os.path.exists(directory + movie + ".jpg")\n        \n        if cached != False:\n            artwork = \'images/kodiart/\' + movie + ".jpg"\n        else:\n            if b == True:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + movie + ".jpg"\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    try:\n                        cover = thumb[1].rsplit("/", 1)\n                        cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                        cover = cover.split(":", 1)\n                        srcfile = str(cover[1])\n                        dstdir = directory + movie + \'.jpg\'\n                        shutil.copy(srcfile, dstdir)\n                        print "cached image: " + dstdir\n                    except IOError:\n                        fanwork = \'images/MO_icon.png\'   \n    Payload = {}\n    Payload = [movie + \'||\' + artwork + \'||\' + year + \'||\' + director + \'||\' + movieid + \'||\' + rating + \'||\' + runtime + \'||\' + genre]\n    movies.append(Payload)\n\nmovies = str(movies)\nmoviesfull = "    " + movies\neg.plugins.Webserver.WsBroadcastData(u\'kodimovies\', moviesfull, u\'\', None, None)\n\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set TV Shows">
                                <Event Name="kodi.updatekoditvshow" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get TV shows">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC22.JSONRPC(u\'VideoLibrary.GetTVShows\', u\'{ "limits": { "start" : 0, "end":250 }, "properties": ["art", "genre", "plot", "title", "originaltitle", "year", "rating", "thumbnail", "playcount", "file", "fanart", "episode", "episodeguide", "studio"], "sort": { "order": "ascending", "method": "label" }  }\', False, True)\nshows = []\nfor item in x[\'tvshows\']:\n    tvshow = item[\'label\']\n    tvshowid = str(item[\'tvshowid\'])\n    playcount = item[\'playcount\']\n    plot = item[\'plot\']\n    episodecount = str(item[\'episode\'])\n    rating = str(item[\'rating\'])\n    year = str(item[\'year\'])\n    try:\n        network = str(item[\'studio\'][0])\n    except IndexError:\n        network = "unknown"\n    \n    thumbnail = item[\'thumbnail\']\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + tvshow + ".jpg"\n        cached = os.path.exists(directory + tvshow + ".jpg")\n        \n        if cached != False:\n            artwork = \'images/kodiart/\' + tvshow + ".jpg"\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + tvshow + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + tvshow + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/tv_icon.png\'\n    Payload = {}\n    Payload = [tvshow + \'||\' + artwork + \'||\' + episodecount + \'||\' + network + \'||\' + tvshowid + \'||\' + rating]\n    shows.append(Payload)\n\nshows = str(shows)\nshowsfull = "    " + shows\neg.plugins.Webserver.WsBroadcastData(u\'koditvshows\', showsfull, u\'\', None, None)\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set TV Seasons">
                                <Event Name="kodi.TVSeason" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get TV show Seasons">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\ntvshowid = eg.event.payload\nx = eg.plugins.XBMC22.JSONRPC(u\'VideoLibrary.GetSeasons\', u\'{ "limits": { "start" : 0, "end": 500 }, "tvshowid": \' + tvshowid + \', "properties": ["season", "showtitle", "episode", "fanart", "thumbnail", "playcount", "art"], "sort": { "order": "ascending", "method": "season" }  }\', False, True)\nseasons = []\n\n\nfor item in x[\'seasons\']:\n    season = str(item[\'label\'])\n    seasonid = str(item[\'seasonid\'])\n    showtitle = str(item[\'showtitle\'])\n    thumbnail = item[\'thumbnail\']\n    fanart = item[\'fanart\']\n    episodecount = str(item[\'episode\'])\n    try:\n        network = str(item[\'studio\'][0])\n        \n    except KeyError:\n        network = "unknown"\n    thumbnail = item[\'thumbnail\']\n    thumb = thumbnail.split(\'//\', 1)\n    fan = fanart.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + showtitle + " - " + season + ".jpg"\n        cached = os.path.exists(directory + showtitle + " - " + season + ".jpg")\n        \n        if cached != False:\n            artwork = \'images/kodiart/\' + showtitle + " - " + season + ".jpg"\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + showtitle + " - " + season + ".jpg"\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + showtitle + \' - \' + season + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    artwork = \'images/tv_icon.png\'\n    Payload = {}\n    Payload = [season + \'||\' + artwork + \'||\' + tvshowid + \'||\' + showtitle + \'||\' + episodecount + \'||\' + \'\']\n    seasons.append(Payload)\n\nseasons = str(seasons)\nseasonsfull = "    " + seasons\n\ntry:\n    a = fan[1].startswith( \'http\' )\n    b = fan[1].endswith( \'/\' )\n\nexcept IndexError:\n    a = fan[0].startswith( \'http\' )\n    b = fan[0].endswith( \'/\' )\n\nif a == True and b == True:\n        cover = fan[1].rsplit("/", 1)\n        cover = str(cover[0])\n        fanwork = urllib2.unquote(cover).decode(\'utf8\')\nelse:\n    fanwork = \'images/kodiart/\' + showtitle + " - fanart.jpg"\n    cached = os.path.exists(directory + showtitle + " - fanart.jpg")\n    if cached != False:\n        fanwork = \'images/kodiart/\' + showtitle + " - fanart.jpg"\n    else:\n        try:\n            cover = fan[1].rsplit("/", 1)\n            cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n            srcfile = str(cover)\n            dstdir = directory + showtitle + " - fanart.jpg"\n            shutil.copy(srcfile, dstdir)\n            print "cached image: " + dstdir\n        except IOError:\n            try:\n                cover = fan[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                cover = cover.split(":", 1)\n                srcfile = str(cover[1])\n                dstdir = directory + showtitle + \' - fanart.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                fanwork = \'images/f_icon.png\'\n        \n        \neg.plugins.Webserver.WsBroadcastData(u\'koditvseasons\', seasonsfull, u\'\', None, None)\neg.plugins.Webserver.SetValue(u\'koditvseasonul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'koditvseasonul\')')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set TV Episode">
                                <Event Name="kodi.TVEpisode" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get TV episodes by shows id &amp; season number http:/local cached check">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\npayload = eg.event.payload\npay = payload.split("||")\nseasonid = pay[1].split(\'Season \')\nseasonid = seasonid[1]\ntvshowid = pay[0]\nx = eg.plugins.XBMC22.JSONRPC(u\'VideoLibrary.GetEpisodes\', u\'{ "tvshowid": \' + tvshowid + \', "season": \' + seasonid + \', "properties": ["season", "resume", "title", "showtitle", "episode", "playcount", "plot", "fanart", "thumbnail", "rating"], "sort": { "order": "ascending", "method": "label" }  }\', False, True)\nepisodes = []\nfor item in x[\'episodes\']:\n    episode = item[\'title\']\n    episodenum = str(item[\'episode\'])\n    if len(episodenum) &lt; 2:\n        episodenum = "0" + episodenum\n    seasonnum = str(seasonid)\n    se = "s" + seasonnum + \'e\' + episodenum\n    episodeid = str(item[\'episodeid\'])\n    plot = item[\'plot\']\n    resume = item[\'resume\'][\'position\']\n    rating = str(item[\'rating\'])\n    thumbnail = item[\'thumbnail\']\n    showtitle = item[\'showtitle\']\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + showtitle + \' - \' + se + \'.jpg\'\n        cachedart = os.path.exists(directory + showtitle + \' - \' + se + \'.jpg\')\n        if cachedart != False:\n            artwork = \'images/kodiart/\'+ showtitle + \' - \' + se + \'.jpg\'\n        else:\n            try: \n                cover = thumb[1].rsplit(\'/\', 1)\n                srcfile = urllib2.unquote(cover[0]).decode(\'utf8\')\n                dstdir = directory + showtitle + \' - \' + se + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except UnicodeEncodeError:\n                cover = thumb[1].rsplit(\'/\', 1)\n                artwork = \'images/k_icon.png\'\n            except IOError:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + showtitle + \' - \' + se + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    print "error"\n                    artwork = \'images/k_icon.png\'\n    Payload = {}\n    Payload = [episode + \'||\' + artwork + \'||\' + se + \'||\' + showtitle + \'||\' + episodeid + \'||\' + rating]\n    episodes.append(Payload)\n    \nepisodes = str(episodes)\nepisodesfull = "    " + episodes\neg.plugins.Webserver.WsBroadcastData(u\'koditvepisodes\', episodesfull, u\'\', None, None)\n\nx = eg.plugins.XBMC22.JSONRPC(u\'VideoLibrary.GetSeasons\', u\'{ "limits": { "start" : 0, "end": 500 }, "tvshowid": \' + tvshowid + \', "properties": ["season", "showtitle", "episode", "fanart", "thumbnail", "playcount", "art"], "sort": { "order": "ascending", "method": "season" }  }\', False, True)\n\nshowtitle = str(x[\'seasons\'][0][\'showtitle\'])\nfanart = x[\'seasons\'][0][\'fanart\']\nfanart = fanart.split(\'//\', 1)\nurl = str(fanart[1])\ncover = urllib2.unquote(url).decode(\'utf8\')\na = cover.startswith( \'http\' )\nb = cover.endswith( \'.jpg\' )\nc = cover.endswith( \'/\' )\n\nif a == True and b == True:\n    cover = cover.split(".jpg")\n    fanwork = str(cover[0]) + \'.jpg\'\n\nelif a == True and c == True:\n    cover = cover.rsplit("/", 1)\n    fanwork = str(cover[0])\n\nelse:\n    fanwork = \'images/kodiart/\' + showtitle + \' - fanart.jpg\'\n    cachedfanart = os.path.exists(directory + showtitle + \' - fanart.jpg\')\n        \n    if cachedfanart != False:\n        try:\n            fanwork = \'images/kodiart/\' + showtitle + \' - fanart.jpg\'\n        except IOError:\n            try:\n                cover = cover.rsplit("/", 1)\n                srcfile = str(cover[0])\n                dstdir = directory + showtitle + \' - fanart.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                try:\n                    cover = cover[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    print cover\n                    cover = cover.split(":", 1)\n                    srcfile = str(cover[1])\n                    dstdir = directory + showtitle + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/f_icon.png\'\n    else:\n        fanwork = \'images/f_icon.png\'   \neg.plugins.Webserver.SetValue(u\'koditvepisodeul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'koditvepisodeul\')')
                                </Action>
                                <Action Name="Get TV episodes by shows id &amp; season number http:/cache local without check" Enabled="False">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\npayload = eg.event.payload\npay = payload.split("||")\nseasonid = pay[1].split(\'Season \')\nseasonid = seasonid[1]\ntvshowid = pay[0]\nx = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetEpisodes\', u\'{ "tvshowid": \' + tvshowid + \', "season": \' + seasonid + \', "properties": ["season", "resume", "title", "showtitle", "episode", "playcount", "plot", "fanart", "thumbnail", "rating"], "sort": { "order": "ascending", "method": "label" }  }\', False, True)\nepisodes = []\nfor item in x[\'episodes\']:\n    episode = item[\'title\']\n    episodenum = str(item[\'episode\'])\n    if len(episodenum) &lt; 2:\n        episodenum = "0" + episodenum\n    seasonnum = str(seasonid)\n    se = "s" + seasonnum + \'e\' + episodenum\n    episodeid = str(item[\'episodeid\'])\n    plot = item[\'plot\']\n    rating = str(item[\'rating\'])\n    thumbnail = item[\'thumbnail\']\n    showtitle = item[\'showtitle\']\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:\n        artwork = \'images/kodiart/\' + showtitle + \' - \' + se + \'.jpg\'\n        cover = thumb[1].rsplit(\'/\', 1)\n        try:\n            srcfile = urllib2.unquote(cover[0]).decode(\'utf8\')\n            dstdir = directory + showtitle + \' - \' + se + \'.jpg\'\n            shutil.copy(srcfile, dstdir)\n        except UnicodeEncodeError:\n            srcfile = ""\n        \n\n    Payload = {}\n    Payload = [episode + \'||\' + artwork + \'||\' + se + \'||\' + showtitle + \'||\' + episodeid + \'||\' + rating]\n    episodes.append(Payload)\n    \nepisodes = str(episodes)\nepisodesfull = "    " + episodes\neg.plugins.Webserver.WsBroadcastData(u\'koditvepisodes\', episodesfull, u\'\', None, None)\n\nx = eg.plugins.XBMC2.JSONRPC(u\'VideoLibrary.GetSeasons\', u\'{ "limits": { "start" : 0, "end": 500 }, "tvshowid": \' + tvshowid + \', "properties": ["season", "showtitle", "episode", "fanart", "thumbnail", "playcount", "art"], "sort": { "order": "ascending", "method": "season" }  }\', False, True)\n\nshowtitle = str(x[\'seasons\'][0][\'showtitle\'])\nfanart = x[\'seasons\'][0][\'fanart\']\nfanart = fanart.split(\'//\', 1)\nurl = str(fanart[1])\ncover = urllib2.unquote(url).decode(\'utf8\')\na = cover.startswith( \'http\' )\nb = cover.endswith( \'.jpg\' )\nc = cover.endswith( \'/\' )\n\nif a == True and b == True:\n    cover = cover.split(".jpg")\n    fanwork = str(cover[0]) + \'.jpg\'\n\nelif a == True and c == True:\n    cover = cover.rsplit("/", 1)\n    fanwork = str(cover[0])\n\nelse:\n    fanwork = \'images/kodiart/\' + showtitle + \' - fanart.jpg\'\n    cover = cover.rsplit("/", 1)\n    srcfile = str(cover[0])\n    dstdir = directory + showtitle + \' - fanart.jpg\'\n    shutil.copy(srcfile, dstdir)\n    \neg.plugins.Webserver.SetValue(u\'koditvepisodeul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'koditvepisodeul\')')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set PVR channels">
                                <Event Name="kodi.updatekodipvr" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get Channels (current info)">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nchannels = eg.plugins.XBMC22.JSONRPC(u\'PVR.GetChannels\', u\'{"channelgroupid": 1, "properties": [ "thumbnail", "channel", \\\'lastplayed\\\', \\\'hidden\\\']}\', False, True)\nchannellist = []\nfor channel in channels[\'channels\']:\n    name = channel[\'label\']\n    hidden = channel[\'hidden\']\n    thumbnail = channel[\'thumbnail\']\n    channelid = str(channel[\'channelid\'])\n    chan = {}\n    chan[channelid] = {\'name\':name, \'id\':channelid, \'thumbnail\':thumbnail}\n    channellist.append(chan)\nmychannels = []\nfor item in channellist:\n    \n    channame = str(item.values()[0][\'name\'])\n    channame = channame.split(" ")\n    channelname = channame[1]\n    if channelname == "":\n        channelname = "???"\n    thumbnail = str(item.values()[0][\'thumbnail\'])\n    thumb = thumbnail.split(\'//\', 1)\n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + channelname + \'.jpg\'\n        cachedart = os.path.exists(directory + channelname + \'.jpg\')\n        if cachedart != False:\n            artwork = \'images/kodiart/\'+ channelname + \'.jpg\'\n        else:\n            try: \n                cover = thumb[1].rsplit(\'/\', 1)\n                srcfile = urllib2.unquote(cover[0]).decode(\'utf8\')\n                dstdir = directory + channelname + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                artwork = \'images/k_icon.png\'\n            except IndexError:\n                artwork = \'images/k_icon.png\'\n    channelid = str(item.values()[0][\'id\'])\n    getchan = str(item.keys()[0])\n    chan = eg.plugins.XBMC22.JSONRPC(u\'PVR.GetBroadcasts\', u\'{"channelid":\' + getchan + \', "properties": [ "thumbnail","title", "episodename","plot","runtime","starttime","endtime"]}\', False, True)\n    try:\n        details = chan[\'broadcasts\'][0]\n        broadcastid = str(details[\'broadcastid\'])\n        episodename = details[\'episodename\']\n        plot = details[\'plot\']\n        episodetitle = details[\'label\']\n        runtime = str(details[\'runtime\'])\n        start = details[\'starttime\']\n        end = details[\'endtime\']\n    except KeyError:\n        x = "y"\n    Payload = {}\n    Payload = [channelid + \'||\' + artwork + \'||\' + channelname + \'||\' + episodetitle + \'||\' + broadcastid + \'||\' + runtime]\n    mychannels.append(Payload)\n\nmychannelsfull = "    " + str(mychannels)\neg.plugins.Webserver.WsBroadcastData(u\'kodipvr\', mychannelsfull, u\'\', None, None)\n\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Current Audio Playlist" id="1057">
                                <Event Name="XBMC2.Playlist.OnClear" />
                                <Event Name="kodi.reloadtracks" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get Current Playlist Tracks">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaultcdthumb\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC22.JSONRPC(u\'Playlist.GetItems\', u\'{"playlistid":0, "properties": ["title", "album", "artist", "duration", "rating", "track", "thumbnail", "fanart"]}\', False, True)\n\nsize = x[\'limits\'][\'total\']\nif size != 0:\n    tracks = []\n    postion = 0\n    for item in x[\'items\']:\n        position = str(postion + 1)\n        try:\n            artist = str(item[\'artist\'])\n        except KeyError:\n            artist = "???"\n        u = artist.startswith( \'[\' )\n        if u == True:\n            artist = str(item[\'artist\'][0])\n        try:\n            album = str(item[\'album\'])\n        except UnicodeEncodeError:\n            album = ""\n        artistlong = artist + \' - \' + album\n        duration = int(item[\'duration\'])\n        m, s = divmod(duration, 60)\n        duration = "%2d:%02d" % (m, s)\n        duration = str(duration)\n        songid = item[\'id\']\n        track = item[\'title\']\n        tracknum = item[\'track\']\n        tracknum = str(tracknum)\n        type = item[\'type\']\n        rating = str(item[\'rating\'])\n        thumb = item[\'thumbnail\']\n        thumb = thumb.split(\'//\', 1)\n        fanart = item[\'fanart\']\n        fanart = fanart.split(\'//\', 1)\n    \n        try:\n            a = thumb[1].startswith( \'http\' )\n            b = thumb[1].endswith( \'/\' )\n            c = fanart[1].startswith( \'http\' )\n            d = fanart[1].endswith( \'/\' )\n        except IndexError:\n            a = thumb[0].startswith( \'http\' )\n            b = thumb[0].endswith( \'/\' )\n            c = fanart[0].startswith( \'http\' )\n            d = fanart[0].endswith( \'/\' )\n        if a == True and b == True:\n            cover = thumb[1].rsplit("/", 1)\n            cover = str(cover[0])\n            artwork = urllib2.unquote(cover).decode(\'utf8\')\n            fanart = fanart[1].rsplit("/", 1)\n            fancover = str(fanart[0])\n            fanwork = urllib2.unquote(fancover).decode(\'utf8\')\n        else:\n            artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n            fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n            cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n            cachedfanart = os.path.exists(directory + artist + \' - fanart.jpg\')\n            if cachedart != False:\n                artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n            else:\n                if b == True:\n                    try:\n                        cover = thumb[1].rsplit("/", 1)\n                        cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                        srcfile = str(cover)\n                        dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                        shutil.copy(srcfile, dstdir)\n                        print "copied"\n                    except IOError:\n                        artwork = \'images/M_icon.png\'\n                artwork = \'images/M_icon.png\'\n        \n            if cachedfanart != False:\n                fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n            else:\n                if b == True:\n                    try:\n                        cover = fanart[1].rsplit("/", 1)\n                        cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                        srcfile = str(cover)\n                        dstdir = directory + artist + \' - fanart.jpg\'\n                        shutil.copy(srcfile, dstdir)\n                        print "cached image: " + dstdir\n                    except IOError:\n                        fanwork = \'images/f_icon.png\'\n    \n        Payload = {}\n        Payload = [track + \'||\' + artwork + \'||\' + artist + \'||\' + duration + \'||\' + tracknum + \'||\' + rating]\n        tracks.append(Payload)\n\n    tracks = str(tracks)\n    tracksfull = "     " + tracks\n    eg.plugins.Webserver.WsBroadcastData(u\'kodicurrenttracks\', tracksfull, u\'\', None, None)\n\nelse:\n    eg.plugins.Webserver.SetValue(u\'kodiclearcurrentplaylistul\', "", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiclearcurrentplaylistul\')\n    eg.Exit()')
                                </Action>
                                <Action Name="Get/Save/Set Fanart">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\nimport re\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaultcdthumb\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\np = eg.plugins.XBMC22.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = p[0][\'playerid\']\n    id = str(id)\n    type = p[0][\'type\']\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\n\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\nif id == "0":\n    current = eg.plugins.XBMC22.JSONRPC(u\'Player.GetItem\', u\'{ "properties": ["title", "album", "artist", "duration", "year", "rating", "playcount", "genre", "thumbnail", "file", "fanart", "streamdetails"], "playerid": \' + id + \' }\', False, True)\n    artist = current[\'item\'][\'artist\'][0]\n    album = current[\'item\'][\'album\']\n    fanart = current[\'item\'][\'fanart\']\n    fanart = fanart.split(\'//\', 1)\n    \n    try:\n        c = fanart[1].startswith( \'http\' )\n        d = fanart[1].endswith( \'/\' )\n    except IndexError:\n        c = fanart[0].startswith( \'http\' )\n        d = fanart[0].endswith( \'/\' )\n    if c == True and d == True:\n        fanart = fanart[1].rsplit("/", 1)\n        fancover = str(fanart[0])\n        fanwork = urllib2.unquote(fancover).decode(\'utf8\')\n    else:\n        fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        cachedfanart = os.path.exists(directory + artist + \' - fanart.jpg\')\n        if cachedfanart != False:\n            fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        else:\n            if d == True:\n                try:\n                    cover = fanart[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/f_icon.png\'\n                    \n    eg.plugins.Webserver.SetValue(u\'kodicurrentplaylistul\', fanwork, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodicurrentplaylistul\')')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Current Video Playlist" id="1065">
                                <Event Name="kodi.UpdatekodiVideoTracks" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get Current Playlist Tracks">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaultcdthumb\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nx = eg.plugins.XBMC22.JSONRPC(u\'Playlist.GetItems\', u\'{"playlistid":1, "properties": ["originaltitle", "sorttitle", "uniqueid", "season", "tvshowid", "duration", "episode", "showtitle", "rating", "description", "episodeguide", "plotoutline", "thumbnail", "title", "track", "fanart"]}\', False, True)\ntracks = []\npostion = 0\n\ntry:\n    showtitle = str(x[\'items\'][0][\'showtitle\'])\nexcept KeyError:\n    eg.Exit()\nfanart = x[\'items\'][0][\'fanart\']\nfanart = fanart.split(\'//\', 1)\ncover = str(fanart[1])\n\na = cover.startswith( \'http\' )\nb = cover.endswith( \'/\' )\nif a == True and b == True:\n    cover = cover.rsplit("/", 1)\n    cover = str(cover[0])\n    fanwork = urllib2.unquote(cover).decode(\'utf8\')\nelse:\n    fanwork = \'images/kodiart/\' + showtitle + \' - fanart.jpg\'\n    cachedfanart = os.path.exists(directory + showtitle + \' - fanart.jpg\')\n    \n    if cachedfanart != False:\n        fanwork = \'images/kodiart/\' + showtitle + \' - fanart.jpg\'\n    else:\n        if b == True:\n            try:\n                cover = fanart[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + showtitle + \' - fanart.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                cover = cover.split(":")\n                srcfile = str(cover[1])\n                dstdir = directory + showtitle + \' - fanart.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                artwork = \'images/f_icon.png\'\n\n\nfor item in x[\'items\']:\n    position = str(postion + 1)\n    try:\n        season = int(item[\'season\'])\n    except UnicodeEncodeError:\n        season = ""\n    episode = int(item[\'episode\'])\n    try:\n        duration = int(item[\'duration\'])\n        m, s = divmod(duration, 60)\n        duration = "%2d:%02d" % (m, s)\n        duration = str(duration)\n    except KeyError:\n        duration = ""\n    sorttitle = str(item[\'sorttitle\'])\n    title = str(item[\'title\'])\n    tracknum = item[\'track\']\n    tracknum = str(tracknum)\n    tvshowid = str(item[\'tvshowid\'])\n    showtitle = str(item[\'showtitle\'])\n    plot = str(item[\'plotoutline\'])\n    thumbnail = str(item[\'thumbnail\'])\n    type = item[\'type\']\n    rating = str(int(round(item[\'rating\']) / 2))\n    try:\n        uniqueid = str(item[\'uniqueid\'])\n    except KeyError:\n        uniqueid = ""\n    try:\n        description = str(item[\'description\'])\n    except KeyError:\n        description = ""\n\n    if season &lt;= 9:\n        season = "0" + str(season)\n    else:\n        season = str(season)\n    if episode &lt;= 9:\n        episode = "0" + str(episode)\n    else:\n        episode = str(episode)\n\n    se = "S" + season + "E" + episode\n    \n    thumb = thumbnail.split(\'//\', 1)\n    \n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n    \n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    \n    else:  \n        artwork = \'images/kodiart/\'+ showtitle + \' - \' + "s" + season + "e" + episode + \'.jpg\'\n        cached = os.path.exists(directory + showtitle + \' - \' + "s" + season + "e" + episode + \'.jpg\')\n        if cached != False:\n            artwork = \'images/kodiart/\' + showtitle + \' - \' + "s" + season + "e" + episode + \'.jpg\'\n        else:\n            try:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                srcfile = str(cover)\n                dstdir = directory + showtitle + \' - \' + "s" + season + "e" + episode + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                cover = thumb[1].rsplit("/", 1)\n                cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                cover = cover.split(":")\n                srcfile = str(cover[1])\n                dstdir = directory + showtitle + \' - \' + "s" + season + "e" + episode + \'.jpg\'\n                shutil.copy(srcfile, dstdir)\n                print "cached image: " + dstdir\n            except IOError:\n                artwork = \'images/k_icon.png\'\n    Payload = {}\n    Payload = [title + \'||\' + artwork + \'||\' + showtitle + " - " + se + \'||\' + duration + \'||\' + "" + \'||\' + rating]\n    tracks.append(Payload)\n\ntracks = str(tracks)\ntracksfull = "     " + tracks\n\neg.plugins.Webserver.WsBroadcastData(u\'kodicurrenttracks\', tracksfull, u\'\', None, None)\neg.plugins.Webserver.SetValue(u\'kodicurrentplaylistul\', fanwork, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodicurrentplaylistul\')')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Main player info">
                            <Macro Name="Get/Set Current Audio Playback variables" id="1072">
                                <Event Name="Main.kodiaucioplayeractive" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get/Save/Set Thumbnail">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\nimport re\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaultcdthumb\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\np = eg.plugins.XBMC22.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = p[0][\'playerid\']\n    id = str(id)\n    type = p[0][\'type\']\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\n\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\nif id == "0":\n    current = eg.plugins.XBMC22.JSONRPC(u\'Player.GetItem\', u\'{ "properties": ["title", "album", "artist", "duration", "year", "rating", "playcount", "genre", "thumbnail", "file", "fanart", "streamdetails"], "playerid": \' + id + \' }\', False, True)\n    artist = current[\'item\'][\'artist\'][0]\n    album = current[\'item\'][\'album\']\n    thumb = current[\'item\'][\'thumbnail\']\n    fanart = current[\'item\'][\'fanart\']\n    thumb = thumb.split(\'//\', 1)\n    fanart = fanart.split(\'//\', 1)\n    \n    try:\n        a = thumb[1].startswith( \'http\' )\n        b = thumb[1].endswith( \'/\' )\n        c = fanart[1].startswith( \'http\' )\n        d = fanart[1].endswith( \'/\' )\n    except IndexError:\n        a = thumb[0].startswith( \'http\' )\n        b = thumb[0].endswith( \'/\' )\n        c = fanart[0].startswith( \'http\' )\n        d = fanart[0].endswith( \'/\' )\n    if a == True and b == True:\n        cover = thumb[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n        fanart = fanart[1].rsplit("/", 1)\n        fancover = str(fanart[0])\n        fanwork = urllib2.unquote(fancover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        cachedart = os.path.exists(directory + artist + \' - \' + album + \'.jpg\')\n        cachedfanart = os.path.exists(directory + artist + \' - fanart.jpg\')\n        if cachedart != False:\n            artwork = \'images/kodiart/\' + artist + \' - \' + album + \'.jpg\'\n        else:\n            if b == True:\n                try:\n                    cover = thumb[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - \' + album + \'.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "copied"\n                except IOError:\n                    artwork = \'images/M_icon.png\'\n                    \n        if cachedfanart != False:\n            fanwork = \'images/kodiart/\' + artist + \' - fanart.jpg\'\n        else:\n            if b == True:\n                try:\n                    cover = fanart[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + artist + \' - fanart.jpg\'\n                    shutil.copy(srcfile, dstdir)\n                    print "cached image: " + dstdir\n                except IOError:\n                    fanwork = \'images/f_icon.png\'              \n    coverart = \'&lt;a id="kodi.reloadtracks" name="kodi" title="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" href="#kodiplaylist"&gt;&lt;img style="text-align:center;" id="art" src="\' + artwork + \'" width="250" height="250" alt=""/&gt;&lt;/a&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodicoverart\', coverart, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodicoverart\')\n')
                                </Action>
                                <Action Name="Get/Set current playback info">
                                    EventGhost.PythonScript(u'import urllib2\np = eg.plugins.XBMC22.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = str(p[0][\'playerid\'])\n    type = p[0][\'type\']\nexcept IndexError:\n    id = "none"\n    print "id = None"\ncurrent = eg.plugins.XBMC22.JSONRPC(u\'Player.GetItem\', u\'{ "properties": ["title", "album", "artist", "duration", "year", "rating", "playcount", "genre", "thumbnail", "file", "fanart", "streamdetails"], "playerid": \' + id + \' }\', False, True)\nsongid = str(current[\'item\'][\'id\'])\ntype = current[\'item\'][\'type\']\nartist = current[\'item\'][\'artist\'][0]\nalbum = current[\'item\'][\'album\']\nsong = current[\'item\'][\'title\']\nyear = str(current[\'item\'][\'year\'])\nrating = str(current[\'item\'][\'rating\'])\nfanart = current[\'item\'][\'fanart\']\nu = eg.plugins.XBMC2.JSONRPC(u\'AudioLibrary.GetSongDetails\', u\'{"songid": \' + songid + \', "properties": ["playcount", "lastplayed", "track", "duration", "albumid", "albumartistid", "artist", "album"]}\', False, True)\nplaycount = str(u[\'songdetails\'][\'playcount\'])\np = eg.plugins.XBMC2.JSONRPC(u\'Player.GetProperties\', u\'{"playerid": \' + id + \', "properties": ["repeat", "shuffled", "percentage", "time", "totaltime", "type", "playlistid", "partymode", "position", "speed"]}\', False, True)\ntry:\n    progress = p[\'percentage\']\nexcept TypeError:\n    progress = "0"\ntry:\n    partymode = p[\'partymode\']\nexcept TypeError:\n    partymode = "False"\ntry:\n    speed = p[\'speed\']\n    if speed == 0:\n        state = "Paused"\n    elif speed == 1:\n        state = "Playing"\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', state, False, False)\nexcept TypeError:\n    speed = "0"\n    \neg.plugins.Webserver.SetValue(u\'koditrackplaycount\', playcount, False, False)\neg.plugins.Webserver.BroadcastValue(u\'koditrackplaycount\')\n\nif state == None:\n    state = "Playing"\nif state == "Playing":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', eqimg, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodileftRating\')\nelif state == "Paused":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Paused", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\n    eqimg = \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', eqimg, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodileftRating\')\nelif state == "Stopped":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Stopped", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\n    eqimg = \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodileftRating\', eqimg, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodileftRating\')\n\neg.plugins.Webserver.SetValue(u\'kodiartist\', artist, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodiartist\')\neg.plugins.Webserver.SetValue(u\'kodialbum\', album, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodialbum\')\neg.plugins.Webserver.SetValue(u\'koditrackTitle\', song, False, False)\neg.plugins.Webserver.BroadcastValue(u\'koditrackTitle\')\neg.plugins.Webserver.SetValue(u\'kodiyear\', year, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodiyear\')\neg.plugins.Webserver.SetValue(u\'kodirating\', rating, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodirating\')\neg.plugins.Webserver.BroadcastValue(u\'kodiroom\', None, u\'\', None)\neg.plugins.Webserver.BroadcastValue(u\'kodirun_icon\', None, u\'\', None)\n\n\n')
                                </Action>
                                <Action>
                                    EventGhost.DisableItem(XmlIdLink(885))
                                </Action>
                                <Action>
                                    EventGhost.EnableItem(XmlIdLink(866))
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.hidedefaultplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.hidevideoplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.showaudioplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodiupdatetoggles', 0.5)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1057), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Current Video Playback variables" id="1086">
                                <Event Name="Main.kodiVideoplayeractive" />
                                <Event Name="Main.kodichannelchanged" />
                                <Action>
                                    Webserver.GetPersistentValue(u'kodirun_icon', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "False"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action Name="Get/Set current playback info &amp; poster">
                                    EventGhost.PythonScript(u'import urllib2\nimport os\nimport shutil\ndefault = eg.plugins.Webserver.GetPersistentValue(u\'kodidefaulttvposter\', False)\ndirectory = eg.plugins.Webserver.GetPersistentValue(u\'kodiartdirectory\', False)\nepisodeshort = "Other Variable"\np = eg.plugins.XBMC22.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = str(p[0][\'playerid\'])\n    type = p[0][\'type\']\nexcept IndexError:\n    id = "none"\n    print "id = None"\n\ncurrent = eg.plugins.XBMC22.JSONRPC(u\'Player.GetItem\', u\'{ "properties": ["theme", "tagline", "premiered", "studio", "director", "title", "album", "artist", "duration", "year", "rating", "playcount", "genre", "thumbnail", "file", "fanart", "streamdetails", "tvshowid", "season", "episode", "showtitle"], "playerid": \' + id + \' }\', False, True)\ntry:\n    file = current[\'item\'][\'file\']\nexcept KeyError:\n    file = ""\n\n\nid = str(current[\'item\'][\'id\'])\nthumbnail = str(current[\'item\'][\'thumbnail\'])\ntry:\n    premiered = str(current[\'item\'][\'premiered\'])\nexcept KeyError:\n    premiered = ""\ntype = current[\'item\'][\'type\']\ntry:\n    genre = current[\'item\'][\'genre\'][0]\nexcept IndexError:\n    genre = "Unknown"\nyear = str(current[\'item\'][\'year\'])\nrating = current[\'item\'][\'rating\']\nrating = str(int(round(rating / 2)))\ntitle = str(current[\'item\'][\'title\'])\ntry:\n    director = str(current[\'item\'][\'director\'][0])\nexcept IndexError:\n    director = ""\nrating = str(rating)\nfanart = str(current[\'item\'][\'fanart\'])\ntry:\n    tvshowid = str(current[\'item\'][\'tvshowid\'])\nexcept KeyError:\n    tvshowid = ""\ntry:\n    studio = str(current[\'item\'][\'studio\'][0])\nexcept IndexError:\n    studio = "Unknown"\nexcept KeyError:\n    studio = ""\ntry:\n    duration = str(current[\'item\'][\'duration\'])\nexcept KeyError:\n    duration = ""\ntry:\n    showtitle = str(current[\'item\'][\'showtitle\'])\nexcept KeyError:\n    showtitle = ""\nstate = eg.plugins.Webserver.GetValue(u\'kodiplaypause\', False)\n\nif state == None:\n    state = "Playing"\nif state == "Playing":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Playing", False, False)\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', eqimg, False, False)\nelif state == "Paused":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Paused", False, False)\n    eqimg = \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', eqimg, False, False)\nelif state == "Stopped":\n    eg.plugins.Webserver.SetValue(u\'kodiplaypause\', "Stopped", False, False)\n    eqimg = \'&lt;img src="images/buttons/eqnull.gif" width="48" height="24" alt=""/&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideoleftRating\', eqimg, False, False)\n\neg.plugins.Webserver.SetValue(u\'kodiVideotrackTitle\', showtitle, False, False)\neg.plugins.Webserver.SetValue(u\'kodiVideoshow\', title, False, False)\neg.plugins.Webserver.SetValue(u\'kodiVideorating\', rating, False, False)\n\neg.plugins.Webserver.BroadcastValue(u\'kodiVideorating\')\neg.plugins.Webserver.BroadcastValue(u\'kodiroom\', None, u\'\', None)\neg.plugins.Webserver.BroadcastValue(u\'kodirun_icon\', None, u\'\', None)\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoleftRating\')\neg.plugins.Webserver.BroadcastValue(u\'kodiplaypause\')\n\nif type == "episode":\n    year = premiered[:4]\n    eg.plugins.Webserver.SetValue(u\'kodiVideonetworkgenre\', studio, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideogenre\', genre, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoyear\', year, False, False)\n    \n    season = current[\'item\'][\'season\']\n    if season &lt;= 9:\n        season = "0" + str(season)\n    else:\n        season = str(season)\n    episode = (current[\'item\'][\'episode\'])\n    if episode &lt;= 9:\n        episode = "0" + str(episode)\n    else:\n        episode = str(episode)\n    episodeshort = "S" + season + "E" + episode\n    season = int(season)\n    x = eg.plugins.XBMC22.JSONRPC(u\'VideoLibrary.GetSeasons\', u\'{ "limits": { "start" : 0, "end": 500 }, "tvshowid": \' + tvshowid + \', "properties": ["season", "showtitle", "episode", "fanart", "thumbnail", "playcount", "art"], "sort": { "order": "ascending", "method": "season" }  }\', False, True)\n    try:\n        episodecount = str(x[\'seasons\'][season][\'episode\'])\n    except IndexError:\n        episodecount = "0"\n    try: \n        poster = x[\'seasons\'][season][\'art\'][\'poster\']\n    except IndexError:\n        poster = default\n    cover = poster.split(\'//\', 1)\n    season = str(season)\n    try:\n        a = cover[1].startswith( \'http\' )\n        b = cover[1].endswith( \'/\' )\n\n    except IndexError:\n        try:\n            a = cover.startswith( \'http\' )\n            b = cover.endswith( \'/\' )\n        except AttributeError:\n            a = cover[0].startswith( \'http\' )\n            b = cover[0].endswith( \'/\' )\n    if a == True and b == True:\n        cover = cover[1].rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n    else:\n        artwork = \'images/kodiart/\' + showtitle + \' - Season \' + season + \'.jpg\'\n        cached = os.path.exists(directory + showtitle + \' - \' + season + \'.jpg\')\n        if cached != False:\n            artwork = \'images/kodiart/\' + showtitle + \' - Season \' + season + \'.jpg\'\n        else:\n            if b == True:\n                try:\n                    cover = cover[1].rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + showtitle + " - " + season + ".jpg"\n                    shutil.copy(srcfile, dstdir)\n                    print "cached file: " + dstdir\n                except IOError:\n                    artwork = \'images/tv_icon.png\'\n    print artwork\n    coverart = \'&lt;a id="kodi.reloadtracks" name="kodi" title="UpdatekodiVideoTracks" class="dynamicdatasend" data-action="reload.tracks" href="#kodiplaylist"&gt;&lt;img style="text-align:center;" id="art" src="\' + artwork + \'" width="210" height="300" alt=""/&gt;&lt;/a&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideocoverart\', coverart, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiVideocoverart\')\n    eg.plugins.Webserver.SetValue(u\'kodiVideotrackTitle\', title, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoshow\', episodeshort, False, False)\nif type == "movie":\n    eg.plugins.Webserver.SetValue(u\'kodiVideogenre\', genre, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideonetworkgenre\', studio, False, False)\n    thumb = thumbnail.split(\'//\', 1)\n    url = str(thumb[1])\n    cover = urllib2.unquote(url).decode(\'utf8\')\n    try:\n        a = cover.startswith( \'http\' )\n        b = cover.endswith( \'/\' )\n\n    except IndexError:\n        a = cover.startswith( \'http\' )\n        b = cover.endswith( \'/\' )\n        \n    if a == True and b == True:\n        cover = cover.rsplit("/", 1)\n        cover = str(cover[0])\n        artwork = urllib2.unquote(cover).decode(\'utf8\')\n        \n    else:\n        artwork = \'images/kodiart/\' + title + \'.jpg\'\n        cached = os.path.exists(directory + title + ".jpg")\n        \n        if cached != False:\n            artwork = \'images/kodiart/\' + title + ".jpg"\n        else:\n            if b == True:\n                try:\n                    cover = cover.rsplit("/", 1)\n                    cover = urllib2.unquote(cover[0]).decode(\'utf8\')\n                    srcfile = str(cover)\n                    dstdir = directory + title + ".jpg"\n                    shutil.copy(srcfile, dstdir)\n                    print "copied"\n                except IOError:\n                    artwork = \'images/MO_icon.png\'\n    print artwork\n    coverart = \'&lt;a id="moviees" name="kodi" title="UpdatekodiVideoTracks" class="dynamicdatasend" data-action="" href="#"&gt;&lt;img style="text-align:center;" id="art" src="\' + artwork + \'" width="210" height="300" alt=""/&gt;&lt;/a&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideocoverart\', coverart, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiVideocoverart\')\n    eg.plugins.Webserver.SetValue(u\'kodiVideotrackTitle\', title, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoshow\', director, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoyear\', year, False, False)\n    \nif type == "channel":\n    label = str(current[\'item\'][\'label\'])\n    thumbnail = str(current[\'item\'][\'thumbnail\'])\n    rating = "0"\n\n    cover = urllib2.unquote(thumbnail).decode(\'utf8\')\n    cover = cover.split(\'//\', 1)\n    cover = cover[1].rsplit("/", 1)\n    cover = cover[0]\n    coverart = \'&lt;a id="kodi.reloadchannels" title="UpdatekodiVideoTracks" name="kodi" class="dynamicdatasend" data-action="reload.channels" href="#kodi_pvr"&gt;&lt;img style="text-align:center;" id="art" src="\' + cover + \'" width="210" height="300" alt=""/&gt;&lt;/a&gt;\'\n    eg.plugins.Webserver.SetValue(u\'kodiVideocoverart\', coverart, False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'kodiVideocoverart\')\n    eg.plugins.Webserver.SetValue(u\'kodiVideotrackTitle\', label, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoshow\', title, False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoinfoholder\', "hide", False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoratingContainer\', "hide", False, False)\n    eg.plugins.Webserver.SetValue(u\'kodiVideoprogressholder\', "hide", False, False)\n\n\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoshow\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideogenre\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideonetworkgenre\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideotrackTitle\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoinfoholder\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoratingContainer\')\neg.plugins.Webserver.BroadcastValue(u\'kodiVideoprogressholder\')\n\n')
                                </Action>
                                <Action>
                                    EventGhost.DisableItem(XmlIdLink(866))
                                </Action>
                                <Action>
                                    EventGhost.EnableItem(XmlIdLink(885))
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.hideaudioplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.hidedefaultplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodi.showvideoplayback', 0.0)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'kodiupdatetoggles', 0.5)
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1065), 2, False)
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set toggles/volume variables">
                                <Event Name="Main.kodiupdatetoggles" />
                                <Action Name="Get/Set propeties mute, volume">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC22.JSONRPC(u\'Application.GetProperties\', u\'{"properties": ["volume", "muted", "name"]}\', False, True)\nvolume = str(int(p[\'volume\']))\neg.plugins.Webserver.SetValue(u\'kodiVolumeLevelChanged\', volume, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodiVolumeLevelChanged\')\nmute = str(p[\'muted\'])\neg.plugins.Webserver.SetValue(u\'kodimute\', mute, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodimute\')')
                                </Action>
                                <Action Name="Get player shuffle, repeat, speed, partymode">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC22.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = p[0][\'playerid\']\n    id = str(id)\n    type = p[0][\'type\']\n    eqimg = \'&lt;img src="images/buttons/eq.gif" width="48" height="24" alt=""/&gt;\'\nexcept IndexError:\n    id = "none"\n    print "id = None"\n    \nj = eg.plugins.XBMC2.JSONRPC(u\'Player.GetProperties\', u\'{"playerid": \' + id + \', "properties": ["repeat", "shuffled", "percentage", "position", "time", "totaltime", "type", "playlistid", "speed", "partymode"]}\', False, True)\nrepeat = str(j[\'repeat\'])\nshuffle = str(j[\'shuffled\'])\nspeed = str(j[\'speed\'])\npartymode = str(j[\'partymode\'])\n\neg.plugins.Webserver.SetValue(u\'kodishuffle\', shuffle, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodishuffle\')\neg.plugins.Webserver.SetValue(u\'kodirepeat\', repeat, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodirepeat\')\neg.plugins.Webserver.SetValue(u\'kodispeed\', speed, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodispeed\')\neg.plugins.Webserver.SetValue(u\'kodipartymode\', partymode, False, False)\neg.plugins.Webserver.BroadcastValue(u\'kodipartymode\')\n')
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Kodi running status" id="1104">
                                <Event Name="Main.OnInit" />
                                <Event Name=".WsClientConnected" />
                                <Event Name=".kodi" />
                                <Action Name="Get/Set active player">
                                    EventGhost.PythonScript(u'p = eg.plugins.XBMC22.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\n\ntry:\n    id = str(p[0][\'playerid\'])\n    type = p[0][\'type\']\n    eg.plugins.Webserver.SetPersistentValue(u\'kodiartactiveplayer\', id, False, False, 1)\n    if id == "0":\n        eg.TriggerEvent("kodiaucioplayeractive")\n        eg.TriggerEvent("kodi.hidedefaultplayback")\n        eg.plugins.Webserver.SetPersistentValue(u\'kodirun_icon\', u\'True\', False, False, 1)\n    if id == "1":\n        eg.TriggerEvent("kodiVideoplayeractive")\n        eg.TriggerEvent("kodi.hidedefaultplayback")\n        eg.plugins.Webserver.SetPersistentValue(u\'kodirun_icon\', u\'True\', False, False, 1)\nexcept IndexError:\n    id = "none"\n    eg.plugins.Webserver.SetPersistentValue(u\'kodiartactiveplayer\', "None", False, False, 1)\n    eg.TriggerEvent("kodishowdefaultplayback")\neg.plugins.Webserver.BroadcastValue(u\'kodirun_icon, kodiroom\', None, u\'\', None)')
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Show/Hide Players">
                            <Macro Name="Hide Default Playback variables (When audio/video player are Active)">
                                <Event Name="Main.kodi.hidedefaultplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_player4holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player4holder', None, u'', None)
                                </Action>
                            </Macro>
                            <Macro Name="Show Default Playback variables (When no player is Active)" id="1114">
                                <Event Name="Main.kodishowdefaultplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_player2holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player1holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player4holder', u'show', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player1holder, kodi_player2holder, kodi_player4holder', None, u'', None)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StopKodiProgress', 0.0)
                                </Action>
                            </Macro>
                            <Macro Name="Hide Audio Playback variables (When video player is Active)">
                                <Event Name="Main.kodi.hideaudioplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_player1holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player1holder', None, u'', None)
                                </Action>
                            </Macro>
                            <Macro Name="Show Audio Playback variables (When video player is Inactive)">
                                <Event Name="Main.kodi.showaudioplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_playeractive', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player1holder', u'show', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_playeractive', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player1holder', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.GetValue(u'kodiplaypause', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "Paused"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StartKodiAudioProgress', 0.0)
                                </Action>
                            </Macro>
                            <Macro Name="Hide Video Playback variables (When audio player is Active)">
                                <Event Name="Main.kodi.hidevideoplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_player2holder', u'hide', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player2holder', None, u'', None)
                                </Action>
                            </Macro>
                            <Macro Name="Show Video Playback variables (When audio player is Inactive)">
                                <Event Name="Main.kodi.showvideoplayback" />
                                <Action>
                                    Webserver.SetValue(u'kodi_playeractive', u'show', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_playeractive', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodi_player2holder', u'show', False, False, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiVideoinfoholder', u'show', False, True, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiVideoratingContainer', u'show', False, True, 1)
                                </Action>
                                <Action>
                                    Webserver.SetValue(u'kodiVideoprogressholder', u'show', False, True, 1)
                                </Action>
                                <Action>
                                    Webserver.BroadcastValue(u'kodi_player2holder, kodiVideoratingContainer, kodiVideoinfoholder, kodiVideoprogressholder, kodi_playeractive', None, u'', None)
                                </Action>
                                <Action>
                                    Webserver.GetValue(u'kodiplaypause', False)
                                </Action>
                                <Action>
                                    EventGhost.PythonCommand(u'eg.result == "Paused"')
                                </Action>
                                <Action>
                                    EventGhost.NewJumpIf(XmlIdLink(1174), 0, False)
                                </Action>
                                <Action>
                                    EventGhost.TriggerEvent(u'StartKodiVideoProgress', 0.0)
                                </Action>
                            </Macro>
                        </Folder>
                        <Folder Name="Get/Set Progress variables">
                            <Macro Name="Stop All Periodic Progress ">
                                <Event Name="Main.StopKodiProgress" />
                                <Event Name="Main.KodiClosed" />
                                <Action>
                                    Webserver.WsStopNamedBroadcastPeriodicTasks(u'kodiprogress')
                                </Action>
                            </Macro>
                            <Macro Name="Start Kodi Audio Progress Slider Periodic Broadcast">
                                <Event Name="Main.StartKodiAudioProgress" />
                                <Action>
                                    Webserver.WsStopNamedBroadcastPeriodicTasks(u'kodiprogress')
                                </Action>
                                <Action>
                                    Webserver.WsPeriodicallyBroadcastData(u'kodiprogress', u'{"kodiprogress", str(eg.globals.getkodi_progress()[\'Progress\']) + "||" + str(eg.globals.getkodi_progress()[\'timeElapsed\']) + "||" + str(eg.globals.getkodi_progress()[\'timeRemain\'])}', u'', False, 1.0)
                                </Action>
                            </Macro>
                            <Macro Name="Get/Set Videoprogress variables">
                                <Event Name="Main.StartKodiVideoProgress" />
                                <Action>
                                    Webserver.WsStopNamedBroadcastPeriodicTasks(u'kodiprogress')
                                </Action>
                                <Action>
                                    Webserver.WsPeriodicallyBroadcastData(u'kodiprogress', u'{"kodiVideoprogress", str(eg.globals.getkodi_progress()[\'Progress\']) + "||" + str(eg.globals.getkodi_progress()[\'timeElapsed\']) + "||" + str(eg.globals.getkodi_progress()[\'timeRemain\'])}', u'', False, 1.0)
                                </Action>
                            </Macro>
                        </Folder>
                        <Macro Name="Set playlist edit mode">
                            <Event Name="kodi.editplaylist" />
                            <Action>
                                EventGhost.PythonScript(u'import urllib2\ntry:\n    p = eg.plugins.XBMC22.JSONRPC(u\'Player.GetActivePlayers\', u\'\', False, True)\nexcept urllib2.HTTPError, e:\n    print e.code\n    eg.Triggerevent("KodiClosed")\nexcept urllib2.URLError, e:\n    print e.args\n    eg.TriggerEvent("KodiClosed")\n\ntry:\n    kodiplayerid = str(p[0][\'playerid\'])\n    eg.plugins.Webserver.SetValue(u\'kodiplayerid\', kodiplayerid, False, False, 1)\n    type = p[0][\'type\']\nexcept IndexError:\n    eg.plugins.Webserver.SetValue(u\'kodiplayerid\', u\'none\', False, False, 1)\n    print "id = None"\n    \nstate = eg.plugins.Webserver.GetPersistentValue(u\'kodi_playlistedit\', False)\n\nif state == "True":\n    eg.plugins.Webserver.SetPersistentValue(u\'kodi_playlistedit\', u\'False\', False, False, 1)\nelif state == "False":\n    eg.plugins.Webserver.SetPersistentValue(u\'kodi_playlistedit\', u\'True\', False, False, 1)\neg.plugins.Webserver.BroadcastValue(u\'kodi_playlistedit\', None, u\'\', None)')
                            </Action>
                            <Action>
                                Webserver.GetValue(u'kodiplayerid', False)
                            </Action>
                            <Action>
                                EventGhost.PythonCommand(u'eg.result == "0"')
                            </Action>
                            <Action>
                                EventGhost.NewJumpIf(XmlIdLink(1057), 0, False)
                            </Action>
                            <Action>
                                Webserver.GetValue(u'kodiplayerid', False)
                            </Action>
                            <Action>
                                EventGhost.PythonCommand(u'eg.result == "1"')
                            </Action>
                            <Action>
                                EventGhost.NewJumpIf(XmlIdLink(1065), 0, False)
                            </Action>
                        </Macro>
                        <Macro Name="Null macro" id="1174" />
                    </Folder>
                </Folder>
            </Folder>
        </Folder>
        <Folder Name="Sonos" Enabled="False">
            <Folder Name="Actions">
                <Macro Name="Previous">
                    <Event Name="prev.sonos" />
                    <Action>
                        Sonos.Previous(u'RINCON_B8E937BE5A1601400')
                    </Action>
                </Macro>
                <Macro Name="Play/Pause">
                    <Event Name="sonos.sonosplaypause" />
                    <Action>
                        EventGhost.PythonScript(u'state = eg.plugins.Webserver.GetValue(u\'sonosplaypause\', False)\nif state == "Playing":\n    eg.plugins.Sonos.Pause(u\'RINCON_B8E937BE5A1601400\')\n    eg.plugins.Webserver.SetValue(u\'sonosplaypause\', "Paused", False, False)\nif state == "Paused":\n    eg.plugins.Sonos.Play(u\'RINCON_B8E937BE5A1601400\')\n    eg.plugins.Webserver.SetValue(u\'sonosplaypause\', "Playing", False, False)\nif state == "Stopped":\n    eg.plugins.Sonos.Play(u\'RINCON_B8E937BE5A1601400\')\n    eg.plugins.Webserver.SetValue(u\'sonosplaypause\', "Playing", False, False) \n  \neg.plugins.Webserver.BroadcastValue(u\'sonosplaypause\')')
                    </Action>
                </Macro>
                <Macro Name="Next">
                    <Event Name="next.sonos" />
                    <Action>
                        Sonos.Next(u'RINCON_B8E937BE5A1601400')
                    </Action>
                </Macro>
                <Macro Name="VolumeSet">
                    <Event Name="Volume.sonosVolumeLevelChanged" />
                    <Action>
                        EventGhost.PythonScript(u"payload = eg.event.payload\n\neg.plugins.Sonos.VolumeSet(u'RINCON_B8E937BE5A1601400', payload)")
                    </Action>
                    <Action>
                        Webserver.SetValue(u'sonosVolumeLevelChanged', u'{str(eg.event.payload)}', False, False)
                    </Action>
                    <Action>
                        Webserver.BroadcastValue(u'sonosVolumeLevelChanged')
                    </Action>
                </Macro>
                <Macro Name="Mute">
                    <Event Name="sonos.sonosmuted" />
                    <Action>
                        EventGhost.PythonScript(u'state = eg.plugins.Webserver.GetValue(u\'sonosmute\', False)\nif state == "True":\n    eg.plugins.Sonos.MuteOff(u\'RINCON_B8E937BE5A1601400\')\nelif state == "False":\n    eg.plugins.Sonos.MuteOn(u\'RINCON_B8E937BE5A1601400\')')
                    </Action>
                </Macro>
                <Folder Name="need work">
                    <Macro Name="SetPlayMode: Repeat">
                        <Event Name="sonos.sonosrepeated" />
                        <Action>
                            Sonos.SetPlayMode(u'RINCON_B8E937BE5A1601400', u'SHUFFLE')
                        </Action>
                    </Macro>
                    <Macro Name="SetPlayMode: Shuffle">
                        <Event Name="sonos.sonosshuffled" />
                        <Action>
                            Sonos.SetPlayMode(u'RINCON_B8E937BE5A1601400', u'REPEAT_ALL')
                        </Action>
                    </Macro>
                </Folder>
            </Folder>
            <Folder Name="Get/Set Variables">
                <Macro Name="Webserver: Set Volume slider">
                    <Event Name="SONOS.RINCON_B8E937BE5A1601400.Volume" />
                    <Action>
                        EventGhost.PythonScript(u'import re\npayload = eg.event.payload\nvol = payload.split("-")\nvolume = vol[1].split(" ")\nvolume = volume[0]\n\neg.plugins.Webserver.SetValue(u\'sonosVolumeLevelChanged\', volume, False, False)\neg.plugins.Webserver.BroadcastValue(u\'sonosVolumeLevelChanged\')')
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set Artist">
                    <Event Name="SONOS.RINCON_B8E937BE5A1601400.Artist" />
                    <Action>
                        EventGhost.PythonScript(u'payload = eg.event.payload\npay = payload.split(":")\nartist = pay[1]\neg.plugins.Webserver.SetValue(u\'sonosartist\', artist, False, False)\neg.plugins.Webserver.BroadcastValue(u\'sonosartist\')')
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set Track Source">
                    <Event Name="SONOS.RINCON_B8E937BE5A1601400.Source" />
                    <Action>
                        EventGhost.PythonScript(u'payload = eg.event.payload\npay = payload.split(":")\nsource = pay[1]\neg.plugins.Webserver.SetValue(u\'sonosalbum\', source, False, False)\neg.plugins.Webserver.BroadcastValue(u\'sonosalbum\')')
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set Track Title">
                    <Event Name="SONOS.RINCON_B8E937BE5A1601400.Title" />
                    <Action>
                        EventGhost.PythonScript(u'payload = eg.event.payload\npay = payload.split(":")\ntrack = pay[1]\neg.plugins.Webserver.SetValue(u\'sonostrackTitle\', track, False, False)\neg.plugins.Webserver.BroadcastValue(u\'sonostrackTitle\')')
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set Artwork">
                    <Event Name="SONOS.RINCON_B8E937BE5A1601400.AlbumArtWorkURL" />
                    <Action>
                        EventGhost.PythonScript(u'payload = eg.event.payload\npay = payload.split(":", 1)\nart = pay[1]\ncover =\'&lt;a id="sonos.reloadtracks" name="reloadtracks" class="dynamicdatasend" data-action="reload.tracks" href="#sonostracks"&gt;&lt;img style="text-align:center;" id="art" src="\' + art + \'" width="250" height="250" alt=""/&gt;&lt;/a&gt;\'\neg.plugins.Webserver.SetValue(u\'sonoscoverart\', cover, False, False)\neg.plugins.Webserver.BroadcastValue(u\'sonoscoverart\')')
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set Mute">
                    <Event Name="SONOS.RINCON_B8E937BE5A1601400.Mute" />
                    <Action>
                        EventGhost.PythonScript(u'payload = eg.event.payload\npay = payload.split("-")\nmute = pay[1].split(" ")\nmute = mute[0]\nif mute == "0":\n    eg.plugins.Webserver.SetValue(u\'sonosmute\', "False", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'sonosmute\')\nelif mute == "1":\n    eg.plugins.Webserver.SetValue(u\'sonosmute\', "True", False, False)\n    eg.plugins.Webserver.BroadcastValue(u\'sonosmute\')')
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set Playstate - Playing">
                    <Event Name="SONOS.RINCON_B8E937BE5A1601400.Playing" />
                    <Action>
                        EventGhost.PythonScript(u'eg.plugins.Webserver.SetPersistentValue(u\'sonosplaypause\', "Playing", False, False)\neg.plugins.Webserver.BroadcastValue(u\'sonosplaypause\')')
                    </Action>
                </Macro>
                <Macro Name="Webserver: Set Playstate - Stopped">
                    <Event Name="SONOS.RINCON_B8E937BE5A1601400.Stopped" />
                    <Action>
                        EventGhost.PythonScript(u'eg.plugins.Webserver.SetPersistentValue(u\'sonosplaypause\', "Stopped", False, False)\neg.plugins.Webserver.BroadcastValue(u\'sonosplaypause\')')
                    </Action>
                </Macro>
            </Folder>
        </Folder>
        <Folder Name="Weather (Suntracker)" Expanded="True">
            <Macro Name="Change Location">
                <Event Name="WU.ChangeLocation" />
                <Event Name="WU.zipsend" />
                <Action Name="Suntracker">
                    EventGhost.PythonScript(u"zip = str(eg.event.payload)\neg.plugins.Suntracker.SetLocation(u'EGwebTempLocation', '0.0', '0.0', zip, u'0101,0501,0606,1224,1225,1226', u'0106,0402,0405,0512,0522,0523,0625', u'06', u'10', u'+01.00')")
                </Action>
                <Action Enabled="False">
                    Suntracker.SetLocation(u'WS-location', '18.0', '59.25', u'{eg.event.payload}', u'0101,0501,0606,1224,1225,1226', u'0106,0402,0405,0512,0522,0523,0625', u'--', u'--', u'+01.00')
                </Action>
                <Action>
                    EventGhost.TriggerEvent(u'updateCurrentweather', 2.0)
                </Action>
            </Macro>
            <Macro Name="Get/Set weather variables (Suntracker/Imperial)">
                <Event Name=".WsClientConnected" />
                <Event Name="Main.updateCurrentweather" />
                <Event Name=".updateCurrentweather" />
                <Action Name="Get/Set 5 day forecast variables (Suntracker)">
                    EventGhost.PythonScript(u'import datetime\n\n# Initialize variables\nnumber = -1\n\n# Request weather info\nb = eg.plugins.Suntracker.GetForecasts()\n\n# Parse Return\nSunrise = b[0][\'sunrise\'].split(" ")\nSunrise = Sunrise[0]\nSunset = b[0][\'sunset\'].split(" ")\nSunset = Sunset[0]\nDrain = str(b[0][\'day\'][\'chance_precip\']) + "%"\n\nfor item in b:\n    \n    number = int(number) + 1\n    Day = \'D\' + str(number)\n    strdate = item[\'day_of_week\']\n    Date = strdate + \' - \' +  item[\'date\']\n    High = str(item[\'high\']) + "&amp;deg;"\n    Low = str(item[\'low\']) + "&amp;deg;"\n    Condition = item[\'day\'][\'text\']\n    if Condition == "":\n        Condition = "Sunny"\n    Rain = str(item[\'day\'][\'chance_precip\']) + \'%\'\n    Humidity = str(item[\'day\'][\'humidity\']) + \'%\'\n    d = item[\'day\'][\'wind\'][\'direction\']\n    mph = item[\'day\'][\'wind\'][\'speed\']\n    Wind = "Winds " + item[\'day\'][\'wind\'][\'text\'] + "&amp;nbsp;at " + mph + "mph"\n    nt = item[\'night\'][\'text\']\n    np = item[\'night\'][\'chance_precip\']\n    nh = item[\'night\'][\'humidity\']\n    nwd = item[\'night\'][\'wind\'][\'direction\']\n    nws = item[\'night\'][\'wind\'][\'speed\']\n    nwt = item[\'night\'][\'wind\'][\'text\']\n    \n    #Sets Weather Icon variable\n    if Condition == "Clear":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_clear.png" alt=""/&gt;\'\n    elif Condition == "Sunny":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_clear.png" alt=""/&gt;\'\n    elif Condition == "Mostly Sunny":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_clear.png" alt=""/&gt;\'\n    elif Condition == "Overcast":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_cloudy.png" alt=""/&gt;\'\n    elif Condition == "Partly Cloudy":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_slightly_cloudy.png" alt=""/&gt;\'\n    elif Condition == "Mostly Cloudy":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_cloudy.png" alt=""/&gt;\'\n    elif Condition == "Scattered Clouds":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_cloudy.png" alt=""/&gt;\'\n    elif Condition == "Slightly Cloudy":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_slightly_cloudy.png" alt=""/&gt;\'\n    elif Condition == "Mostly Cloudy":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_cloudy.png" alt=""/&gt;\'\n    elif Condition == "Cloudy":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_cloudy.png" alt=""/&gt;\'\n    elif Condition == "AM Clouds / PM Sun":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_cloudy.png" alt=""/&gt;\'\n    elif Condition == "PM Showers":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_shower.png" alt=""/&gt;\'\n    elif Condition == "Chance of Rain":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_shower.png" alt=""/&gt;\'\n    elif Condition == "PM Rain / Wind":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_shower.png" alt=""/&gt;\'\n    elif Condition == "AM Showers":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_shower.png" alt=""/&gt;\'\n    elif Condition == "Chance of a Thunderstorm":\n        Condition = "Thunderstorms"\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_thunderstorm.png" alt=""/&gt;\'\n    elif Condition == "Thunderstorms":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_thunderstorm.png" alt=""/&gt;\'\n    elif Condition == "Showers":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_shower.png alt=""/&gt;\'\n    elif Condition == "Rain":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_rain.png" alt=""/&gt;\'\n    elif Condition == "Rain / Wind":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_rain.png" alt=""/&gt;\'\n    elif Condition == "Rainy":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_rain.png" alt=""/&gt;\'\n    elif Condition == "Snow":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_snow.png" alt=""/&gt;\'\n    elif Condition == "Snow Shower":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_snow.png" alt=""/&gt;\'\n    elif Condition == "Thunderstorms":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_thunderstorm.png" alt=""/&gt;\'\n    elif Condition == "Sleet":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/sleet.png" alt=""/&gt;\'\n    elif Condition == "Flurries":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/day_snow.png" alt=""/&gt;\'\n    elif Condition == "Hail":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/hail.png" alt=""/&gt;\'\n    elif Condition == "Freezing Rain":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/snow-rain.png" alt=""/&gt;\'\n    elif Condition == "Snow Showers":\n        img = \'&lt;img style="padding-left:5px; height:80px; width:80px;" src="images/weather/snow-rain.png" alt=""/&gt;\'\n    else:\n        img = \'\'\n    if Day != "0":\n        #Sets Webserver Temporary variables\n        eg.plugins.Webserver.SetValue(Day + "date", \'&lt;div style="display:inline-block; vertical-align:text-bottom; padding:0px;"&gt;&lt;img style="height:24px; width:24px;" src="/images/cloud_lg.png"&gt;&lt;/div&gt;&lt;h2 style="display:inline-block; margin-bottom:3px;"&gt;&amp;nbsp;&amp;nbsp;\' + Date + \'&lt;/h2&gt;\', False, False)\n        eg.plugins.Webserver.SetValue(Day + "condition", \'&lt;h6&gt;\' + Condition + \'&lt;/h6&gt;&lt;p id="\' + Day + \'wind" class="weekrain"&gt;&lt;/p&gt;\', False, False)\n        eg.plugins.Webserver.SetValue(Day + "wind", Wind, False, False)\n        eg.plugins.Webserver.SetValue(Day + "high", High, False, False)\n        eg.plugins.Webserver.SetValue(Day + "low", Low, False, False)\n        eg.plugins.Webserver.SetValue(Day + "rain", Rain, False, False)\n        eg.plugins.Webserver.SetValue(Day + "hum", Humidity, False, False)\n        eg.plugins.Webserver.SetValue(Day + "icon", img, False, False)\n\n        #Broadcast Webserver Temporary variables\n        eg.plugins.Webserver.BroadcastValue(Day + "date")\n        eg.plugins.Webserver.BroadcastValue(Day + "condition")\n        eg.plugins.Webserver.BroadcastValue(Day + "wind")\n        eg.plugins.Webserver.BroadcastValue(Day + "high")\n        eg.plugins.Webserver.BroadcastValue(Day + "low")\n        eg.plugins.Webserver.BroadcastValue(Day + "rain")\n        eg.plugins.Webserver.BroadcastValue(Day + "hum")\n        eg.plugins.Webserver.BroadcastValue(Day + "icon")\n    \n# Broadcasts Sunrise/Sunset variables to the websocket client\neg.plugins.Webserver.SetPersistentValue(u\'D0sunrise\', Sunrise, False, False)\neg.plugins.Webserver.SetPersistentValue(u\'D0sunset\', Sunset, False, False)\neg.plugins.Webserver.SetValue(u\'D0rain\', Drain, False, False)\neg.plugins.Webserver.BroadcastValue(u\'D0sunrise\')\neg.plugins.Webserver.BroadcastValue(u\'D0sunset\')\neg.plugins.Webserver.BroadcastValue(u\'D0rain\')\n')
                </Action>
                <Action Name="Get/Set Current weather variables (Suntracker)">
                    EventGhost.PythonScript(u'# initialize variables\ntime = "day"\nzip = eg.plugins.Webserver.GetPersistentValue(u\'WUzipcode\', False)\nzip = str(zip)\n\n# Request Weather fron Suntracker\nweather = eg.plugins.Suntracker.GetCurrentCondition()\n\n# Parse Suntracker Return\nTemp = str(weather[\'temperature\'])\ncondition = weather[\'text\']\nHumidity = str(weather[\'humidity\']) + \'%\'\nstation = weather[\'station\'].rsplit(\',\', 1)\nLocation = station[0]\nFeelslike =  str(weather[\'feels_like\'])\nmph =  \'&amp;nbsp;winds at \' + str(weather[\'wind\'][\'speed\']) + \' mph\'\nDirection = weather[\'wind\'][\'text\']\n# Request Day/Night Cycle\nstate = eg.plugins.Suntracker.GetSunState()\nif state == False:\n    time = "night"\nelse:\n    time = "day"\n\n# Sets the weather icon based on weather condition &amp; time of day\nif (condition == "" and time == "night"): \n    condition = "Clear"\n    img = \'&lt;img src="images/weather/night_clear.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "" and time == "day"):\n    condition = "Clear"\n    img = \'&lt;img src="images/weather/day_clear.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "" and time == "night"): \n    condition = "Sunny"\n    img = \'&lt;img src="images/weather/night_clear.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "" and time == "day"):\n    condition = "Sunny"\n    img = \'&lt;img src="images/weather/day_clear.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Clear" and time == "night"):\n    img = \'&lt;img src="images/weather/night_clear.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Clear" and time == "day"):\n    img = \'&lt;img src="images/weather/day_clear.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Sunny" and time == "night"):\n    img = \'&lt;img src="images/weather/night_clear.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Sunny" and time == "day"):\n    img = \'&lt;img src="images/weather/day_clear.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Overcast" and time == "night"):\n    img = \'&lt;img src="images/weather/night_cloudy.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Overcast" and time == "day"):\n    img = \'&lt;img src="images/weather/day_cloudy.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Fair" and time == "night"):\n    img = \'&lt;img src="images/weather/night_cloudy.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Fair" and time == "day"):\n    img = \'&lt;img src="images/weather/day_cloudy.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Partly Cloudy" and time == "night"):\n    img = \'&lt;img src="images/weather/night_slightly_cloudy.png" width="200" height="200"  alt=""/&gt;\'\nif (condition == "Partly Cloudy" and time == "day"):\n    img = \'&lt;img src="images/weather/day_slightly_cloudy.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Cloudy / Windy" and time == "day"):\n    img = \'&lt;img src="images/weather/day_slightly_cloudy.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Cloudy / Windy" and time == "night"):\n    img = \'&lt;img src="images/weather/night_slightly_cloudy.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Scattered Clouds" and time == "night"):\n    img = \'&lt;img src="images/weather/night_slightly_cloudy.png" width="200" height="200"  alt=""/&gt;\'\nif (condition == "Scattered Clouds" and time == "day"):\n    img = \'&lt;img src="images/weather/day_slightly_cloudy.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Mostly Cloudy" and time == "night"):\n    img = \'&lt;img src="images/weather/night_cloudy.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Mostly Cloudy" and time == "day"):\n    img = \'&lt;img src="images/weather/day_cloudy.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Cloudy" and time == "night"):\n    img = \'&lt;img src="images/weather/night_cloudy.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Cloudy" and time == "day"):\n    img = \'&lt;img src="images/weather/day_cloudy.png" width="200" height="200" alt=""/&gt;\'\n\nif (condition == "Chance of Rain" and time == "night"):\n    img = \'&lt;img src="images/weather/night_shower.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Chance of Rain" and time == "day"):\n    img = \'&lt;img src="images/weather/day_shower.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Rain" and time == "night"):\n    img = \'&lt;img src="images/weather/night_rain.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Rain" and time == "day"):\n    img = \'&lt;img src="images/weather/day_rain.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Heavy Thunderstorms and Rain" and time == "night"):\n    img = \'&lt;img src="images/weather/night_rain.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Heavy Thunderstorms and Rain" and time == "day"):\n    img = \'&lt;img src="images/weather/day_rain.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Light Thunderstorms and Rain" and time == "night"):\n    img = \'&lt;img src="images/weather/night_rain.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Light Thunderstorms and Rain" and time == "day"):\n    img = \'&lt;img src="images/weather/day_rain.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Light Rain" and time == "night"):\n    img = \'&lt;img src="images/weather/night_rain.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Light Rain" and time == "day"):\n    img = \'&lt;img src="images/weather/day_rain.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Snow" and time == "night"):\n    img = \'&lt;img src="images/weather/night_snow.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Snow" and time == "day"):\n    img = \'&lt;img src="images/weather/day_snow.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Thunderstorm" and time == "night"):\n    img = \'&lt;img src="images/weather/night_thunderstorm.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Thunderstorm" and time == "day"):\n    img = \'&lt;img src="images/weather/day_thunderstorm.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Thunderstorms" and time == "night"):\n    img = \'&lt;img src="images/weather/night_thunderstorm.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Thunderstorms" and time == "day"):\n    img = \'&lt;img src="images/weather/day_thunderstorm.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Sleet" and time == "night"):\n    img = \'&lt;img src="images/weather/sleet.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Sleet" and time == "day"):\n    img = \'&lt;img src="images/weather/sleet.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Flurries" and time == "night"):\n    img = \'&lt;img src="images/weather/night_snow.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Flurries" and time == "day"):\n    img = \'&lt;img src="images/weather/day_snow.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Hail" and time == "night"):\n    img = \'&lt;img src="images/weather/hail.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Hail" and time == "day"):\n    img = \'&lt;img src="images/weather/hail.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Freezing Rain" and time == "night"):\n    img = \'&lt;img src="images/weather/snow-rain.png" width="200" height="200" alt=""/&gt;\'\nif (condition == "Snow Showers" and time == "day"):\n    img = \'&lt;img src="images/weather/snow-rain.png" width="200" height="200" alt=""/&gt;\'\nif time == "night": \n    img2 = \'&lt;img src="images/weather/night_clear.png" width="200" height="200" alt=""/&gt;\'\n\n\n# Sets Temporary Variables &amp; Broadcasts Varaiables to the websocket client\nif time == "day":\n    eg.plugins.Webserver.SetValue(u\'D0rainimg\', \'&lt;img style="vertical-align:text-bottom; padding-right:6px; height:24px; width:24px;" src="images/rain.png" alt=""&gt;\', False, False)\nelse:\n    eg.plugins.Webserver.SetValue(u\'D0rainimg\', \'&lt;img style="vertical-align:text-bottom; padding-right:6px; height:24px; width:24px;" src="images/rain2.png" alt=""&gt;\', False, False)\neg.plugins.Webserver.BroadcastValue(u\'D0rainimg\')\neg.plugins.Webserver.SetValue(u\'D0currenttemp\', Temp, False, False)\neg.plugins.Webserver.BroadcastValue(u\'D0currenttemp\')\neg.plugins.Webserver.SetValue(u\'D0feelslike\', Feelslike, False, False)\neg.plugins.Webserver.BroadcastValue(u\'D0feelslike\')\neg.plugins.Webserver.SetValue(u\'D0condition\', condition, False, False)\neg.plugins.Webserver.BroadcastValue(u\'D0condition\')\neg.plugins.Webserver.SetValue(u\'weather_D0_icon\', img, False, False)\neg.plugins.Webserver.BroadcastValue(u\'weather_D0_icon\')\neg.plugins.Webserver.SetValue(u\'weather_background\', time, False, False)\neg.plugins.Webserver.BroadcastValue(u\'weather_background\')\neg.plugins.Webserver.SetValue(u\'D0winddir\', Direction, False, False)\neg.plugins.Webserver.BroadcastValue(u\'D0winddir\')\neg.plugins.Webserver.SetValue(u\'D0windspd\', mph, False, False)\neg.plugins.Webserver.BroadcastValue(u\'D0windspd\')\neg.plugins.Webserver.SetValue(u\'D0humidity\', Humidity, False, False)\neg.plugins.Webserver.BroadcastValue(u\'D0humidity\')\neg.plugins.Webserver.SetValue(u\'weatherlocation\', Location, False, False)\neg.plugins.Webserver.BroadcastValue(u\'weatherlocation\')\n')
                </Action>
            </Macro>
        </Folder>
        <Folder Name="Timer">
            <Macro Name="Start a timer">
                <Event Name="sendtimer.eg" />
                <Action Name="Start a timer">
                    EventGhost.PythonScript(u'# Parse the payload\nseconds = eg.event.payload[1]\nminutes = eg.event.payload[0]\n\n# Error handling when no seconds submitted\nif seconds == "":\n    seconds = "0"\n\n# Conversion to Seconds\nif minutes != "":\n    minutes = int(minutes)\nelse:\n    minutes = 0\nmseconds = minutes * 60\ntimer = str(mseconds + int(seconds))\n\n\n# Send Value to Webserver\neg.plugins.Webserver.SetValue(u\'starttimer\', timer, False, False, 1)\neg.plugins.Webserver.BroadcastValue(u\'starttimer\', None, u\'\', None)\ntimer = float(timer)\neg.plugins.Timer.TimerAction(u\'timer\', 0, 1, timer, u\'timerdone\', False, True, 1, u\'00:00:00\')')
                </Action>
            </Macro>
            <Macro Name="Play Sound When Timer's done: (This needs to be changed to the location of your HTML\sounds\Timer alarm.wav">
                <Event Name="Timer.timerdone" />
                <Action>
                    System.PlaySound(u'D:\\WS - Demo\\sounds\\Timer alarm.wav', 1, False)
                </Action>
            </Macro>
        </Folder>
        <Folder Name="Notes">
            <Macro Name="Set Persistent notes values">
                <Event Name="newitem.notesbtn" />
                <Action Name="Set Persistent Notes item">
                    EventGhost.PythonScript(u'p = eg.event.payload\n\n# Error handling for no value sent\nif p == "newnotesitem":\n    print "Nothing Added"\nelse:\n    # Parse variable and sets it\'s persistent value\n    p = p.split(".")\n    name = p[0]\n    number =  int(p[1])\n    num = str(number - 1)\n    number = "Persistentnotesitem" + number\n    eg.plugins.Webserver.SetPersistentValue(number, name, False, False)')
                </Action>
            </Macro>
            <Macro Name="Delete Persistent notes values">
                <Event Name="Delete.notesitem" />
                <Action>
                    Webserver.DeletePersistentValue(u'{"Persistent" + eg.event.payload}', False)
                </Action>
            </Macro>
            <Macro Name="Rebuild Notes list from persistent variables">
                <Event Name=".WsClientConnected" />
                <Action Name="Rebuild notes items">
                    EventGhost.PythonScript(u'# Set the max number of notes you want displayed: Currently 20\nnumbers = (range(20))\n\n# Reads your note variables and sends values to build your note items on WS.Client.Connected\nfor x in numbers:\n    num = str(x)\n    id = "notesitem" + num\n    pnum = \'Persistentnotesitem\' + num \n    item = str(eg.plugins.Webserver.GetPersistentValue(pnum, False))\n    if item != "None":\n        eg.plugins.Webserver.SetValue(id, item, False, False)\n        eg.plugins.Webserver.BroadcastValue(id)')
                </Action>
            </Macro>
        </Folder>
        <Folder Name="Groceries">
            <Macro Name="Set Persistent grocery values">
                <Event Name="newitem.grocerybtn" />
                <Action Name="Set Persistent Grocery item">
                    EventGhost.PythonScript(u'p = eg.event.payload\n\n# Error handling for no value sent\nif p == "newgroceryitem":\n    print "Nothing added"\n    \n# Parse variable and sets it\'s persistent value\nelse:\n    p = p.split(".")\n    name = p[0]\n    number =  int(p[1])\n    number = str(number - 1)\n    number = "Persistentgroceryitem" + number\n    eg.plugins.Webserver.SetPersistentValue(number, name, False, False)')
                </Action>
            </Macro>
            <Macro Name="Delete Persistent notes values">
                <Event Name="Delete.groceryitem" />
                <Action>
                    Webserver.DeletePersistentValue(u'{"Persistent" + eg.event.payload}', False)
                </Action>
            </Macro>
            <Macro Name="Rebuild Groceryl list from persistent variables">
                <Event Name=".WsClientConnected" />
                <Action Name="Rebuild grocery items">
                    EventGhost.PythonScript(u'# Sets the number of grocery items you want displayed: Currently 20\nnumbers = (range(20))\n\n# Reads your note variables and sends values to build your grocery items on WS.Client.Connected\nfor x in numbers:\n    num = str(x)\n    id = "groceryitem" + num\n    pnum = \'Persistentgroceryitem\' + num \n    item = str(eg.plugins.Webserver.GetPersistentValue(pnum, False))\n    if item != "None":\n        eg.plugins.Webserver.SetValue(id, item, False, False)\n        eg.plugins.Webserver.BroadcastValue(id)')
                </Action>
            </Macro>
        </Folder>
    </Folder>
</EventGhost>
