The Following User Says Thank You to Mentalist Traceur For This Useful Post: | ||
|
2012-10-07
, 19:20
|
Posts: 336 |
Thanked: 129 times |
Joined on Jan 2011
@ portugal
|
#793
|
|
2012-11-18
, 06:49
|
Posts: 569 |
Thanked: 462 times |
Joined on Jul 2010
@ USA
|
#794
|
|
2013-01-18
, 20:59
|
Posts: 188 |
Thanked: 308 times |
Joined on Jan 2013
@ UK
|
#795
|
Current: -3 Conditions: Light Snow High: -2 Low: -3 Image: /tmp/ywtemp.png
|
2013-01-21
, 17:15
|
Posts: 188 |
Thanked: 308 times |
Joined on Jan 2013
@ UK
|
#796
|
I've written a new weatherwidget.sh to get the information form the UKMO mobile site (I think it just covers the UK). I'll post it up here when I get it all working, but I have two issues.
The first is that the icon is very small, but it's workable for me at the moment - though it may be worth eventually looking into it.
The second is that I'm not getting the Conditions being displayed.
Here is an example of my output:
Anyone spot the obvious thing I must be missing?Code:Current: -3 Conditions: Light Snow High: -2 Low: -3 Image: /tmp/ywtemp.png
#!/bin/sh #Arguments: # 1 = Place id - from ukmo website # 2 = output dir url="http://www.metoffice.gov.uk/mobile/" # Your default location here, take it from the Met Office mobile # website. id=${2-"XXXXXX"} out=${3-"/tmp"} post="forecastid=$id" # Get info for day wget --user-agent="" -q -t 1 -T 10 --post-data="$post" -O "$out/ywtemp.htm" "${url}5dayforecastdetail" || { exit 1; } curday=`date "+%a %d %b %y"` eval `awk ' BEGIN { use = 0 } /.h2.'"$curday"'..h2./ { use = 1 } use == 1 && /weathervalues/ { sub("^.*>Temperature: ",""); sub(" .*\\\(", " "); sub(" .*$", ""); high=$1; low=$2; exit } END { printf("high=\"%s\" low=\"%s\"", high, low)}' "$out/ywtemp.htm" ` # Get info specific to time of day curtime=`date +%H`00 if [ $curtime -lt 1200 ]; then curtime=0900 elif [ $curtime -ge 1200 ] && [ $curtime -lt 1500 ]; then curtime=1200 elif [ $curtime -ge 1500 ] && [ $curtime -lt 1800 ]; then curtime=1500 elif [ $curtime -ge 1800 ] && [ $curtime -lt 2100 ]; then curtime=1800 elif [ $curtime -gt 2100 ]; then curtime=2100 fi curday=`date "+%a %d %b %y" | sed 's/ /%20/g'` post="forecastid=$id&detail=$curday" wget --user-agent="" -q -t 1 -T 10 --post-data="$post" -O "$out/ywtemp.htm" "${url}5dayforecastdetail" || { exit 1; } eval `awk ' BEGIN { use = 0 } /Time: '$curtime'/ { use = 1 } use == 1 && /img/ { sub("^.*src=", ""); sub(" alt.*$", ""); img=$0 } use == 1 && /weathervalues/ { sub("^.*weathervalues\">", "") sub(" .*$", "") sub("<br/>Temperature: ","\" temp=\"") wx=$0 exit } END { printf("icon=\"%s\" conditions=\"%s\"", img, wx)}' "$out/ywtemp.htm" ` wget --user-agent="" -q -t 1 -T 10 -O "$out/ywtemp.gif" "${url}${icon}" || { exit 1; } echo "Current: "$temp echo "Conditions: "$conditions echo "High: "$high echo "Low: "$low echo "Image: $out/ywtemp.png"
The Following User Says Thank You to skanky For This Useful Post: | ||
|
2013-02-13
, 11:26
|
|
Posts: 323 |
Thanked: 189 times |
Joined on Oct 2010
@ Brazil
|
#797
|
#!/bin/sh #Arguments: # 1 = Link to yahoo weather # 2 = output dir # 3 = Biggest weather code to consider url=${1-"weather.yahooapis.com/forecastrss?w=455861&u=c"} out=${2-"/tmp"} big=${3-"47"} let big="$big"+1 # ========sakya's translation======== # In order to work with QtLockscreen I need to, in the WORST case scenario: # http://weather.yahoo.com/weather.yahooapis.com/forecastrss?w=455861&u=c?unit=c # 1) Remove the 'http://weather.yahoo.com/' # 2) Translate the appended '?unit=X' to '&u=X' url=`echo "$url" | sed s/weather.yahoo.com\\\/// | sed 's/&u=[cf]//' | sed 's/?unit/\&u/'` # the only problem is that now it requires the ?unit=c to recognize celcius, but for the qtlockscreen it is ok. code="44d" curr="0" cond="Unknown" high="0" loww="0" # Getting all the necessary info. wget --user-agent="" -q -t 1 -T 10 -O "$out/ywtemp.xml" "$url" || { exit 1; } # Now I have to find out the condition code in order to select the icon to download code=`cat "$out/ywtemp.xml" | grep -o code=\".* -m 1 | sed s/code=\"// | sed s/\".*//`|| { exit 1; } # I think that it is safe to translate odd codes to night and even codes to day. It is difficult to get each match on the site, there's nothing anywhere to look into. The weather developer API does not stabilish a correlation. if [ "$code" -lt "$big" ] then # It is lower than the bigger known good weather code (47?), so, it isn't the unknown code 3200 or any other also unknown. Now the unknown icon are the 44d and 44n that are equal N/A: if [ ` expr $code % 2 ` -eq 0 ] then code="$code""d"; else code="$code""n"; fi curr=`cat "$out/ywtemp.xml" | grep -o temp=\".* -m 1 | sed s/temp=\"// | sed s/\".*//` || { exit 1; } cond=`cat "$out/ywtemp.xml" | grep -o text=\".* -m 1 | sed s/text=\"// | sed s/\".*//` || { exit 1; } high=`cat "$out/ywtemp.xml" | grep -o high=\".* -m 1 | sed s/high=\"// | sed s/\".*//` || { exit 1; } loww=`cat "$out/ywtemp.xml" | grep -o low=\".* -m 1 | sed s/low=\"// | sed s/\".*//` || { exit 1; } else code="44d"; fi # Getting the icon... wget --user-agent="" -q -t 1 -T 10 -O "$out/ywtemp.png" "l.yimg.com/os/mit/media/m/weather/images/icons/l/$code-100567.png" || { exit 1; } echo "Current: $curr" echo "Conditions: $cond" echo "High: $high" echo "Low: $loww" echo "Image: $out/ywtemp.png"
|
2014-05-28
, 08:31
|
Posts: 2 |
Thanked: 2 times |
Joined on May 2014
@ Moscow, Russia
|
#798
|
#!/bin/sh #Arguments: # 1 = Link to yahoo weather # 2 = output dir # 3 = Biggest weather code to consider url=${1-"weather.yahooapis.com/forecastrss?w=2122265&u=c?unit=c"} out=${2-"/tmp"} # ========sakya's translation======== # In order to work with QtLockscreen I need to, in the WORST case scenario: # http://weather.yahoo.com/weather.yahooapis.com/forecastrss?w=455861&u=c?unit=c # 1) Remove the 'http://weather.yahoo.com/' # 2) Translate the appended '?unit=X' to '&u=X' url=`echo "$url" | sed s/weather.yahoo.com\\\/// | sed 's/&u=[cf]//' | sed 's/?unit/\&u/'` # the only problem is that now it requires the ?unit=c to recognize celcius, but for the qtlockscreen it is ok. curr="0" cond="Unknown" high="0" loww="0" # Getting the XML and extracting the weather icon URL wget --user-agent="" -q -t 1 -T 10 -O "$out/ywtemp.xml" "$url" || { exit 1; } image=`cat "$out/ywtemp.xml" | grep "img src" | sed s'_<img src="__' | sed s'_"/><br />__'`|| { exit 1; } #echo "$image" # Setting weather conditions curr=`cat "$out/ywtemp.xml" | grep -o temp=\".* -m 1 | sed s/temp=\"// | sed s/\".*//` || { exit 1; } cond=`cat "$out/ywtemp.xml" | grep -o text=\".* -m 1 | sed s/text=\"// | sed s/\".*//` || { exit 1; } high=`cat "$out/ywtemp.xml" | grep -o high=\".* -m 1 | sed s/high=\"// | sed s/\".*//` || { exit 1; } loww=`cat "$out/ywtemp.xml" | grep -o low=\".* -m 1 | sed s/low=\"// | sed s/\".*//` || { exit 1; } # Getting the icon... # The icon has been changed to GIF by Yahoo, writing it with a PNG extension works. wget --user-agent="" -q -t 1 -T 10 -O "$out/ywtemp.png" "$image" || { exit 1; } echo "Current: $curr" echo "Conditions: $cond" echo "High: $high" echo "Low: $loww" echo "Image: $out/ywtemp.png"
|
2015-04-17
, 12:25
|
Posts: 176 |
Thanked: 468 times |
Joined on Jan 2010
@ NL
|
#799
|
But you might still be right - it's possible, for instance, the N900 swaps out desktop-classified programs after some long period of inactivity, or something, but doesn't touch the sysutils-classified ones, or something like that. I'm going to report back if/when I see the QtLockscreen start freezing again. (I concede it's possible I don't notice because my QtLockscreen config is fairly simple - no music player/album art/weather/etc.