Hi
Now that the Yahoo APIs have changed myt original script fails to work.
I have the following XML that I would like to use with Geektool, but am having issues :
<yweather:location xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" city="Peterborough" country="United Kingdom" region=" England"/>
<yweather:wind xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" chill="64" direction="220" speed="11"/>
<yweather:atmosphere xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" humidity="91" pressure="1009.0" rising="0" visibility="13.9"/>
<yweather:astronomy xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" sunrise="4:37 am" sunset="9:28 pm"/>
<yweather:condition xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" code="11" date="Mon, 20 Jun 2016 01:00 PM BST" temp="64" text="Showers"/>
<yweather:forecast xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" code="12" date="20 Jun 2016" day="Mon" high="65" low="58" text="Rain"/>
I dont really know Apple Script very well but my old script uses the following code to extract the data for the forecast:
set forecast1Conditions to (do shell script "awk '/yweather:forecast/{print $0}' " & weatherFile & "| awk 'NR==1{print;exit}' | sed -e 's/.text=//;s/code=.//' | sed 's/\"//g'") as string
set forecast1Conditions to (my trim_string(forecast1Conditions, white_space, "both"))
do shell script ("echo " & forecast1Conditions)
This bombs out now with the newly formatted XML. Can anyone explain what am I doing wrong in trying to select the text="Rain" from the final yweather:forecast ?? I have plenty of other lines selecting all sorts of stuff so if someone can help with this I should be able to work out what I am doing wrong. I dont really understand AWK and SED.
Thanks
Apologies posted this in the UI customisations forum first...
Now that the Yahoo APIs have changed myt original script fails to work.
I have the following XML that I would like to use with Geektool, but am having issues :
<yweather:location xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" city="Peterborough" country="United Kingdom" region=" England"/>
<yweather:wind xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" chill="64" direction="220" speed="11"/>
<yweather:atmosphere xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" humidity="91" pressure="1009.0" rising="0" visibility="13.9"/>
<yweather:astronomy xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" sunrise="4:37 am" sunset="9:28 pm"/>
<yweather:condition xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" code="11" date="Mon, 20 Jun 2016 01:00 PM BST" temp="64" text="Showers"/>
<yweather:forecast xmlns:yweather="http://xml.weather.yahoo.com/ns/rss/1.0" code="12" date="20 Jun 2016" day="Mon" high="65" low="58" text="Rain"/>
I dont really know Apple Script very well but my old script uses the following code to extract the data for the forecast:
set forecast1Conditions to (do shell script "awk '/yweather:forecast/{print $0}' " & weatherFile & "| awk 'NR==1{print;exit}' | sed -e 's/.text=//;s/code=.//' | sed 's/\"//g'") as string
set forecast1Conditions to (my trim_string(forecast1Conditions, white_space, "both"))
do shell script ("echo " & forecast1Conditions)
This bombs out now with the newly formatted XML. Can anyone explain what am I doing wrong in trying to select the text="Rain" from the final yweather:forecast ?? I have plenty of other lines selecting all sorts of stuff so if someone can help with this I should be able to work out what I am doing wrong. I dont really understand AWK and SED.
Thanks
Apologies posted this in the UI customisations forum first...