![]() |
2010-09-15
, 21:39
|
Posts: 150 |
Thanked: 80 times |
Joined on Dec 2009
|
#2
|
The Following User Says Thank You to Sash For This Useful Post: | ||
![]() |
2010-09-16
, 05:57
|
|
Posts: 700 |
Thanked: 846 times |
Joined on Nov 2009
|
#3
|
![]() |
2010-09-16
, 14:45
|
|
Posts: 700 |
Thanked: 846 times |
Joined on Nov 2009
|
#4
|
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...
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.
![]() |
2010-09-16
, 17:03
|
|
Posts: 700 |
Thanked: 846 times |
Joined on Nov 2009
|
#5
|
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:""; }
QBW_REMEMBER_ME(<content to be remembered>)
remember_me() { echo "QBW_REMEMBER_ME($TAB:$LEAGUE:$FAVLONG:$PREVDATE:$DISPLAYDATE:$NEXTDATE)" }
![]() |
2010-10-14
, 10:13
|
|
Posts: 700 |
Thanked: 846 times |
Joined on Nov 2009
|
#6
|
Hi,
I've been trying to do something similar for belgium with the QBW.
...
![]() |
2011-08-06
, 02:17
|
|
Posts: 700 |
Thanked: 846 times |
Joined on Nov 2009
|
#7
|
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
![]() |
2011-08-23
, 15:23
|
|
Posts: 700 |
Thanked: 846 times |
Joined on Nov 2009
|
#8
|
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!).
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
The Following User Says Thank You to No!No!No!Yes! For This Useful Post: | ||
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!!!
Functional view:
Extract & Copy attached images and shell script (make it executable chmod 777 mlbeecon_reloaded.sh) to directory:
Have a look at Queen BeeCon Widget (WIKI) Customizable and flexible widget-based multi-instance monitoring, alerting and interactive tool for the N900
Please provide comments and feedback for having QBW supported and enhanced further - (DONATE) - v1.3.3devel / v1.3.3testing / v1.3.3extras
Last edited by No!No!No!Yes!; 2010-09-15 at 05:11.