Skip to content

Commit

Permalink
Merge pull request #439 from fwinn/master
Browse files Browse the repository at this point in the history
Add source for Landkreis Forchheim, Germany
  • Loading branch information
mampfes authored Nov 24, 2022
2 parents 859d959 + 8131659 commit b29ab47
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Currently the following service providers are supported:
- [Abfall.IO / AbfallPlus.de](./doc/source/abfall_io.md)
- [AbfallNavi.de (RegioIT.de)](./doc/source/abfallnavi_de.md)
- [Abfallkalender Würzburg](./doc/source/wuerzburg_de.md)
- [Abfalltermine Forchheim](./doc/source/abfalltermine_forchheim_de.md)
- [Abfallwirtschaft Landkreis Harburg](./doc/source/aw_harburg_de.md)
- [Abfallwirtschaft Landkreis Wolfenbüttel](./doc/source/alw_wf_de.md)
- [Abfallwirtschaft Neckar-Odenwald-Kreis](./doc/source/awn_de.md)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
from waste_collection_schedule.service.ICS import ICS

import urllib

TITLE = "Landkreis Forchheim"
DESCRIPTION = "Source for Landkreis Forchheim"
URL = "https://www.abfalltermine-forchheim.de/"
TEST_CASES = {
"Dormitz": {"city": "Dormitz", "area": "Dormitz"},
"Rüsselbach": {"city": "Igensdorf", "area": "Oberrüsselbach"},
"Kellerstraße": {"city": "Forchheim", "area": "Untere Kellerstraße (ab Adenauerallee bis Piastenbrücke)"}
}


class Source:
def __init__(self, city, area):
self._city = city
self._area = area
self._ics = ICS()

def fetch(self):
place = urllib.parse.quote(self._city + " - " + self._area)
r = requests.get(
f"http://www.abfalltermine-forchheim.de/Forchheim/Landkreis/{place}/ics?RESTMUELL=true&RESTMUELL_SINGLE=true&BIO=true&YELLOW_SACK=true&PAPER=true"
)
r.encoding = r.apparent_encoding
dates = self._ics.convert(r.text)

entries = []
for d in dates:
entries.append(Collection(d[0], d[1]))
return entries
42 changes: 42 additions & 0 deletions doc/source/abfalltermine_forchheim_de.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Abfalltermine Forchheim

Support for Landkreis Forchheim schedules provided by [abfalltermine-forchheim.de](https://www.abfalltermine-forchheim.de/) located in Bavaria, Germany.

## Configuration via configuration.yaml

```yaml
waste_collection_schedule:
sources:
- name: abfalltermine_forchheim_de
args:
city: CITY
area: AREA
```
### Configuration Variables
**city**<br>
*(string) (required)*
**area**<br>
*(string) (required)*
### How to get the source arguments
The arguments can be found on [abfalltermine-forchheim.de](https://www.abfalltermine-forchheim.de/).
Search for your area. Use the part in front of the dash as `city` argument and the part behind it as `area` argument. Do not insert additional spaces.
<br>

**Examples**
Forchheim - Bamberger Straße (nördlich der Adenauerallee)

```yaml
city: Forchheim
area: Bamberger Straße (nördlich der Adenauerallee)
```
<br>
Dormitz - Dormitz

```yaml
city: Dormitz
area: Dormitz
```
1 change: 1 addition & 0 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Currently the following service providers are supported:
- [Abfall.IO / AbfallPlus.de](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/abfall_io.md)
- [AbfallNavi.de (RegioIT.de)](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/abfallnavi_de.md)
- [Abfallkalender Würzburg](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/wuerzburg_de.md)
- [Abfalltermine Forchheim](./doc/source/abfalltermine_forchheim_de.md)
- [Abfallwirtschaft Landkreis Harburg](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/aw_harburg_de.md)
- [Abfallwirtschaft Landkreis Wolfenbüttel](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/alw_wf_de.md)
- [Abfallwirtschaft Neckar-Odenwald-Kreis](https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/awn_de.md)
Expand Down

0 comments on commit b29ab47

Please sign in to comment.