The branch, eden-pre has been updated
       via  34a6d7b424102fd9474ffdab77bd23d5f3b11ead (commit)
      from  4523e158258fd7d73493e65b75522dd0a89083ba (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=34a6d7b424102fd9474ffdab77bd23d5f3b11ead

commit 34a6d7b424102fd9474ffdab77bd23d5f3b11ead
Author: ronie <[email protected]>
Date:   Sun Feb 19 23:21:35 2012 +0100

    [weather.wunderground] -v0.0.5
    
    sync with xbmc git

diff --git a/weather.wunderground/addon.xml b/weather.wunderground/addon.xml
index 0ef8cbe..06e5deb 100644
--- a/weather.wunderground/addon.xml
+++ b/weather.wunderground/addon.xml
@@ -1,16 +1,21 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="weather.wunderground" name="Weather Underground" version="0.0.4" 
provider-name="Team XBMC">
+<addon id="weather.wunderground" name="Weather Underground" version="0.0.5" 
provider-name="Team XBMC">
        <requires>
                <import addon="xbmc.python" version="2.0"/>
                <import addon="script.module.simplejson" version="2.0.10"/>
        </requires>
        <extension point="xbmc.python.weather" library="default.py"/>
        <extension point="xbmc.addon.metadata">
+               <summary lang="bg">Синоптична прогноза от 
wunderground.com</summary>
                <summary lang="en">Weather forecast from 
wunderground.com</summary>
+               <summary lang="se">Väderprognos från 
wunderground.com</summary>
                <summary 
lang="zh">来自wunderground.com的天气预报</summary>
+               <description lang="bg">Прогноза за времето 
осигурена от Weather Underground 
(http://www.wunderground.com/)</description>
                <description lang="en">Weather forecast provided by Weather 
Underground (http://www.wunderground.com/)</description>
+               <description lang="se">Väderprognos tillhandahållen av 
Weather Underground (http://www.wunderground.com/)</description>
                <description lang="zh">由Weather 
Underground(http://www.wunderground.com/)提供的天气预报</description>
                <disclaimer lang="en">Use of this add-on implies that you have 
agreed to the Terms of Service located at 
http://www.wunderground.com/weather/api/d/terms.html</disclaimer>
+               <disclaimer lang="se">Användning av detta tillägg innebär 
att du har godkänt Terms of Service från 
http://www.wunderground.com/weather/api/d/terms.html</disclaimer>
                <disclaimer 
lang="zh">使用此扩展功能意味着你同意此连接下的服务条款:http://www.wunderground.com/weather/api/d/terms.html</disclaimer>
                <platform>all</platform>
        </extension>
diff --git a/weather.wunderground/changelog.txt 
b/weather.wunderground/changelog.txt
index d4ce40b..62596ec 100644
--- a/weather.wunderground/changelog.txt
+++ b/weather.wunderground/changelog.txt
@@ -1,3 +1,8 @@
+v0.0.5
+- add geoip support
+- fetch 7 day forecast
+- workaround: when user switches weather addon, xbmc may call the script with 
a location id that has not been setup. try to fallback to id 1 in this case.
+
 v0.0.4
 - don't fetch weather when no locations are set up
 - fix incrementing values on each weather refresh when no locations are set up
diff --git a/weather.wunderground/default.py b/weather.wunderground/default.py
index c00e6d3..86d07c7 100644
--- a/weather.wunderground/default.py
+++ b/weather.wunderground/default.py
@@ -28,8 +28,10 @@ from utilities import *
 
 LOCATION_URL    = 
'http://autocomplete.wunderground.com/aq?query=%s&format=JSON'
 WEATHER_URL     = 
'http://api.wunderground.com/api/%s/conditions/forecast7day/hourly%s.json'
+GEOIP_URL       = 'http://api.wunderground.com/api/%s/geolookup/q/autoip.json'
 A_I_K           = 'NDEzNjBkMjFkZjFhMzczNg=='
 WEATHER_WINDOW  = xbmcgui.Window(12600)
+MAXDAYS         = 6
 
 socket.setdefaulttimeout(10)
 
@@ -82,6 +84,16 @@ def location(string):
         locid.append(locationid)
     return loc, locid
 
+def geoip():
+    data = fetch(GEOIP_URL % aik[::-1])
+    if data != '' and data.has_key('location'):
+        location = data['location']['l']
+        __addon__.setSetting('Location1', data['location']['city'])
+        __addon__.setSetting('Location1id', location)
+    else:
+        location = ''
+    return location
+
 def forecast(city):
     data = fetch(WEATHER_URL % (aik[::-1], city))
     if data != '':
@@ -108,7 +120,7 @@ def properties(query):
         set_property('Day%i.Outlook'     % count, item['conditions'])
         set_property('Day%i.OutlookIcon' % count, '%s.png' % weathercode)
         set_property('Day%i.FanartCode'  % count, weathercode)
-        if count == 3:
+        if count == MAXDAYS:
             break
 
 if sys.argv[1].startswith('Location'):
@@ -129,9 +141,12 @@ if sys.argv[1].startswith('Location'):
 else:
     location = __addon__.getSetting('Location%sid' % sys.argv[1])
     aik = base64.b64decode(A_I_K)
+    if (location == '') and (sys.argv[1] != '1'):
+        location = __addon__.getSetting('Location1id')
+    if location == '':
+        location = geoip()
     if not location == '':
         forecast(location)
-        refresh_locations()
     else:
         # workaround to fix incrementing values on each weather refresh when 
no locations are set up:
         set_property('Current.Condition'     , 'N/A')
@@ -144,14 +159,13 @@ else:
         set_property('Current.DewPoint'      , '0')
         set_property('Current.OutlookIcon'   , 'na.png')
         set_property('Current.FanartCode'    , 'na')
-        for count in range (0, 3):
+        for count in range (0, MAXDAYS):
             set_property('Day%i.Title'       % count, 'N/A')
             set_property('Day%i.HighTemp'    % count, '0')
             set_property('Day%i.LowTemp'     % count, '0')
             set_property('Day%i.Outlook'     % count, 'N/A')
             set_property('Day%i.OutlookIcon' % count, 'na.png')
             set_property('Day%i.FanartCode'  % count, 'na')
-        # workaround to stop xbmc from running the script in a loop when no 
locations are set up:
-        set_property('Locations', '1')
 
+refresh_locations()
 set_property('WeatherProvider', 'Weather Underground')

-----------------------------------------------------------------------

Summary of changes:
 weather.wunderground/addon.xml                     |    7 +++++-
 weather.wunderground/changelog.txt                 |    5 ++++
 weather.wunderground/default.py                    |   24 +++++++++++++++----
 .../resources/language/Finnish/strings.xml         |    7 +++++
 .../resources/language/Swedish/strings.xml         |   12 ++++++++++
 5 files changed, 49 insertions(+), 6 deletions(-)
 create mode 100644 weather.wunderground/resources/language/Finnish/strings.xml
 create mode 100644 weather.wunderground/resources/language/Swedish/strings.xml


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to