Skip to content

Commit

Permalink
Use geo.places instead of geo.placefinder to get woeid from yahoo. Fi…
Browse files Browse the repository at this point in the history
…xes LP: #1573771

geo.placefinder doesn't exist any more which means we have
to use geo.places which always return single places if match found.
That means weather indicator code needs to modified as well to reflect these changes
  • Loading branch information
khurshid-alam committed May 20, 2017
1 parent 13461d4 commit 7f05282
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pywapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@

WOEID_SEARCH_URL = 'http://query.yahooapis.com/v1/public/yql'
WOEID_QUERY_STRING = 'select line1, line2, line3, line4, ' + \
'woeid from geo.placefinder where text="%s"'
'woeid from geo.places where text="%s"'

#WXUG_BASE_URL = 'http://api.wunderground.com/auto/wui/geo'
#WXUG_FORECAST_URL = WXUG_BASE_URL + '/ForecastXML/index.xml?query=%s'
Expand Down Expand Up @@ -967,13 +967,15 @@ def get_woeid_from_yahoo(search_string):
yahoo_woeid_result = json.loads(json_response)

try:
result = yahoo_woeid_result['query']['results']['Result']
result = yahoo_woeid_result['query']['results']['place']
except KeyError:
# On error, returned JSON evals to dictionary with one key, 'error'
return yahoo_woeid_result
except TypeError:
return {'error': 'No matching place names found'}


#geo-places doesn't return this sort of structure any more
'''
woeid_data = {}
woeid_data['count'] = yahoo_woeid_result['query']['count']
for i in xrange(yahoo_woeid_result['query']['count']):
Expand All @@ -986,8 +988,8 @@ def get_woeid_from_yahoo(search_string):
if place_data[tag] is not None]
place_name = ', '.join(name_lines)
woeid_data[i] = (place_data['woeid'], place_name)

return woeid_data
'''
return result['woeid']

def heat_index(temperature, humidity, units = 'metric'):
"""Calculate Heat Index for the specified temperature and humidity
Expand Down

0 comments on commit 7f05282

Please sign in to comment.