maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [Announce] Queen BeeCon Widget: Super powerful and customizable Widget Generation Engine - Official Thread (https://talk.maemo.org/showthread.php?t=45388)

gkuenning 2010-05-22 19:21

Re: [Announce] Queen BeeCon Widget: Customizable and flexible monitoring tool.
 
So MLBeeCon is truly wonderful; thanks, No!No!No!Yes!

But I follow more than one team. And of course some people care about seeing certain teams lose, e.g. during a pennant race. So here's a somewhat fancier script. Drop it someplace convenient (I put it in /home/user/bin) and make it executable (chmod +x script-name). Then invoke it as:

/home/user/bin/mlbeecon CWS CWC -STL

which says you want to cheer for the White Sox, the Cubs, and whoever is playing Saint Louis.

The icon smiles if more of your teams win than lose, frowns if losers outnumber winners, and is smug if everything is balanced.

Code:

#!/bin/bash
#
# Fetch MLB scores and colorize them for use with Queen BeeCon.
#
USAGE='Usage: mlbeecon [team] [team] [-team] ...'
#
# Each team is an abbreviation used on the m.mlb.com site.  A team preceded
# by a minus sign is a "team you love to hate;" the icon becomes happy if
# that team loses.  The icon is happy if more teams win than lose, angry
# if losing dominates, and smug if the losers equal the winners.  (Ties
# aren't considered in this calculation.)

# Since ESPN thinks the world runs on Eastern time, use that for the
# date/time display at the top.  That makes it easier to read the
# schedule.  Change this field to $TZ if you prefer using your own
# timezone.
DISPLAYZONE=US/Eastern
#DISPLAYZONE=$TZ

# When we fetch the scores, we use a time zone a few hours to the
# west; this ensures that games that are in progress after midnight
# EST will still be shown; the next day's schedule won't come up until
# about 6 AM EST.
GRABZONE=US/Hawaii

echo "<span foreground=\"green\"><big><i>[`TZ=$DISPLAYZONE date '+%m/%d/%Y %H:%M'`]</i></big></span>"
wget -t 1 -T 10 -q -O - http://m.mlb.com/scores/`TZ=$GRABZONE date +%Y%m%d`/ \
  | awk 'BEGIN \
        {
        ntm = split("'"$*"'", tm)
        w = 0
        l = 0
        t = 0
        inScoreboard = 0
        inGame = 0
        }
    /<div.*id="scoreboard_module".*>/ \
        {
        inScoreboard = 1
        next
        }
    /<a href/  &&  inScoreboard \
        {
        split($0, linkLine, ">")
        inGame = 1
        next
        }
    /<\/div/  &&  inScoreboard \
        {
        inScoreboard = 0
        inGame = 0
        next
        }
    inGame \
        {
        if ($1 == "-"  ||  $1 == "vs.")
            {
            vsLine = $1
            next
            }
        inGame = 0
        split(linkLine[2], visitor)
        home = $1
        ist = 0
        for (i = 1;  i <= ntm;  i++)
            {
            ct = tm[i]
            bad = 0
            if (ct ~ /^-/)
                {
                bad = 1
                ct = substr(ct, 2)
                }
            if (visitor[1] == ct  ||  home == ct)
                {
                ist = 1
                break
                }
            }
        if (!ist)
            {
            print linkLine[2], vsLine, $0
            next
            }
        print "<span foreground=\"cyan\"><b><big>" linkLine[2], \
          vsLine, $0 "</big></b></span>"
        if (vsLine == "vs."  ||  visitor[2] == $2)
            t++
        else if ((visitor[1] == ct  &&  visitor[2] > $2) \
          ||  ($1 == ct  &&  $2 > visitor[2]))
            {
            w += !bad
            l += bad
            }
        else
            {
            w += bad
            l += !bad
            }
        }
    END \
        {
        if (w + l + t == 0)
            {
            print "No\nMatch!\n"
            exit 1
            }
        else if (w > l)
            exit 0
        else if (w < l)
            exit 2
        else
            exit 1
        }'
exit

# Old code
wget -t 1 -T 10 -q -O - http://m.mlb.com/scores/`TZ=$GRABZONE date +%Y%m%d`/ \
  | awk 'BEGIN \
        {
        ntm = split("'"$*"'", tm)
        w = 0
        l = 0
        t = 0
        }
    /<td>.+<\/td>/ \
        {
        s = gensub(/<[^>]*>/, "", "g")
        s = gensub(/[\t ]+/, " ", "g", s)
        split(s, a)
        ist = 0
        for (i = 1;  i <= ntm;  i++)
            {
            ct = tm[i]
            bad = 0
            if (ct ~ /^-/)
                {
                bad = 1
                ct = substr(ct, 2)
                }
            if (a[1] == ct  ||  a[3] == ct  ||  a[4] == ct)
                {
                ist = 1
                break
                }
            }
        if (!ist)
            {
            print s
            next
            }
        print "<span foreground=\"cyan\"><b><big>" s "</big></b></span>"
        if (a[2] == "vs."  ||  a[5] == a[2])
            t++
        else if ((a[4] == ct  &&  a[5] > a[2]) \
          ||  (a[1] == ct  &&  a[2] > a[5]))
            {
            w += !bad
            l += bad
            }
        else
            {
            w += bad
            l += !bad
            }
        }
    END \
        {
        if (w + l + t == 0)
            {
            print "No\nMatch!\n"
            exit 1
            }
        else if (w > l)
            exit 0
        else if (w < l)
            exit 2
        else
            exit 1
        }'

EDIT 19-Aug-2010: one of the problems with screen scraping is that it breaks when the Web site changes its layout. ESPN just did that; this edit contains a rewritten version that works with the new ESPN site design.

rolan900d 2010-05-22 19:39

Re: [Announce] Queen BeeCon Widget: Customizable and flexible monitoring tool.
 
Quote:

Originally Posted by No!No!No!Yes! (Post 670598)
While proper backup/restore developments are in the brewery you can have a look HERE

That made sense!

Cheers

No!No!No!Yes! 2010-05-22 19:51

Re: [Announce] Queen BeeCon Widget: Customizable and flexible monitoring tool.
 
Quote:

Originally Posted by gkuenning (Post 670734)
So MLBeeCon is truly wonderful; thanks, No!No!No!Yes!

But I follow more than one team. And of course some people care about seeing certain teams lose, e.g. during a pennant race. So here's a somewhat fancier script. Drop it someplace convenient (I put it in /home/user/bin) and make it executable (chmod +x script-name). Then invoke it as:

/home/user/bin/mlbeecon CWS CWC -STL

which says you want to cheer for the White Sox, the Cubs, and whoever is playing Saint Louis.

The icon smiles if more of your teams win than lose, frowns if losers outnumber winners, and is smug if everything is balanced.

Code:

#!/bin/bash
#
# Fetch MLB scores and colorize them for use with Queen BeeCon.
#
USAGE='Usage: mlbeecon [team] [team] [-team] ...'
#
# Each team is an abbreviation used on the m.mlb.com site.  A team preceded
# by a minus sign is a "team you love to hate;" the icon becomes happy if
# that team loses.  The icon is happy if more teams win than lose, angry
# if losing dominates, and smug if the losers equal the winners.  (Ties
# aren't considered in thois calculation.)

echo "<span foreground=\"green\"><big><i>[`date '+%m/%d/%Y %H:%M'`]</i></big></span>"
wget -t 1 -T 10 -q -O - http://m.mlb.com/scores/`date +%Y%m%d`/ \
  | awk 'BEGIN \
        {
        ntm = split("'"$*"'", tm)
        w = 0
        l = 0
        t = 0
        }
    /<td>.+<\/td>/ \
        {
        s = gensub(/<[^>]*>/, "", "g")
        s = gensub(/[\t ]+/, " ", "g", s)
        split(s, a)
        ist = 0
        for (i = 1;  i <= ntm;  i++)
            {
            ct = tm[i]
            bad = 0
            if (ct ~ /^-/)
                {
                bad = 1
                ct = substr(ct, 2)
                }
            if (a[1] == ct  ||  a[3] == ct  ||  a[4] == ct)
                {
                ist = 1
                break
                }
            }
        if (!ist)
            {
            print s
            next
            }
        print "<span foreground=\"cyan\"><b><big>" s "</big></b></span>"
        if (a[2] == "vs."  ||  a[5] == a[2])
            t++
        else if ((a[4] == tm[i]  &&  a[5] > a[2]) \
          ||  (a[1] == tm[i]  &&  a[2] > a[5]))
            {
            w += !bad
            l += bad
            }
        else
            {
            w += bad
            l += !bad
            }
        }
    END \
        {
        if (w + l + t == 0)
            {
            print "No\nMatch!\n"
            exit 1
            }
        else if (w > l)
            exit 0
        else if (w < l)
            exit 2
        else
            exit 1
        }'


YOU ARE COMMUNITY!!! MAN! :D:D

I've stuck your contribution to relevant section of the WIKI ... feel free to amend it at your convenience!!!

No!No!No!Yes! 2010-05-22 19:54

Re: [Announce] Queen BeeCon Widget: Customizable and flexible monitoring tool.
 
Quote:

Originally Posted by gkuenning (Post 670727)
My widgets aren't auto-updating. I removed .queen_beecon, restarted the desktop, and recreated the MLB example (see following post for some improvements). It works fine when I click it, but doesn't update every 5 minutes. I did double-check the settings, and it's set correctly. Grepping .queen_beecon shows delayIndex=3.

Any thoughts as to why the timers aren't firing? If it's relevant, it was working earlier and then stopped; the clean restart was an attempt to get it to work properly.

Uhm... have you upgraded any QBW release lately?

gkuenning 2010-05-22 20:12

Re: [Announce] Queen BeeCon Widget: Customizable and flexible monitoring tool.
 
Quote:

Originally Posted by No!No!No!Yes! (Post 670777)
Uhm... have you upgraded any QBW release lately?

First, thanks for posting my script. I forgot to mention that I'd appreciate you doing that.

Based on timestamps in /var/lib/dpkg/info, it looks like I did an update about two days ago, at 08:55 Zulu on 2010-May-20. But the md5sums are from Mar 16, which I find odd. Surely you've done a release since then? How do I find out the version I'm running?

No!No!No!Yes! 2010-05-22 21:13

Re: [Announce] Queen BeeCon Widget: Customizable and flexible monitoring tool.
 
Quote:

Originally Posted by Lake (Post 670665)
Hi - please is it possible to alter the script to point the snippet to here:

http://m.flickr.com/#/explore/interesting/

Think the other page is static - my fault, sorry!

There you go ... :D:cool:

No!No!No!Yes! 2010-05-22 21:15

Re: [Announce] Queen BeeCon Widget: Customizable and flexible monitoring tool.
 
Quote:

Originally Posted by gkuenning (Post 670797)
First, thanks for posting my script. I forgot to mention that I'd appreciate you doing that.

Based on timestamps in /var/lib/dpkg/info, it looks like I did an update about two days ago, at 08:55 Zulu on 2010-May-20. But the md5sums are from Mar 16, which I find odd. Surely you've done a release since then? How do I find out the version I'm running?

Application Manager -> Uninstall ... Look in that list.

Lake 2010-05-22 21:45

Re: [Announce] Queen BeeCon Widget: Customizable and flexible monitoring tool.
 
Quote:

Originally Posted by No!No!No!Yes! (Post 670860)

FABULOUS!!!! Just so much better than the Ovi Store offering!

Now I just need to get the Ebay one working ok - any ideas? ;-)

Ps do you have a donate button or something?

No!No!No!Yes! 2010-05-22 21:50

Re: [Announce] Queen BeeCon Widget: Customizable and flexible monitoring tool.
 
For people with TIMER issues ... could you please provide QBW Release you are using and any other info you believe pertinent like for example:
  • It was working and now it doesn't
  • I did this and that and now is not working
  • I installed <xxx>, <yyy>, ... and now ...
  • ...

No!No!No!Yes! 2010-05-22 22:16

Re: [Announce] Queen BeeCon Widget: Customizable and flexible monitoring tool.
 
Quote:

Originally Posted by Lake (Post 670896)
Now I just need to get the Ebay one working ok - any ideas? ;-)

Please elaborate further...

Quote:

Originally Posted by Lake
I seem to be having a bit of a problem getting the Ebay Snippet to work correctly. I followed your instructions (very clear - many thanks) but I cannot seem to get a correct output, i.e. I edit the ebay item number and click "Save and Run" and I get the item title and picture, but no timer.

Is it just a timer issue you have here? What kind of output do you get?

Quote:

Originally Posted by Lake
Having read your recent message about the Flickr snippet I installed "Wget" application but this doesn;t appear to have done the trick.

wget is not supposed to cause timer issues...anything else to report here?

Quote:

Originally Posted by Lake
What might be useful is a suggested 'default' for layout, font etc to optimise the appearance of the widget maybe?

Please elaborate further...

Quote:

Originally Posted by Lake (Post 670896)
Ps do you have a donate button or something?

Uhm ... well ... don't ask twice!!!! :D:o:cool:


All times are GMT. The time now is 05:50.

vBulletin® Version 3.8.8