diff --git a/__init__.py b/__init__.py index 6adc71f8..f8ce3650 100644 --- a/__init__.py +++ b/__init__.py @@ -949,7 +949,7 @@ def _get_intent_data(self, message: Message) -> WeatherIntent: def _get_weather_config(self, message=None): sess = SessionManager.get(message) - cfg = {"lang": sess. lang, + cfg = {"lang": sess.lang, "system_unit": sess.system_unit, "location": sess.location_preferences, "date_format": sess.date_format, diff --git a/requirements.txt b/requirements.txt index d30bfacf..3302a84a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,7 @@ requests>=2.31.0 pytz -ovos-utils>=0.0.28 +ovos-utils>=0.4.0,<1.0.0 ovos-workshop>=2.2.0,<3.0.0 ovos-number-parser>=0.0.1,<1.0.0 ovos-date-parser>=0.0.2,<1.0.0 ovos-utterance-normalizer>=0.0.1,<1.0.0 -ovos-backend-client>=1.0.1,<2.0.0 diff --git a/weather_helpers/intent.py b/weather_helpers/intent.py index a0b9497a..c0051548 100644 --- a/weather_helpers/intent.py +++ b/weather_helpers/intent.py @@ -91,7 +91,7 @@ def geolocation(self): if self.location is None: self._geolocation = dict() else: - self._geolocation = get_geolocation(self.location) + self._geolocation = get_geolocation(self.location, lang=self.config.lang) return self._geolocation @property diff --git a/weather_helpers/util.py b/weather_helpers/util.py index 3cdb4762..fa7761b5 100644 --- a/weather_helpers/util.py +++ b/weather_helpers/util.py @@ -13,13 +13,12 @@ # limitations under the License. """Utility functions for the weather skill.""" from datetime import datetime, timedelta, tzinfo -from typing import List from itertools import islice +from typing import List import pytz - -from ovos_date_parser import nice_date, extract_datetime -from ovos_backend_client.api import GeolocationApi +from ovos_date_parser import nice_date, extract_datetime +from ovos_utils.geolocation import get_geolocation as _get_geo from ovos_utils.time import now_local, to_local @@ -83,11 +82,12 @@ def get_tz_info(timezone: str) -> tzinfo: return pytz.timezone(timezone) -def get_geolocation(location: str): +def get_geolocation(location: str, lang: str = "en"): """Retrieve the geolocation information about the requested location. Args: location: a location specified in the utterance + lang: lang to return country/region in Returns: A deserialized JSON object containing geolocation information for the @@ -96,8 +96,7 @@ def get_geolocation(location: str): Raises: LocationNotFound error if the API returns no results. """ - geolocation_api = GeolocationApi() - geolocation = geolocation_api.get_geolocation(location) + geolocation = _get_geo(location, lang=lang) if geolocation is None: raise LocationNotFoundError(f"Location {location} is unknown") @@ -106,7 +105,7 @@ def get_geolocation(location: str): return { "city": geolocation["city"]["name"], "region": geolocation["city"]["state"]["name"], - "country": geolocation["city"]["state"]["country"]["name"], + "country": geolocation["city"]["state"]["country"]["name"], "latitude": geolocation["coordinate"]["latitude"], "longitude": geolocation["coordinate"]["longitude"], "timezone": geolocation["timezone"]["code"]