Fix weather geoip lookups

- _external_ip() isn't necessary with freegeoip.net as it does this for you when unspecified.
- region_name/country_name make Yahoo's weather API unhappy whereas region_code/country_code work for me (TX/US)
This commit is contained in:
Evan Callicoat 2013-11-01 00:57:33 -05:00
parent db80fc95ed
commit c293b62132
1 changed files with 3 additions and 3 deletions

View File

@ -335,10 +335,10 @@ class WeatherSegment(ThreadedSegment):
# Do not lock attribute assignments in this branch: they are used # Do not lock attribute assignments in this branch: they are used
# only in .update() # only in .update()
if not self.location: if not self.location:
location_data = json.loads(urllib_read('http://freegeoip.net/json/' + _external_ip())) location_data = json.loads(urllib_read('http://freegeoip.net/json/'))
self.location = ','.join([location_data['city'], self.location = ','.join([location_data['city'],
location_data['region_name'], location_data['region_code'],
location_data['country_name']]) location_data['country_code']])
query_data = { query_data = {
'q': 'q':
'use "http://github.com/yql/yql-tables/raw/master/weather/weather.bylocation.xml" as we;' 'use "http://github.com/yql/yql-tables/raw/master/weather/weather.bylocation.xml" as we;'