maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Applications (https://talk.maemo.org/forumdisplay.php?f=41)
-   -   [Study] Queen Beecon Widget - MLBeecon ... reloaded! (https://talk.maemo.org/showthread.php?t=62289)

No!No!No!Yes! 2010-09-14 20:43

[Study] Queen Beecon Widget - MLBeecon ... reloaded!
 
2 Attachment(s)
For QBW >=1.0.52
This is just a study purpose Beecon. Make sure you have wget package installed
It contains several new/advanced technics:
  • information persistency
  • clickable hot-spots management
  • intra-widget communication
  • variable parameters substitution
  • awk programming
  • awk variables pull-in from the shell
  • awk variables push-back to the shell
  • shell script functions
  • Pango Markup Language
  • Web scraping
I'll not be able to maintain the script on a regular basis as much of my spare time drowns into QBW dev/test but I promise I'll try to answer every question. (Bear with some bugs or unhandled error conditions)

Now let's stop blabbing and back into the core!!! :cool:

Functional view:
http://i52.tinypic.com/4ih8y1.jpg
http://i55.tinypic.com/6yzfat.jpg
http://i56.tinypic.com/21j4tnm.jpg
http://i56.tinypic.com/ohizjm.jpg
http://i54.tinypic.com/10hvs6s.jpg
http://i51.tinypic.com/10h0nt4.jpg
http://i56.tinypic.com/2hogyut.jpg
http://i53.tinypic.com/hvc8it.jpg

Extract & Copy attached images and shell script (make it executable chmod 777 mlbeecon_reloaded.sh) to directory:
Code:

/home/user/.queen_beecon_dir
Import Beecon:
Code:

[queen-beecon-header]
version=1,000000
checksum=3018258
[queen-beecon-exported-instance]
widgetType=0
widgetVisible=1
operationalStatus=0
hideCanvas=true
hideClickCanvas=true
snippetBgRGB=0
snippetExtBgRGB=#000000000000
beecon_lt0_ImgZoom=0
beecon_lt0_BgRGB=2
beecon_lt0_ExtBgRGB=#bebebebebebe
beecon_lt0_ImgFilename=queen-beecon-syserr.png
beecon_eq0_ImgZoom=0
beecon_eq0_BgRGB=3
beecon_eq0_ExtBgRGB=#000000000000
beecon_eq0_ImgFilename=mlb_news.png
beecon_eq1_ImgZoom=0
beecon_eq1_BgRGB=4
beecon_eq1_ExtBgRGB=#000000000000
beecon_eq1_ImgFilename=mlb_scoreboard.png
beecon_ge2_ImgZoom=0
beecon_ge2_BgRGB=5
beecon_ge2_ExtBgRGB=#000000000000
beecon_ge2_ImgFilename=mlb_standings.png
beecon_idxge2_ImgZoom=0
beecon_idxge2_BgRGB=11
beecon_idxge2_ExtBgRGB=#0000ffffffff
beecon_idxge2_ImgFilename=queen-beecon-index.png
widWidth=372.84403669724776
widHeight=420
instanceTitle=MLBeecon Reloaded
instanceCmd=/home/user/.queen_beecon_dir/mlbeecon_reloaded.sh "$QBW_REMEMBER_ME" "$QBW_HOTSPOT_PRESS" "$QBW_ID"
rememberMe=1:AL:BOS-Red Sox|NYY-Yankees:20100913:20100914:20100915
cmdImgFilename=queen-beecon.png
cmdImgAngle=0
cmdImgZoom=0
cmdFgRGB=1
cmdExtFgRGB=#ffffffffffff
cmdTextAngle=0
cmdVisibilityPosition=0
cmdImgVisibilityPosition=0
cmdJustify=0
cmdExtFont=Nokia Sans bold italic 12
cmdFontName=3
cmdFontSize=12
resImgFilename=queen-beecon-resimg.png
resImgAngle=0
resImgZoom=0
resFgRGB=1
resExtFgRGB=#ffffffffffff
resTextAngle=0
resVisibilityPosition=1
resImgVisibilityPosition=9
resJustify=0
resExtFont=Tahoma bold 10
resFontName=2
resFontSize=12
progressAnimationFrames=4
progressAnimationTimer=4
progressAnimationPos=4
progressAnimationAtClickXY=true
progressAnimationBasename=queen-beecon-progress
updOnStartup=false
updOnClick=true
updOnDesktop=false
updOnSight=false
delayIndex=9
customIntervalSecs=300
updNeworkPolicy=0
updOnDBUS=0
updOnDBUSBus=0
updOnDBUSMatchRule=

Here's the same text of attached script (for reference purpose only):
Quote:

Originally Posted by mlbeecon_reloaded.sh
Code:

#dt=`TZ=EST+24 date +%Y%m%d`
QBW_REMEMBER_ME="$1"
QBW_HOTSPOT_PRESS="$2";
QBW_ID="$3";
TAB=`echo "$QBW_REMEMBER_ME" | cut -f1 -d:`
LEAGUE=`echo "$QBW_REMEMBER_ME" | cut -f2 -d:`
FAVLONG=`echo "$QBW_REMEMBER_ME" | cut -f3 -d:`
PREVDATE=`echo "$QBW_REMEMBER_ME" | cut -f4 -d:`
DISPLAYDATE=`echo "$QBW_REMEMBER_ME" | cut -f5 -d:`
NEXTDATE=`echo "$QBW_REMEMBER_ME" | cut -f6 -d:`

remember_me()
{
        run-standalone.sh dbus-send --session --type=method_call --dest=oh.no.more.qbw /oh/no/more/qbw$QBW_ID oh.no.more.qbw.set_param_string string:"rememberMe" string:"$TAB:$LEAGUE:$FAVLONG:$PREVDATE:$DISPLAYDATE:$NEXTDATE" string:"";
}

#echo $TAB
#echo $LEAGUE
#echo $FAVLONG
#echo $PREVDATE
#echo $DISPLAYDATE
#echo $NEXTDATE


if [ "_$PREVDATE" == "_" -o $DISPLAYDATE == "_" -o "_$NEXTDATE" == "_" ]; then
    DISPLAYDATE=`TZ=EST+05EDT date +%Y%m%d`
    PREVDATE=`TZ=EST+29 date +%Y%m%d`
    NEXTDATE=`TZ=EST-19 date +%Y%m%d`
fi

case $QBW_HOTSPOT_PRESS in
[123])
    DISPLAYDATE=`TZ=EST+05EDT date +%Y%m%d`
    if [ "$QBW_HOTSPOT_PRESS" -ne "$TAB" ]; then
        remember_me
    fi
    TAB=$QBW_HOTSPOT_PRESS;
    ;;
esac

case $TAB in
1)
    wget -U " " -t 1 -T 10 -q -O - "http://m.espn.go.com/mlb/news?lang=EN" | awk -v fav="$FAVLONG" -v hi="yellow" -v oc='white' -v ec='gray' -- '
BEGIN {
    FS="";
    infoOk=0
}

/^<\/style>.+<\/html>/ {
    print "\n\n<span foreground=\"cyan\" font=\"bold 15\"></span>";
    x=split($0,m,"(<div class=\"ind[^\"]*\"[^>]*><a  class=\"inline\"[^>]*>)|(</a> </div>)");
    for (i=2;i<x-1;i++) {
        infoOk=1
        if (n%2==0)
            c=oc;
        else
            c=ec;
        gsub(/(<[^>]*>)+/,"",m[i]);
        if (m[i]!="") {
            n++;
                    t=split(fav,fa,"[\|\-]");
                    for(f=1;f<=t;f++) {
#                print f "-" fa[f] "-" m[i]
                if (match(m[i],fa[f])) c=hi;
            }
            print "<b><span foreground=\""c"\">- "m[i]"</span></b>";
        }
    }
}

END {
        if (infoOk==0) print "<span foreground=\"red\" font=\"bold 17\">\n\n No Info Available</span>";
}'
    remember_me
    exit 0
    ;;
 2)
    case $QBW_HOTSPOT_PRESS in
    [47])
        DISPLAYDATE=$PREVDATE
        ;;
    [69])
        DISPLAYDATE=$NEXTDATE
        ;;
    esac
    wget -U " " -t 1 -T 10 -q -O - "http://m.espn.go.com/mlb/scoreboard?date=$DISPLAYDATE&lang=EN" | awk -v fav="$FAVLONG" -v hi="yellow" -v oc='white' -v ec='gray' -- '
BEGIN {
    FS="";
    infoOk=0
}

/^<\/style>.+<\/html>/ {
    print "<span font=\"bold 6\">\n\n\n</span>";
    match($0,/<\/a> \| [A-Z0-9 ]+/);
    print "<tt><span foreground=\"cyan\" font=\"bold 12\"> "substr($0,RSTART+7,6)"</span></tt>";
    match($0,/scoreboard\?date=[0-9]+/);
    pd=substr($0,RSTART+16,8)
    match($0,/ <a  href=\"scoreboard\?date=[0-9]+/);
    nd=substr($0,RSTART+27,8)
    print "PREVDATE"pd
    print "NEXTDATE"nd
    match($0,"> [\|] [^\|]+");
    x=split($0,m,"(<div id=\"game[^>]*><div class=\"ind[^>]*><a  href=\"/mlb/gamecast[^>]*>)|(</a></div></div>)");
    for(i=2;i<x;i++) {
        infoOk=1;
        if (n%2==0)
            c=oc;
        else
            c=ec;
        if (m[i]!="") {
            n++;
                    t=split(fav,fa,"[\|\-]");
                    for(f=1;f<=t;f+=2) {
#                print f "-" fa[f] "-" fa[f+1] "-" m[i]
                            if (match(m[i],fa[f])) c=hi;
            }
            split(m[i],p," ");
            if (p[2]=="at")
                printf "<tt><span font=\"bold 14\" foreground=\""c"\">      %3s @ %3s %s %s %s %s</span></tt>\n", p[1], p[3], p[4], p[5], p[6], p[7], p[8];
            else
                printf "<tt><span font=\"bold 14\" foreground=\""c"\">      %3s %2s-%-2s %3s %s %s %s</span></tt>\n", p[1], p[2], p[4], p[3], p[5], p[6], p[7];
        }
    }
}

END {
        if (infoOk==0) print "<span foreground=\"red\" font=\"bold 17\">\n\n No Info Available</span>";
}' | while read out
do
    if [ "`echo $out|cut -c1-8`" == "PREVDATE" ];then
        PREVDATE="`echo $out|cut -c9-16`"
    elif [ "`echo $out|cut -c1-8`" == "NEXTDATE" ];then
        NEXTDATE="`echo $out|cut -c9-16`"
        remember_me
    else echo "$out"   
    fi
done
    exit 1
    ;;
3)
    if [ "$LEAGUE" == "AL" ]; then
        LG=7
        LEAGUE="NL"
    elif [ "$LEAGUE" == "NL" ]; then
        LG=8
        LEAGUE="WC"
    elif [ "$LEAGUE" == "WC" ]; then
        LG=9
        LEAGUE="AL"
    fi

    wget -U " " -t 1 -T 10 -q -O - "http://m.espn.go.com/mlb/standings?groupId=$LG&lang=EN" | awk -v fav="$FAVLONG" -v hi="yellow" -v lg="$LG" -v oc='red' -v ec='gray' -- '
BEGIN {
    FS="";
    if (lg==9) st="\n Wildcards";
    infoOk=0;
    wcc=-1;
    fontsize=12;
    blanks="";
}

/^<\/style>.+<\/html>/ {
    print "\n\n<tt><span foreground=\"cyan\" font=\"bold 12\">"st"</span></tt>";
    match($0,"<table  class=\"table\".*</table>");
    q=substr($0, RSTART, RLENGTH);
    gsub(/(<[^>]*>)+/,"|",q);
    x=split(q,m,"\|");
    for(i=2;i<x;i+=5) {
        infoOk=1;
        if (m[i]=="AL EAST" || m[i]=="AL CENT" || m[i]=="AL WEST" || m[i]=="NL EAST" || m[i]=="NL CENT" || m[i]=="NL WEST" || m[i]=="AL" || m[i]=="NL") {
            wcc=0;           
            c=oc;
        } else {
            c=ec;
        }
                t=split(fav,fa,"[\|\-]");
                for(f=1;f<=t;f+=2) {
#            print f "-" fa[f] "-" fa[f+1] "-" m[i]
                        if (match(m[i],fa[f+1])) c=hi;
        }
        if (lg==9) {
            if (wcc>=0&&wcc<9) wcc++;
            else continue;
        };
        if ( match(m[i+1],/\([0-9]+\)/) ) {m[i+1]=m[i] substr(m[i+1],RSTART,RLENGTH);i++;}
        printf("<tt><span font=\"bold %d\" foreground=\"%s\"> %s%-15s %3s %3s %5s %5s</span></tt>\n", fontsize, c, blanks, m[i], m[i+1], m[i+2], m[i+3], m[i+4]);
    }
}

END {
        if (infoOk==0) print "<span foreground=\"red\" font=\"bold 17\">\n\n No Info Available</span>";
}'
    remember_me
    exit 2
    ;;
*)
    echo "UNKNOWN TAB $TAB"
    ;;
esac


Enjoy!
:cool::eek:

Sash 2010-09-15 21:39

Re: [Study] Queen Beecon Widget - MLBeecon ... reloaded!
 
This beecon works pretty well. I'm going to try and customise it to a football beecon.

No!No!No!Yes! 2010-09-16 05:57

Re: [Study] Queen Beecon Widget - MLBeecon ... reloaded!
 
Widget startup need some more effort to correctly handle last active Tab repositioning; further ... It could be necessary to set Update Policy for Network to "Disabled" and make use of $QBW_IS_CONNECTED inside the script logic...

No!No!No!Yes! 2010-09-16 14:45

Re: [Study] Queen Beecon Widget - MLBeecon ... reloaded!
 
Quote:

Originally Posted by No!No!No!Yes! (Post 817540)
Widget startup need some more effort to correctly handle last active Tab repositioning; further ... It could be necessary to set Update Policy for Network to "Disabled" and make use of $QBW_IS_CONNECTED inside the script logic...

New release in the brewery will add a new network event condition update policy "Passthrough" which will trigger command execution on every network event and demand to the command the connection condition management

Code:

queen-beecon (1.0.53) partial

  * New: Parameter Variables substitution for using with scripts which holds the exit status of the last previous executed command ($QBW_PREVIOUS_EXIT_STATUS)
  * New: Added new Network Connection Event condition (NETWORK__PASSTHROUGH) which will trigger the execution of command at every Network Related event. Management of the connection event status will be completely delegated to the command through $QBW_IS_CONNECTED and $QBW_EXEC_REASON=="QBW_CONNECTION_EVENT" Parameter Variables substitution.


No!No!No!Yes! 2010-09-16 17:03

Re: [Study] Queen Beecon Widget - MLBeecon ... reloaded!
 
Further...

Code:

remember_me()
{
        run-standalone.sh dbus-send --session --type=method_call --dest=oh.no.more.qbw /oh/no/more/qbw$QBW_ID oh.no.more.qbw.set_param_string string:"rememberMe" string:"$TAB:$LEAGUE:$FAVLONG:$PREVDATE:$DISPLAYDATE:$NEXTDATE" string:"";
}

As of release >=1.0.5 this Shell script function which uses the QBW DBUS methods interface, can be substituded by a quicker method:
Just echo the following string as output of your command:
Code:

QBW_REMEMBER_ME(<content to be remembered>)
no angle brackets; escape "close round bracket" like this "\)" to store it as ")" and set <content to be remembered> to what you would like to be stored in permanent rememberMe parameter

So function remember_me() might be rewritten as:
Code:

remember_me()
{
        echo "QBW_REMEMBER_ME($TAB:$LEAGUE:$FAVLONG:$PREVDATE:$DISPLAYDATE:$NEXTDATE)"
}

Note that command output will not be affected by this echoed text as replacement will take place before printing the command result text to the widget's canvas.

No!No!No!Yes! 2010-10-14 10:13

Re: [Study] Queen Beecon Widget - MLBeecon ... reloaded!
 
Quote:

Originally Posted by sebastiaan.lampo (Post 840735)
Hi,

I've been trying to do something similar for belgium with the QBW.
...

Would you mind if we move here with other Traffic beecon?

No!No!No!Yes! 2011-08-06 02:17

Re: [Study] Queen Beecon Widget - MLBeecon ... reloaded!
 
Thanks to gkuenning you can find an updated version of the mlbeecon_reloaded.sh shell script which is now working again as of Aug 5th 2011:
Quote:

Originally Posted by mlbeecon_reloaded.sh
Code:

#!/bin/bash
exec 2> /tmp/mlbeecon.log
set -x

#dt=`TZ=EST+24 date +%Y%m%d`
QBW_REMEMBER_ME="$1"
QBW_HOTSPOT_PRESS="$2";
QBW_ID="$3";
TAB=`echo "$QBW_REMEMBER_ME" | cut -f1 -d:`
LEAGUE=`echo "$QBW_REMEMBER_ME" | cut -f2 -d:`
FAVLONG=`echo "$QBW_REMEMBER_ME" | cut -f3 -d:`
PREVDATE=`echo "$QBW_REMEMBER_ME" | cut -f4 -d:`
DISPLAYDATE=`echo "$QBW_REMEMBER_ME" | cut -f5 -d:`
NEXTDATE=`echo "$QBW_REMEMBER_ME" | cut -f6 -d:`

remember_me()
{
                run-standalone.sh dbus-send --session --type=method_call --dest=oh.no.more.qbw /oh/no/more/qbw$QBW_ID oh.no.more.qbw.set_param_string string:"rememberMe" string:"$TAB:$LEAGUE:$FAVLONG:$PREVDATE:$DISPLAYDATE:$NEXTDATE" string:"";
}

#echo $TAB
#echo $LEAGUE
#echo $FAVLONG
#echo $PREVDATE
#echo $DISPLAYDATE
#echo $NEXTDATE


if [ "_$PREVDATE" == "_" -o $DISPLAYDATE == "_" -o "_$NEXTDATE" == "_" ]; then
        DISPLAYDATE=`TZ=EST+05EDT date +%Y%m%d`
        PREVDATE=`TZ=EST+29 date +%Y%m%d`
        NEXTDATE=`TZ=EST-19 date +%Y%m%d`
fi

case $QBW_HOTSPOT_PRESS in
[123])
        DISPLAYDATE=`TZ=EST+05EDT date +%Y%m%d`
        if [ "$QBW_HOTSPOT_PRESS" -ne "$TAB" ]; then
                remember_me
        fi
        TAB=$QBW_HOTSPOT_PRESS;
        ;;
esac

case $TAB in
1)
        wget -U " " -t 1 -T 10 -q -O - "http://m.espn.go.com/mlb/news?lang=EN&wjb" | awk -v fav="$FAVLONG" -v hi="yellow" -v oc='white' -v ec='gray' -- '
BEGIN {
        FS="";
        infoOk=0
}

/<a *href=[^>]*type=news/ {
        print "\n\n<span foreground=\"cyan\" font=\"bold 15\"></span>";
        x=split($0,m,"(<div class=\"ind[^\"]*\"[^>]*><a  class=\"inline\"[^>]*>)|(</a> </div>)");
        for (i=2;i<x-1;i++) {
                infoOk=1
                if (n%2==0)
                        c=oc;
                else
                        c=ec;
                gsub(/(<[^>]*>)+/,"",m[i]);
                if (m[i]!="") {
                        n++;
                        t=split(fav,fa,"[-|]");
                        for(f=1;f<=t;f++) {
#                              print f "-" fa[f] "-" m[i]
                                if (match(m[i],fa[f])) c=hi;
                        }
                        print "<b><span foreground=\""c"\">- "m[i]"</span></b>";
                }
        }
}

END {
        if (infoOk==0) print "<span foreground=\"red\" font=\"bold 17\">\n\n No Info Available</span>";
}'
        remember_me
        exit 0
        ;;
 2)
        case $QBW_HOTSPOT_PRESS in
        [47])
                DISPLAYDATE=$PREVDATE
                ;;
        [69])
                DISPLAYDATE=$NEXTDATE
                ;;
        esac
        wget -U " " -t 1 -T 10 -q -O - "http://m.espn.go.com/mlb/scoreboard?date=$DISPLAYDATE&lang=EN&wjb" | awk -v fav="$FAVLONG" -v hi="yellow" -v oc='white' -v ec='gray' -- '
BEGIN {
        FS="";
        infoOk=0
}

/<div id="game/ {
        print "<span font=\"bold 6\">\n\n\n</span>";
        match($0,/<\/a> \| [A-Z0-9 ]+/);
        print "<tt><span foreground=\"cyan\" font=\"bold 12\"> "substr($0,RSTART+7,6)"</span></tt>";
        match($0,/scoreboard\?date=[0-9]+/);
        pd=substr($0,RSTART+16,8)
        match($0,/ <a  href=\"scoreboard\?date=[0-9]+/);
        nd=substr($0,RSTART+27,8)
        print "PREVDATE"pd
        print "NEXTDATE"nd
        match($0,"> [\|] [^\|]+");
        x=split($0,m,"(<div id=\"game[^>]*><div class=\"ind[^>]*><a  href=\"/mlb/gamecast[^>]*>)|(</a></div></div>)");
        for(i=2;i<x;i++) {
                infoOk=1;
                if (n%2==0)
                        c=oc;
                else
                        c=ec;
                if (m[i]!="") {
                        n++;
                        t=split(fav,fa,"[\|\-]");
                        for(f=1;f<=t;f+=2) {
#                              print f "-" fa[f] "-" fa[f+1] "-" m[i]
                                if (match(m[i],fa[f])) c=hi;
                        }
                        split(m[i],p," ");
                        if (p[2]=="at")
                                printf "<tt><span font=\"bold 14\" foreground=\""c"\">      %3s @ %3s %s %s %s %s</span></tt>\n", p[1], p[3], p[4], p[5], p[6], p[7], p[8];
                        else
                                printf "<tt><span font=\"bold 14\" foreground=\""c"\">      %3s %2s-%-2s %3s %s %s %s</span></tt>\n", p[1], p[2], p[4], p[3], p[5], p[6], p[7];
                }
        }
}

END {
        if (infoOk==0) print "<span foreground=\"red\" font=\"bold 17\">\n\n No Info Available</span>";
}' | while read out
do
        if [ "`echo $out|cut -c1-8`" == "PREVDATE" ];then
                PREVDATE="`echo $out|cut -c9-16`"
        elif [ "`echo $out|cut -c1-8`" == "NEXTDATE" ];then
                NEXTDATE="`echo $out|cut -c9-16`"
                remember_me
        else echo "$out"
        fi
done
        exit 1
        ;;
3)
        if [ "$LEAGUE" == "AL" ]; then
                LG=7
                LEAGUE="NL"
        elif [ "$LEAGUE" == "NL" ]; then
                LG=8
                LEAGUE="WC"
        elif [ "$LEAGUE" == "WC" ]; then
                LG=9
                LEAGUE="AL"
        fi

        wget -U " " -t 1 -T 10 -q -O - "http://m.espn.go.com/mlb/standings?groupId=$LG&lang=EN&wjb" | awk -v fav="$FAVLONG" -v hi="yellow" -v lg="$LG" -v oc='red' -v ec='gray' -- '
BEGIN {
        FS="";
        if (lg==9) st="\n Wildcards";
        infoOk=0;
        wcc=-1;
        fontsize=12;
        blanks="";
}

/<a *href="standings/ {
        print "\n\n<tt><span foreground=\"cyan\" font=\"bold 12\">"st"</span></tt>";
        match($0,"<table.*</table>");
        q = substr($0, RSTART, RLENGTH);
        gsub(/(<[^>]*>)+/, "|", q);
        x = split(q, m, "|");
        for(i = 2; i < x; i += 5) {
                infoOk = 1;
                if (m[i]=="AL EAST" || m[i]=="AL CENTRAL" || m[i]=="AL WEST" || m[i]=="NL EAST" || m[i]=="NL CENTRAL" || m[i]=="NL WEST" || m[i]=="AL" || m[i]=="NL") {
                        wcc=0;
                        c=oc;
                } else {
                        c=ec;
                }
                t=split(fav,fa,"[-|]");
                for(f=1;f<=t;f+=2) {
#                      print f "-" fa[f] "-" fa[f+1] "-" m[i]
                        if (match(m[i],fa[f+1])) c=hi;
                }
                if (lg==9) {
                        if (wcc>=0&&wcc<9) wcc++;
                        else continue;
                };
                if ( match(m[i+1],/\([0-9]+\)/) ) {m[i+1]=m[i] substr(m[i+1],RSTART,RLENGTH);i++;}
                printf("<tt><span font=\"bold %d\" foreground=\"%s\"> %s%-15s %3s %3s %5s %5s</span></tt>\n", fontsize, c, blanks, m[i], m[i+1], m[i+2], m[i+3], m[i+4]);
        }
}

END {
        if (infoOk==0) print "<span foreground=\"red\" font=\"bold 17\">\n\n No Info Available</span>";
}'
        remember_me
        exit 2
        ;;
*)
        echo "UNKNOWN TAB $TAB"
        ;;
esac



No!No!No!Yes! 2011-08-23 15:23

Re: [Study] Queen Beecon Widget - MLBeecon ... reloaded!
 
Thanks to gkuenning you can find an updated version of the mlbeecon_reloaded.sh shell script which is now working again as of Aug 23th 2011:

Quote:

Originally Posted by gkuenning
MLB.com changed the format of their standings reports. Here's a fixed mlbeecon_reloaded. I also tried to make it a hair more robust to future mlb.com tweaks (oh, for an API!).

Quote:

Originally Posted by mlbeecon_reloaded.sh
Code:

#!/bin/bash
exec 2> /tmp/mlbeecon.log
set -x

#dt=`TZ=EST+24 date +%Y%m%d`
QBW_REMEMBER_ME="$1"
QBW_HOTSPOT_PRESS="$2";
QBW_ID="$3";
TAB=`echo "$QBW_REMEMBER_ME" | cut -f1 -d:`
LEAGUE=`echo "$QBW_REMEMBER_ME" | cut -f2 -d:`
FAVLONG=`echo "$QBW_REMEMBER_ME" | cut -f3 -d:`
PREVDATE=`echo "$QBW_REMEMBER_ME" | cut -f4 -d:`
DISPLAYDATE=`echo "$QBW_REMEMBER_ME" | cut -f5 -d:`
NEXTDATE=`echo "$QBW_REMEMBER_ME" | cut -f6 -d:`

remember_me()
{
                run-standalone.sh dbus-send --session --type=method_call --dest=oh.no.more.qbw /oh/no/more/qbw$QBW_ID oh.no.more.qbw.set_param_string string:"rememberMe" string:"$TAB:$LEAGUE:$FAVLONG:$PREVDATE:$DISPLAYDATE:$NEXTDATE" string:"";
}

#echo $TAB
#echo $LEAGUE
#echo $FAVLONG
#echo $PREVDATE
#echo $DISPLAYDATE
#echo $NEXTDATE


if [ "_$PREVDATE" == "_" -o $DISPLAYDATE == "_" -o "_$NEXTDATE" == "_" ]; then
        DISPLAYDATE=`TZ=EST+05EDT date +%Y%m%d`
        PREVDATE=`TZ=EST+29 date +%Y%m%d`
        NEXTDATE=`TZ=EST-19 date +%Y%m%d`
fi

case $QBW_HOTSPOT_PRESS in
[123])
        DISPLAYDATE=`TZ=EST+05EDT date +%Y%m%d`
        if [ "$QBW_HOTSPOT_PRESS" -ne "$TAB" ]; then
                remember_me
        fi
        TAB=$QBW_HOTSPOT_PRESS;
        ;;
esac

case $TAB in
1)
        wget -U " " -t 1 -T 10 -q -O - "http://m.espn.go.com/mlb/news?lang=EN&wjb" | awk -v fav="$FAVLONG" -v hi="yellow" -v oc='white' -v ec='gray' -- '
BEGIN {
        FS="";
        infoOk=0
}

/<a *href=[^>]*type=news/ {
        print "\n\n<span foreground=\"cyan\" font=\"bold 15\"></span>";
        x=split($0,m,"(<div class=\"ind[^\"]*\"[^>]*><a  class=\"inline\"[^>]*>)|(</a> </div>)");
        for (i=2;i<x-1;i++) {
                infoOk=1
                if (n%2==0)
                        c=oc;
                else
                        c=ec;
                gsub(/(<[^>]*>)+/,"",m[i]);
                if (m[i]!="") {
                        n++;
                        t=split(fav,fa,"[-|]");
                        for(f=1;f<=t;f++) {
#                                print f "-" fa[f] "-" m[i]
                                if (match(m[i],fa[f])) c=hi;
                        }
                        print "<b><span foreground=\""c"\">- "m[i]"</span></b>";
                }
        }
}

END {
        if (infoOk==0) print "<span foreground=\"red\" font=\"bold 17\">\n\n No Info Available</span>";
}'
        remember_me
        exit 0
        ;;
 2)
        case $QBW_HOTSPOT_PRESS in
        [47])
                DISPLAYDATE=$PREVDATE
                ;;
        [69])
                DISPLAYDATE=$NEXTDATE
                ;;
        esac
        wget -U " " -t 1 -T 10 -q -O - "http://m.espn.go.com/mlb/scoreboard?date=$DISPLAYDATE&lang=EN&wjb" | awk -v fav="$FAVLONG" -v hi="yellow" -v oc='white' -v ec='gray' -- '
BEGIN {
        FS="";
        infoOk=0
}

/<div id="game/ {
        print "<span font=\"bold 6\">\n\n\n</span>";
        match($0,/<\/a> \| [A-Z0-9 ]+/);
        print "<tt><span foreground=\"cyan\" font=\"bold 12\"> "substr($0,RSTART+7,6)"</span></tt>";
        match($0,/scoreboard\?date=[0-9]+/);
        pd=substr($0,RSTART+16,8)
        match($0,/ <a  href=\"scoreboard\?date=[0-9]+/);
        nd=substr($0,RSTART+27,8)
        print "PREVDATE"pd
        print "NEXTDATE"nd
        match($0,"> [\|] [^\|]+");
        x=split($0,m,"(<div id=\"game[^>]*><div class=\"ind[^>]*><a  href=\"/mlb/gamecast[^>]*>)|(</a></div></div>)");
        for(i=2;i<x;i++) {
                infoOk=1;
                if (n%2==0)
                        c=oc;
                else
                        c=ec;
                if (m[i]!="") {
                        n++;
                        t=split(fav,fa,"[\|\-]");
                        for(f=1;f<=t;f+=2) {
#                                print f "-" fa[f] "-" fa[f+1] "-" m[i]
                                if (match(m[i],fa[f])) c=hi;
                        }
                        split(m[i],p," ");
                        if (p[2]=="at")
                                printf "<tt><span font=\"bold 14\" foreground=\""c"\">      %3s @ %3s %s %s %s %s</span></tt>\n", p[1], p[3], p[4], p[5], p[6], p[7], p[8];
                        else
                                printf "<tt><span font=\"bold 14\" foreground=\""c"\">      %3s %2s-%-2s %3s %s %s %s</span></tt>\n", p[1], p[2], p[4], p[3], p[5], p[6], p[7];
                }
        }
}

END {
        if (infoOk==0) print "<span foreground=\"red\" font=\"bold 17\">\n\n No Info Available</span>";
}' | while read out
do
        if [ "`echo $out|cut -c1-8`" == "PREVDATE" ];then
                PREVDATE="`echo $out|cut -c9-16`"
        elif [ "`echo $out|cut -c1-8`" == "NEXTDATE" ];then
                NEXTDATE="`echo $out|cut -c9-16`"
                remember_me
        else echo "$out"       
        fi
done
        exit 1
        ;;
3)
        if [ "$LEAGUE" == "AL" ]; then
                LG=7
                LEAGUE="NL"
        elif [ "$LEAGUE" == "NL" ]; then
                LG=8
                LEAGUE="WC"
        elif [ "$LEAGUE" == "WC" ]; then
                LG=9
                LEAGUE="AL"
        fi

        wget -U " " -t 1 -T 10 -q -O - "http://m.espn.go.com/mlb/standings?groupId=$LG&lang=EN&wjb" | awk -v fav="$FAVLONG" -v hi="yellow" -v lg="$LG" -v oc='red' -v ec='gray' -- '
BEGIN {
        FS="";
        if (lg==9) st="\n Wildcards";
        infoOk=0;
        wcc=-1;
        fontsize=12;
        blanks="";
}

/<a *href="standings/ {
        print "\n\n<tt><span foreground=\"cyan\" font=\"bold 12\">"st"</span></tt>";
        match($0,"<table.*</table>");
        q = substr($0, RSTART, RLENGTH);
        gsub(/|/, "", q);
        gsub(/(<[^>]*>)+/, "|", q);
        x = split(q, m, "|");
        for(i = 1; i < x; i++) {
                if (m[i]~/^AL/ || m[i]~/^NL/)
                    break
        }
        for(; i < x; i += 5) {
                infoOk = 1;
                if (m[i]=="AL EAST" || m[i]~/AL CENTRAL/ || m[i]=="AL WEST" || m[i]=="NL EAST" || m[i]~/NL CENTRAL/ || m[i]=="NL WEST" || m[i]=="AL" || m[i]=="NL") {
                        wcc=0;                       
                        c=oc;
                } else {
                        c=ec;
                }
                t=split(fav,fa,"[-|]");
                for(f=1;f<=t;f+=2) {
#                        print f "-" fa[f] "-" fa[f+1] "-" m[i]
                        if (match(m[i],fa[f+1])) c=hi;
                }
                if (lg==9) {
                        if (wcc>=0&&wcc<9) wcc++;
                        else continue;
                };
                if ( match(m[i+1],/\([0-9]+\)/) ) {m[i+1]=m[i] substr(m[i+1],RSTART,RLENGTH);i++;}
                printf("<tt><span font=\"bold %d\" foreground=\"%s\"> %s%-15s %3s %3s %5s %5s</span></tt>\n", fontsize, c, blanks, m[i], m[i+1], m[i+2], m[i+3], m[i+4]);
        }
}

END {
        if (infoOk==0) print "<span foreground=\"red\" font=\"bold 17\">\n\n No Info Available</span>";
}'
        remember_me
        exit 2
        ;;
*)
        echo "UNKNOWN TAB $TAB"
        ;;
esac




All times are GMT. The time now is 00:38.

vBulletin® Version 3.8.8