From 944b7d8c7bbd2df3293c6e5fcd89595a4136f2b7 Mon Sep 17 00:00:00 2001 From: mampfes Date: Sun, 3 May 2020 08:38:44 +0200 Subject: [PATCH] set user-agent to support new abfall.io api with generic ics --- .../waste_collection_schedule/package/source/ics.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/custom_components/waste_collection_schedule/package/source/ics.py b/custom_components/waste_collection_schedule/package/source/ics.py index a3954370..7d5f3873 100644 --- a/custom_components/waste_collection_schedule/package/source/ics.py +++ b/custom_components/waste_collection_schedule/package/source/ics.py @@ -15,11 +15,20 @@ TEST_CASES = OrderedDict( { "url": "https://www.avl-ludwigsburg.de/fileadmin/Files/Abfallkalender/ICS/Privat/Privat_{%Y}_Ossweil.ics" }, - ) + ), + ( + "Esslingen, Bahnhof", + { + "url": "https://api.abfall.io/?kh=DaA02103019b46345f1998698563DaAd&t=ics&s=1a862df26f6943997cef90233877a4fe" + }, + ), ] ) +HEADERS = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"} + + class Source: def __init__(self, url): self.url = url @@ -40,7 +49,7 @@ class Source: def fetch_year(self, url): # get ics file - r = requests.get(url) + r = requests.get(url, headers=HEADERS) r.encoding = "utf-8" # requests doesn't guess the encoding correctly entries = []