![]() |
2010-03-11
, 16:00
|
|
Posts: 700 |
Thanked: 846 times |
Joined on Nov 2009
|
#2
|
echo "<span foreground=\"green\"><big><i>[`date +%m/%d/%Y`]</i></big></span>";
-t 1 try just one time and abort if unsuccessful
-T 10 abort operation if not completed within 10 seconds
-q be quiet and do not output any warning/error/operation message
-O - print fetched page to standard output
`date +%Y%m%d` will be substituted at runtime with the current date in the format <yyyymmdd> to identify the correct webpage to be fetched
wget -t 1 -T 10 -q -O - http://m.mlb.com/scores/`date +%Y%m%d`/
BEGIN { t="NYY"; # Favourite Team!!! m=0; } /<td>.+<\/td>/ { # We find every line of the table which displays results s=gensub(/<[^>]*>/,"","g"); # We remove every simple HTML tag from # out input s=gensub(/[\t ]+/," ","g",s); # and replace every multiple instances # of TABs or SPACEs with just one SPACE split(s,a); # We create an array of blank delimited fields # representing our teams name, score, "vs." string, # situation "Final", "Top 5" ... if(a[1]!=t && a[3]!=t && a[4]!=t) { # Test if our favourite team print s; # just print with no special # Pango tag if other teams next; # and go parse next line } m=1; # Found favourite team... set flag accordingly # Print our fav Team's match with Pango tags for cyan color, # bold & big size font print "<span foreground=\"cyan\"><b><big>" s "</big></b></span>"; if(a[2]=="vs.") { # if second field is string "vs." and not a score # this means game has not started yet ex=1; # We will exit with just a neutral exit status next; # and go parse next line } if((a[4]==t&&a[5]>a[2])||(a[1]==t&&a[2]>a[5])) { # Checks is our fav # Team's winning!!! ex=0; # Yes ... prepare exit with big smiley face exit status! next; # and go parse next matches } if(a[5]==a[2]) { # Is this a still tie game?? ex=1; # Yes ... We will exit with just a neutral exit status next; # and go parse next matches } else { # We have lost ... SAD news!!! ex=2; # Prepare mourning exit status next; # sadly process other teams } } END { # these will be the very last statements performed if(m==0) { # Have we found our fav team's match print "No\nMatch!\n"; # No ... just output a No Match at the # end of the list exit 1; # and exit with neutral exit status } else exit ex; # we now return to beecon with defined exit status }
The Widget is also capable of showing different icons/images/emoticons according to the result of a Favourite Team. (My kiddo's NYY)
In the picture there is also an example of an other customization of Queen BeeCon Widget for displaying my favourite Today's TV Serials which are aired during the day (source is TVRage.com). This will be discussed in another future thread...
Preparation Steps:
Just drop them HERE:
Let's go...
Three usual and basic steps to instantiate the Widget:
Now click on the Settings Wrench Icon and we reach the Settins Dialog.
1) Make sure this is Beecon (our command's Exit Codes will be dynamically managed)
2) Command to be replaced
3) We will now create the command to be associated to the Beecon by clicking on 3. The command will fetch the MLB Results content from the internet (mobile site) and parse it.
1) Let's specify the Command Title: "MLBeeCon"
2) Let's paste our specialist fetching/parser command in this field here:
In code, replace t="NYY" with t="your team here" (short form)
1) Setup the width of our Beecon to around the background image Width
2) Same for Heigth
3,4) Help fine tuning the X,Y position of the Widget on Desktop
1) We don't want any background
2) This only applies to Snippets (not our case)
1,3,5,7) Specify the images to display for the different Command's Exit Status
2,4,6,8) Specify the relevant Beecon background color (not relevant, we've hidden it in previous step)
9,10) Specify basename for images in case we want different icons/background for Command Exit Codes >=3 (not relevant now)
1) This is the filename of our background image
2) Position it in the center of our widget
3,4) Font Family/Size here (This is for the command title label; the "MLBeecon..." in cyan/italics in desktop picture)
5,6,7) Visibility (Hidden/Position), Color & Justification of our label.
1) Image is not relevant here as we rely upon the Exit Status icons/images. (Trailing ";" disables image)
2) Position smileys Status icons/images at bottom right corner of our widget
3,4) Font Family/Size here (This is for default MLB Results text overridden by Pango Markup Language outputted by command)
5,6,7) Visibility (Hidden/Position), Color & Justification of our label.
1) Update at system startup
2) When clicked
3) When desktop gains focus
4) Every 5 minutes
5) When connected to network/internet
6) We Save and Run command immediately
And Here we Are!!!
In next post I'll explain details about the command used for the Beecon.
Credits go to the cited Companies, Organizations, Product, Services. Please report if any contents is neither appropriate nor allowed to be published and it will be removed within short time span.
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-03-17 at 23:52.