adding ravensburg Germany

This commit is contained in:
5ila5
2023-09-05 21:41:49 +02:00
parent 067735b141
commit e22d22b604
4 changed files with 174 additions and 2 deletions

View File

@@ -107,7 +107,7 @@ Waste collection schedules in the following formats and countries are supported.
- [Großwarasdorf](/doc/source/citiesapps_com.md) / grosswarasdorf.at
- [Großwilfersdorf](/doc/source/citiesapps_com.md) / grosswilfersdorf.steiermark.at
- [Gutenberg-Stenzengreith](/doc/source/citiesapps_com.md) / gutenberg-stenzengreith.gv.at
- [GVA Baden](/doc/source/baden_umweltverbaende_at.md) / scheibbs.umweltverbaende.at
- [GVA Baden](/doc/source/baden_umweltverbaende_at.md) / baden.umweltverbaende.at
- [GVU Scheibbs](/doc/source/scheibbs_umweltverbaende_at.md) / scheibbs.umweltverbaende.at
- [Güssing](/doc/source/citiesapps_com.md) / guessing.co.at
- [Hartberg](/doc/source/citiesapps_com.md) / hartberg.at
@@ -473,6 +473,7 @@ Waste collection schedules in the following formats and countries are supported.
- [Landratsamt Main-Tauber-Kreis](/doc/source/c_trace_de.md) / main-tauber-kreis.de
- [Landratsamt Traunstein](/doc/source/abfall_io.md) / traunstein.com
- [Landratsamt Unterallgäu](/doc/source/abfall_io.md) / landratsamt-unterallgaeu.de
- [Lankreis Ravensburg](/doc/source/rv_de.md) / rv.de
- [Lebacher Abfallzweckverband (LAZ)](/doc/ics/lebach_de.md) / lebach.de
- [Ludwigshafen am Rhein](/doc/source/abfall_io.md) / ludwigshafen.de
- [Lübbecke (Jumomind)](/doc/source/jumomind_de.md) / luebbecke.de

View File

@@ -0,0 +1,121 @@
# mostly copied from abfallwirtschaft_pforzheim_de.py
from html.parser import HTMLParser
import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
from waste_collection_schedule.service.ICS import ICS
TITLE = "Lankreis Ravensburg"
DESCRIPTION = "Source for Lankreis Ravensburg."
URL = "https://www.rv.de/"
TEST_CASES = {
"Altshausen Altshauser Weg 1 ": {
"ort": "Altshausen",
"strasse": "Altshauser Weg",
"hnr": 1,
"hnr_zusatz": "",
},
"Hoßkirch, Ob den Gärten 1": {
"ort": "Hoßkirch",
"strasse": "Ob den Gärten",
"hnr": "1",
"hnr_zusatz": "",
},
"Bad Kreznach, Steubenstraße 5645A": {
"ort": "bAd KrezNach",
"strasse": "steuBenstraße",
"hnr": 5645,
"hnr_zusatz": "A",
},
}
ICON_MAP = {
"Restmuelltonne": "mdi:trash-can",
"Biotonne": "mdi:leaf",
"Papiertonne": "mdi:package-variant",
"Gelbe": "mdi:recycle",
}
API_URL = "https://athos-onlinedienste.rv.de/WasteManagementRavensburgPrivat/WasteManagementServlet"
class HiddenInputParser(HTMLParser):
def __init__(self):
super().__init__()
self._args = {}
@property
def args(self):
return self._args
def handle_starttag(self, tag, attrs):
if tag == "input":
d = dict(attrs)
if str(d["type"]).lower() == "hidden":
self._args[d["name"]] = d["value"] if "value" in d else ""
class Source:
def __init__(self, ort: str, strasse: str, hnr: str | int, hnr_zusatz: str | int):
self._ort: str = ort
self._strasse: str = strasse
self._hnr: str | int = hnr
self._hnr_zusatz: str | int = hnr_zusatz
self._ics = ICS()
def fetch(self):
session = requests.session()
r = session.get(
API_URL,
params={"SubmitAction": "wasteDisposalServices", "InFrameMode": "TRUE"},
)
r.raise_for_status()
r.encoding = "utf-8"
parser = HiddenInputParser()
parser.feed(r.text)
args = parser.args
args["Ort"] = self._ort
args["Strasse"] = self._strasse
args["Hausnummer"] = str(self._hnr)
args["Hausnummerzusatz"] = self._hnr_zusatz
args["SubmitAction"] = "CITYCHANGED"
r = session.post(
API_URL,
data=args,
)
r.raise_for_status()
args["SubmitAction"] = "forward"
r = session.post(
API_URL,
data=args,
)
r.raise_for_status()
r = session.post(
API_URL,
data=args,
)
r.raise_for_status()
args["ApplicationName"] = "com.athos.nl.mvc.abfterm.AbfuhrTerminModel"
args["SubmitAction"] = "filedownload_ICAL"
r = session.post(
API_URL,
data=args,
)
r.raise_for_status()
dates = self._ics.convert(r.text)
entries = []
for d in dates:
entries.append(
Collection(d[0], d[1].strip(), ICON_MAP.get(d[1].split(" ")[0]))
)
return entries

50
doc/source/rv_de.md Normal file
View File

@@ -0,0 +1,50 @@
# Lankreis Ravensburg
Support for schedules provided by [Lankreis Ravensburg](https://www.rv.de/), serving Lankreis Ravensburg, Germany.
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: rv_de
args:
ort: ORT
strasse: STRAßE
hnr: "HAUSNUMMER"
hnr_zusatz: HAUSNUMMERZUSATZ
```
### Configuration Variables
**ort**
*(String) (required)*
**strasse**
*(String) (required)*
**hnr**
*(String | Integer) (required)*
**hnr_zusatz**
*(String | Integer) (optional)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: rv_de
args:
ort: Altshausen
strasse: Altshauser Weg
hnr: "1"
hnr_zusatz:
```
## How to get the source argument
Go to [https://www.rv.de/ihr+anliegen/abfall/abfallkalender+-+abfall+app+rv](https://www.rv.de/ihr+anliegen/abfall/abfallkalender+-+abfall+app+rv) click on the link below Abfallkalender zum Ausdrucken.
Find the parameter of your address and write them exactly like on the web page.

File diff suppressed because one or more lines are too long