Skip to content

Commit

Permalink
Adds textual weather forecast
Browse files Browse the repository at this point in the history
  • Loading branch information
FL550 committed Apr 16, 2021
1 parent 81a8bbb commit c9cacba
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="simple_dwd_weatherforecast",
version="1.0.12",
version="1.0.13",
author="Max Fermor",
description="A simple tool to retrieve a weather forecast from DWD OpenData",
long_description=long_description,
Expand Down
22 changes: 15 additions & 7 deletions simple_dwd_weatherforecast/dwdforecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,15 +501,23 @@ def parse_kml(self, kml):
# print(f"temperatures: {self.forecast_data}")
self.forecast_data = merged_list

def get_weather_report(self):
if self.region is not None:
return download_weather_report(self.region_codes[self.region])
return None


def download_weather_report(region_code):
url = f"https://www.dwd.de/DWD/wetter/wv_allg/deutschland/text/vhdl13_{region_code}.html"
headers = {
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.116 Safari/537.36"
}
request = requests.get(url, headers=headers)
return request.text


def download_latest_kml(stationid):
url = (
"https://opendata.dwd.de/weather/local_forecasts/mos/MOSMIX_L/single_stations/"
+ stationid
+ "/kml/MOSMIX_L_LATEST_"
+ stationid
+ ".kmz"
)
url = f"https://opendata.dwd.de/weather/local_forecasts/mos/MOSMIX_L/single_stations/{stationid}/kml/MOSMIX_L_LATEST_{stationid}.kmz"
request = requests.get(url)
file = BytesIO(request.content)
kmz = ZipFile(file, "r")
Expand Down

0 comments on commit c9cacba

Please sign in to comment.