Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create sbazb_de.py #3197

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import logging
import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
from waste_collection_schedule.service.ICS import ICS

TITLE = "Südbrandenburgischer Abfallzweckverband"
DESCRIPTION = "SBAZV Brandenburg, Deutschland"
URL = "https://www.sbazv.de"
TEST_CASES = {
"Schönefeld": {"url": "https://fahrzeuge.sbazv.de/WasteManagementSuedbrandenburg/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=1385852001&AboID=23187&Fra=P;R;WB;L;GS"},
}

ICON_MAP = {
"Restmülltonnen": "mdi:trash-can",
"Laubsäcke": "mdi:leaf",
"Gelbe Säcke": "mdi:sack",
"Papiertonnen": "mdi:package-variant",
"Weihnachtsbäume": "mdi:pine-tree",
}

_LOGGER = logging.getLogger(__name__)

PARAM_TRANSLATIONS = {}
# "de": {
# "city": "Ort",
# "district": "Ortsteil",
# "street": "Straße",
# },
#}


class Source:
def __init__(self, url):
self._url = url
self._ics = ICS()

def fetch(self):

# get ics file
# https://fahrzeuge.sbazv.de/WasteManagementSuedbrandenburg/WasteManagementServiceServlet?ApplicationName=Calendar&SubmitAction=sync&StandortID=1448170001&AboID=12386&Fra=P;R;WB;L;GS
# https://www.sbazv.de/entsorgungstermine/klein.ics?city=Wildau&district=Wildau&street=Miersdorfer+Str.
r = requests.get(self._url)

# parse ics file
dates = self._ics.convert(r.text)

entries = []
for d in dates:
waste_type = d[1].strip()
next_pickup_date = d[0]
# remove duplicates
if any(
e.date == next_pickup_date and e.type == waste_type for e in entries
):
continue
entries.append(
Collection(
date=next_pickup_date,
t=waste_type,
icon=ICON_MAP.get(waste_type),
)
)

return entries
Loading