Kodi Community Forum

Full Version: OzWeather - Australian Weather Addon using BOM data inc. animated radar support
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
bossanova808 Wrote:No errors here under Windows 7 or Openelec (linux, basically) - what platform are you on?

That's a pretty basic bit of the script and the syntaax is definitely correct - maybe there's a weird CR/LF thing going on, I am not sure about that '\n' bit as that's not in the source obviously, but might be coming from the xbmc log stuff.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 10.10
Release: 10.10
Codename: maverick

$ uname -a
Linux htpc 2.6.35-32-generic-pae #64-Ubuntu SMP Tue Jan 3 00:57:30 UTC 2012 i686 GNU/Linux

$ python -V
Python 2.6.6

XBMC 10.1 (Compiled: Mar 9 2011)
Transparency v3.11.7 skin

Oz Weather v0.3.2
Um ok, well, this is an add on for (pre) XBMC 11 only, so that might be it. Also, it's at version 0.3.4 now, so not sure why yours hasn't updated.

(Also, using transparency you won't get the best bit, the radar unless you port the MyWeather.xml to transparency...and if you do, let me know so I can add it to the release!).
Beta3 of XBMC is imminent. This should now incorporate the fix of the issue with the overlays not working on iOS/OSX - would be great if someone could test on those systems and let me know.
Ok I can confirm radar overlays work on OSX with Beta3 at least - so I presume iOS will be the same.
Hi,

I get a script error when I enter my postcode of 3000 too. I had a look in at the xbmc.log file and noticed this

Code:
15:23:32 T:8564   ERROR: Error Type: <type 'exceptions.IndexError'>
15:23:32 T:8564   ERROR: Error Contents: list index out of range
15:23:32 T:8564   ERROR: Traceback (most recent call last):
                                              File "C:\Users\USERNAME\AppData\Roaming\XBMC\addons\weather.ozweather\default.py", line 540, in <module>
                                                locationName = str.split(locationName[0], ' Weather')
                                            IndexError: list index out of range
15:23:33 T:3980   ERROR: Control 1 in window 10099 has been asked to focus, but it can't

I've tried disabling the Oz Weather, and also uninstalling/reinstalling it. And reloading XBMC, I've also checked the weather.ozweather folders in the addons is empty before i try to reinstall but no good. I still get the script error

I'm running Eden 11b3 on Windows 7

Cheers,
Andy
Hi Guys

I cannot download this app, I get the error message 404 - file not found?

does anyone have an updated link so I can download this awesome addon?

thanks in advance.
I agree. 404 error.

I can't find the source on the google code site either.
You need to grab my repo from here:
http://wiki.xbmc.org/index.php?title=Uno...positories

Right now the actual URL is:
http://bossanova808-xbmc-addons.googleco...-0.0.6.zip

..but via that page is the best way. Then you should install the repo zip and then incisde my repo you will find the latest add on.

I will be submitting it to the default repo sometime as well, most likely, to make this even easier.
Ok re: the 3000 error above - it works fine here, are you sure you're just typing 3000 and nothing else? It might have been a transient issue with WeatherZone, they do crop up, but usually go away again pretty quick.
And finally, code is always here:
https://code.google.com/p/bossanova808-xbmc-addons/

..not sure how you could miss it?
Hmm I looked under "downloads", not "source"

My bad.

Thanks for the add-on!

Scott
No probs.
Hi Bossa,

I was having the same trouble as the chap before with a script error when searching a postcode.

Bearing in mind in know very little about python...

The returned url from weather zone has a www. at the front which is missing from the script.
Also, unfortunately there are TWO HTML lists with class typ2, which breaks the script. It only checks one of the two lists, which is the one containing news. Because the list you want is in the "structure_middle" div I included a step before extracting the list to limit the html to just that div.
The third thing is that the length of skimmed is 1, even though the search returns many results. So I changed it to the length of the locations array.

To that end, I've created a patch to fix things. It has some log() calls which really shouldn't be there, feel free to remove them. I'm sure there are ten better ways to accomplish the same thing (like checking for (www\.)? at the start of the URL.

I hope you don't mind me fiddling with your code.

Regards
Scott

Code:
--- default.py.dist     2012-02-27 15:49:06.000000000 +1100
+++ default.py  2012-02-27 15:44:40.000000000 +1100
@@ -521,7 +521,7 @@
         text = keyboard.getText()

         #need to submit the postcode to the weatherzone search
-        searchURL = 'http://weatherzone.com.au/search/'
+        searchURL = 'http://www.weatherzone.com.au/search/'
         user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)'
         host = 'www.weatherzone.com.au'
         headers = { 'User-Agent' : user_agent, 'Host' : host }
@@ -530,9 +530,11 @@
         req = urllib2.Request(searchURL, data, headers)
         response = urllib2.urlopen(req)
         resultPage = str(response.read())
+#        log("OzWeather: got response", resultPage);
         #was there only one match?  If so it returns the page for that match so we need to check the URL
         responseurl = response.geturl()
-        if responseurl != 'http://weatherzone.com.au/search/':
+#        log("OzWeather: got responseurl", responseurl);
+        if responseurl != 'http://www.weatherzone.com.au/search/':
             #we were redirected to an actual result page
             locationName = common.parseDOM(resultPage, "h1", attrs = { "class": "unenclosed" })
             locationName = str.split(locationName[0], ' Weather')
@@ -540,17 +542,24 @@
             locationids = [responseurl]
         else:
             #we got back a page to choose a more specific location
-            skimmed = common.parseDOM(resultPage, "ul", attrs = { "class": "typ2" })
+            middle = common.parseDOM(resultPage, "div", attrs = { "id": "structure_middle" })
+#            log("OzWeather: got middle", middle);
+            skimmed = common.parseDOM(middle, "ul", attrs = { "class": "typ2" })
+#            skimmed = common.parseDOM(resultPage, "ul", attrs = { "class": "typ2" })
+#            log("OzWeather: got skimmed", skimmed);
             #ok now get two lists - one of the friendly names
             #and a matchin one of the URLs to store
             locations = common.parseDOM(skimmed[0], "a")
+#            log("OzWeather: got locations", locations);
+#            log("OzWeather: got locations length", len(locations));
             templocs = common.parseDOM(skimmed[0], "a", ret="href")
+#            log("OzWeather: got templocs", templocs);
             #build the full urls
             locationids = []
             for count, loc in enumerate(templocs):
                 locationids.append(WeatherZoneURL + loc)
             #if we did not get enough data back there are no locations with this postcode
-            if len(skimmed)<=1:
+            if len(locations)<=1:
                 locations = []
                 locationids = []
Not at all, patches welcome! But what postcode was giving you errors - I check about 7 by default and I haven't hit the issue.

Um....also, I am stupid with git - not immediately sure how to apply a patch Wink can you just post the changed function as you have it now? I'll also try and learn...
Hi Bossa,

and I have a feature request.

The UV value is the forecast from the BOM. Is there any chance of displaying the current. I couldn't find any source on the BOM site, but there is a real time capital city reading in XML here:
http://www.arpansa.gov.au/uvindex/realti...values.xml

Is there any chance you could read that data in and display it alongside the forecast?

Cheers,
Scott