diff --git a/plugin.py b/plugin.py index 57f6244..9b0aa7a 100644 --- a/plugin.py +++ b/plugin.py @@ -74,11 +74,17 @@ class OpenWeather(callbacks.Plugin): country = matches.group(3) if (country == None or country == 'US'): - loc = self.geocoding_manager.geocode(city, country='US', state_code - = state, limit = 1)[0] + loc_arr = self.geocoding_manager.geocode(city, country='US', state_code + = state, limit = 1) else: - loc = self.geocoding_manager.geocode(city, country, limit = 1)[0] + loc_arr = self.geocoding_manager.geocode(city, country, limit = 1) + if len(loc_arr) == 0: + irc.error(f'Could not find location with city {city}, state {state}, country {country}', + Raise=True) + + loc = loc_arr[0] + self.log.info(str(loc)) one_call = self.weather_manager.one_call(lat=loc.lat, lon=loc.lon,