mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 06:05:57 +01:00
remove awb_lm_de
This commit is contained in:
@@ -1,62 +0,0 @@
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
from waste_collection_schedule.service.ICS import ICS
|
||||
|
||||
TITLE = "Abfallwirtschaftsbetrieb Limburg-Weilburg"
|
||||
DESCRIPTION = "Source for AWB Limburg-Weilburg, Germany"
|
||||
URL = "https://www.awb-lm.de/"
|
||||
|
||||
TEST_CASES = {
|
||||
"Bad Camberg - Schillerstr.": { "district": 1, "city": 47, "street": 1384},
|
||||
"Limburg - Goethestr.": { "district": 9, "city": 52, "street": 1538}
|
||||
}
|
||||
|
||||
HEADERS = {"user-agent": "Mozilla/5.0 (xxxx Windows NT 10.0; Win64; x64)"}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, district, city, street=None):
|
||||
self._district = district
|
||||
self._city = city
|
||||
self._street = street
|
||||
self._ics = ICS()
|
||||
|
||||
def fetch(self):
|
||||
session = requests.Session()
|
||||
|
||||
params = {
|
||||
"Abfuhrbezirk": self._district,
|
||||
"Ortschaft": self._city,
|
||||
"Strasse": self._street,
|
||||
}
|
||||
|
||||
r = requests.post(
|
||||
"https://www.awb-lm.de/generator/abfuhrtermine.php",
|
||||
data=params
|
||||
)
|
||||
|
||||
r.raise_for_status()
|
||||
|
||||
soup = BeautifulSoup(r.text, features="html.parser")
|
||||
downloads = soup.find_all("a", href=True)
|
||||
ics_url = None
|
||||
for download in downloads:
|
||||
href = download.get("href")
|
||||
if "cache/ical" in href:
|
||||
ics_url = href
|
||||
|
||||
if ics_url is None:
|
||||
raise Exception(f"ics url not found")
|
||||
|
||||
# get ics file
|
||||
r = session.get("https://www.awb-lm.de" + ics_url, headers=HEADERS)
|
||||
r.raise_for_status()
|
||||
|
||||
# parse ics file
|
||||
dates = self._ics.convert(r.text)
|
||||
|
||||
entries = []
|
||||
for d in dates:
|
||||
entries.append(Collection(d[0], d[1].split(" am ")[0]))
|
||||
return entries
|
||||
@@ -1,53 +1,3 @@
|
||||
# AWB Limburg-Weilburg
|
||||
|
||||
Since Limburg-Weilburg changed their api, please use the [abfall.io source](abfall_io.md) instead!
|
||||
|
||||
---
|
||||
|
||||
Support for schedules provided by [awb-lm.de](https://www.awb-lm.de/) located in Hessen, Germany.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: awb_lm_de
|
||||
args:
|
||||
district: DISTRICT_ID
|
||||
city: CITY_ID
|
||||
street: STREET_ID
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**district**<br>
|
||||
*(int) (required)*
|
||||
|
||||
**city**<br>
|
||||
*(int) (required)*
|
||||
|
||||
**street**<br>
|
||||
*(int) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: awb_lm_de
|
||||
args:
|
||||
district: 1
|
||||
city: 47
|
||||
street: 1384
|
||||
```
|
||||
|
||||
|
||||
## How to get the source arguments
|
||||
|
||||
Visit [Abfuhrtermine](https://www.awb-lm.de/generator/abfuhrtermine.php), put in your address and press "Abfuhrtermine anzeigen".
|
||||
|
||||
Next right-click on the first dropdown and select "Inspect". Open the collapsed select-element in your browsers inspect-window. You'll find all the districts with their IDs, for example district "Limburg" with district ID 9:
|
||||
```html
|
||||
<option value="9">Limburg</option>
|
||||
```
|
||||
Repeat these steps for your city and street to get the correct IDs.
|
||||
Please use the [abfall.io source](abfall_io.md).
|
||||
Reference in New Issue
Block a user