diff options
| author | Ja.KooLit <85185940+JaKooLit@users.noreply.github.com> | 2025-02-22 10:22:19 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-02-22 10:22:19 +0900 |
| commit | 341cdff88a33007724b59018d486363eda4c22c9 (patch) | |
| tree | 9a39cb2b787748c752a1529eeabd5978510f4fcb /config/hypr/UserScripts | |
| parent | 6c96baddd16accffb27cad48d534cf688e83d332 (diff) | |
Update Weather.py
just added the manual addition of location in case user wants that
Diffstat (limited to 'config/hypr/UserScripts')
| -rwxr-xr-x | config/hypr/UserScripts/Weather.py | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/config/hypr/UserScripts/Weather.py b/config/hypr/UserScripts/Weather.py index c739d2c5..b9efe4e4 100755 --- a/config/hypr/UserScripts/Weather.py +++ b/config/hypr/UserScripts/Weather.py @@ -8,15 +8,6 @@ import json import os from pyquery import PyQuery # install using `pip install pyquery` - -# 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]) - - # weather icons weather_icons = { "sunnyDay": "", @@ -31,11 +22,31 @@ 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 +# 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 + +# 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 + html_data = PyQuery(url=url) # current temperature |
