aboutsummaryrefslogtreecommitdiffstats
path: root/config/hypr/UserScripts/Weather.py
diff options
context:
space:
mode:
authorJa.KooLit <85185940+JaKooLit@users.noreply.github.com>2025-05-20 15:48:58 +0000
committerGitHub <noreply@github.com>2025-05-20 15:48:58 +0000
commitddcc6d59e24e334d1d8cd812170a133e591f98bf (patch)
tree5eadf581be0ac201cc7a433fc05a688d6a8e14ab /config/hypr/UserScripts/Weather.py
parent2c59d4521a9a610a590876db94b176afeb5b26d8 (diff)
parent359f04a969f4e4c729a6d5d44b26639073497857 (diff)
Merge pull request #702 from JaKooLit/merge-fix
main to development
Diffstat (limited to 'config/hypr/UserScripts/Weather.py')
-rwxr-xr-xconfig/hypr/UserScripts/Weather.py12
1 files changed, 7 insertions, 5 deletions
diff --git a/config/hypr/UserScripts/Weather.py b/config/hypr/UserScripts/Weather.py
index b9efe4e4..efa96813 100755
--- a/config/hypr/UserScripts/Weather.py
+++ b/config/hypr/UserScripts/Weather.py
@@ -22,30 +22,32 @@ weather_icons = {
"default": "",
}
+
# Get current location based on IP address
def get_location():
response = requests.get("https://ipinfo.io")
data = response.json()
loc = data["loc"].split(",")
return float(loc[0]), float(loc[1])
-
+
+
# Get latitude and longitude
latitude, longitude = get_location()
# Open-Meteo API endpoint
url = f"https://weather.com/en-PH/weather/today/l/{latitude},{longitude}"
-# manual location_id
+# manual location_id
# NOTE: if you want to add manually, make sure you disable def get_location above
# to get your own location_id, go to https://weather.com & search your location.
# once you choose your location, you can see the location_id in the URL(64 chars long hex string)
# like this: https://weather.com/en-PH/weather/today/l/bca47d1099e762a012b9a139c36f30a0b1e647f69c0c4ac28b537e7ae9c1c200
-#location_id = "bca47d1099e762a012b9a139c36f30a0b1e647f69c0c4ac28b537e7ae9c1c200" # TODO
+# location_id = "bca47d1099e762a012b9a139c36f30a0b1e647f69c0c4ac28b537e7ae9c1c200" # TODO
# NOTE to change to deg F, change the URL to your preffered location after weather.com
# Default is English-Philippines with Busan, South Korea as location_id
# get html page
-#url = "https://weather.com/en-PH/weather/today/l/" + location_id
+# url = "https://weather.com/en-PH/weather/today/l/" + location_id
html_data = PyQuery(url=url)
@@ -86,7 +88,7 @@ temp_max = (
temp_min_max = f"ī‹‹ {temp_min}\t\t {temp_max}"
# wind speed
-wind_speed = html_data("span[data-testid='Wind']").text().split("\n")[1]
+wind_speed = str(html_data("span[data-testid='Wind'] > span").text())
wind_text = f" {wind_speed}"
# humidity
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage