From df103f3d250c361ff0f997d42023247553c1f95f Mon Sep 17 00:00:00 2001 From: Carter Maxwell Date: Thu, 7 Apr 2016 12:59:09 -0700 Subject: [PATCH] fix weather.py after Yahoo made a change to their API that broke it --- sopel/modules/weather.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/sopel/modules/weather.py b/sopel/modules/weather.py index ea03b46135..b98affe4c8 100644 --- a/sopel/modules/weather.py +++ b/sopel/modules/weather.py @@ -137,16 +137,16 @@ def weather(bot, trigger): if not woeid: return bot.reply("I don't know where that is.") - query = web.urlencode({'w': woeid, 'u': 'c'}) - raw = web.get('http://weather.yahooapis.com/forecastrss?' + query, + query = 'q=select * from weather.forecast where woeid="%s" and u=\'c\'' % woeid + body = web.get('http://query.yahooapis.com/v1/public/yql?' + query, dont_decode=True) - parsed = xmltodict.parse(raw).get('rss') - location = parsed.get('channel').get('title') - - cover = get_cover(parsed) - temp = get_temp(parsed) - humidity = get_humidity(parsed) - wind = get_wind(parsed) + parsed = xmltodict.parse(body).get('query') + results = parsed.get('results') + location = results.get('channel').get('title') + cover = get_cover(results) + temp = get_temp(results) + humidity = get_humidity(results) + wind = get_wind(results) bot.say(u'%s: %s, %s, %s, %s' % (location, cover, temp, humidity, wind)) @@ -178,6 +178,5 @@ def update_woeid(bot, trigger): city = first_result.get('name') state = first_result.get('admin1').get('#text') or '' country = first_result.get('country').get('#text') or '' - uzip = first_result.get('postal').get('#text') or '' - bot.reply('I now have you at WOEID %s (%s%s, %s, %s %s)' % - (woeid, neighborhood, city, state, country, uzip)) + bot.reply('I now have you at WOEID %s (%s%s, %s, %s)' % + (woeid, neighborhood, city, state, country))