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

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

http url monitor plugin

If you have a question or need help, this is the place to be.
Post Reply
eadmaster
Posts: 7
Joined: Sat Oct 26, 2013 2:13 pm
Location: Italy
Contact:

http url monitor plugin

Post by eadmaster »

is there a plugin to monitor an http remote url for changes?
e.g.: the page has been updated since yesterday, etc.
User avatar
Pako
Plugin Developer
Posts: 2294
Joined: Sat Nov 11, 2006 1:31 pm
Location: Czech Republic
Contact:

Re: http url monitor plugin

Post by Pako »

Why create a plugin for such a simple task?
It can handle a simple script:
URLchangeWatching.png
URLchangeWatching.png (5.77 KiB) Viewed 1682 times
Here's a copy:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1640">
    <Folder Name="URLchange watching" Expanded="True">
        <Macro Name="Python Script START watching" Expanded="True">
            <Event Name="Main.OnInit" />
            <Action>
                EventGhost.PythonScript(u'url = r"http://musicbee.niblseed.com/V2_2/"\nperiod = 60 #60 seconds polling period\nimport urllib\n\ndef getPage(u):\n    return urllib.urlopen(u).read().decode(\'utf8\')    \n\ndef watchPage():\n    if eg.globals.watchFlag:\n        eg.scheduler.AddTask(period, watchPage)\n        page = getPage(url)\n        if eg.globals.watchedPage != page:\n            eg.globals.watchedPage = page\n            eg.TriggerEvent("PageChanged", prefix = "URL", payload = url)\n    else:\n        eg.PrintNotice("Watch page task canceled")\n\n\nif not "watchFlag" in eg.globals.__dict__ or eg.globals.watchFlag == False:\n    eg.globals.watchedPage = getPage(url)\n    eg.globals.watchFlag = True\n\nwatchPage()\n        \n')
            </Action>
        </Macro>
        <Macro Name="Python Script STOP watching" Expanded="True">
            <Action>
                EventGhost.PythonScript(u'if "watchFlag" in  eg.globals.__dict__:\n    eg.globals.watchFlag = False\n')
            </Action>
        </Macro>
    </Folder>
</EventGhost>
You can use copy/paste to paste into your configuration tree.

Pako
Post Reply