diff --git a/searx/engines/google_internal_search.py b/searx/engines/google_internal_search.py index ed5fde8ad..a15fade99 100644 --- a/searx/engines/google_internal_search.py +++ b/searx/engines/google_internal_search.py @@ -19,8 +19,8 @@ The implementation is shared by other engines: from urllib.parse import urlencode from json import loads, dumps -from datetime import datetime -from zoneinfo import ZoneInfo +from datetime import datetime, timedelta +from dateutil.tz import tzoffset from babel.dates import format_datetime import babel from searx.utils import html_to_text @@ -350,7 +350,6 @@ class ParseResultGroupItem: return results for item in item_to_parse["image_result_group_element"]: - print(item) results.append(parse_search_feature_proto(item["image_result"])) return results @@ -373,7 +372,13 @@ class ParseResultItem: # pylint: disable=too-few-public-methods timezones_0 = item_to_parse["payload"]["target_location"]["timezones"][0] iana_timezone = timezones_0["iana_timezone"] localized_location = timezones_0["localized_location"] - result_tz = ZoneInfo(iana_timezone) + # parse timezone_abbrev_specific to create result_tz + # timezone_abbrev_specific for India is "UTC+5:30" and for New York is "UTC−4" + # the values for offsets are respectively ["5", "30", "0"] and ["-4": "0"] + timezone_abbrev_specific = timezones_0["timezone_abbrev_specific"] + offsets = timezone_abbrev_specific.replace("UTC", "").replace("GMT", "").replace("−", "-").split(":") + offsets.append("0") + result_tz = tzoffset(iana_timezone, timedelta(hours=int(offsets[0]), minutes=int(offsets[1]))) result_dt = datetime.fromtimestamp(seconds_utc, tz=result_tz) result_dt_str = format_datetime(result_dt, 'long', tzinfo=result_tz, locale=self.locale) answer = f"{result_dt_str} ( {localized_location} )" @@ -390,7 +395,6 @@ def parse_web_results_list(json_data, locale): results_list = tier_1_search_results["result_list"]["item"] if "spell_suggestion" in tier_1_search_results: - print(tier_1_search_results["spell_suggestion"]) spell_suggestion = tier_1_search_results["spell_suggestion"] if "spell_column" in spell_suggestion: for spell_suggestion in tier_1_search_results["spell_suggestion"]["spell_column"]: