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

Update Master #1

Merged
merged 7 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
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
13 changes: 2 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,7 @@ Waste collection schedules in the following formats and countries are supported.
- [Abfallwirtschaft Rems-Murr](/doc/source/awido_de.md) / abfallwirtschaft-rems-murr.de
- [Abfallwirtschaft Rendsburg](/doc/source/awr_de.md) / awr.de
- [Abfallwirtschaft Rheingau-Taunus-Kreis](/doc/source/c_trace_de.md) / eaw-rheingau-taunus.de
- [Abfallwirtschaft Sonneberg](/doc/ics/abfallwirtschaft_sonneberg_de.md) / abfallwirtschaft-sonneberg.de
- [Abfallwirtschaft Stadt Fürth](/doc/source/abfallwirtschaft_fuerth_eu.md) / abfallwirtschaft.fuerth.eu
- [Abfallwirtschaft Stadt Nürnberg](/doc/source/abfallnavi_de.md) / nuernberg.de
- [Abfallwirtschaft Stadt Schweinfurt](/doc/source/schweinfurt_de.md) / schweinfurt.de
Expand Down Expand Up @@ -648,18 +649,12 @@ Waste collection schedules in the following formats and countries are supported.
- [Frankfurt (Oder)](/doc/source/app_abfallplus_de.md) / Abfall+ App: unterallgaeu
- [Freiburg im Breisgau](/doc/source/app_abfallplus_de.md) / Abfall+ App: asf
- [Gelsendienste Gelsenkirchen](/doc/ics/gelsendienste_de.md) / gelsendienste.de
- [Gemeinde Aschheim](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Blankenheim](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Bühlerzell](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Deggenhausertal](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Kalletal](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Kappelrodeck](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Lindlar](/doc/source/abfallnavi_de.md) / lindlar.de
- [Gemeinde Mittelbiberach](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Oberstadion](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Roetgen](/doc/source/abfallnavi_de.md) / roetgen.de
- [Gemeinde Schutterwald](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Senden (Westfalen)](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Gemeinde Unterhaching](/doc/source/awido_de.md) / unterhaching.de
- [Gipsprojekt](/doc/ics/gipsprojekt_de.md) / gipsprojekt.de
- [Großkrotzenburg (MyMuell App)](/doc/source/jumomind_de.md) / mymuell.de
Expand All @@ -676,7 +671,6 @@ Waste collection schedules in the following formats and countries are supported.
- [Heidelberg](/doc/ics/gipsprojekt_de.md) / heidelberg.de
- [Heilbronn Entsorgungsbetriebe](/doc/source/heilbronn_de.md) / heilbronn.de
- [Hohenlohekreis](/doc/source/app_abfallplus_de.md) / Abfall+ App: hokwaste
- [Hohenlohekreis](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Holtgast (MyMuell App)](/doc/source/jumomind_de.md) / mymuell.de
- [Höxter](/doc/source/jumomind_de.md) / abfallservice.kreis-hoexter.de
- [Ilm-Kreis](/doc/source/app_abfallplus_de.md) / Abfall+ App: abfallappik
Expand Down Expand Up @@ -799,7 +793,6 @@ Waste collection schedules in the following formats and countries are supported.
- [Landkreis Roth](/doc/source/awido_de.md) / landratsamt-roth.de
- [Landkreis Roth](/doc/source/c_trace_de.md) / landratsamt-roth.de
- [Landkreis Schweinfurt](/doc/source/awido_de.md) / landkreis-schweinfurt.de
- [Landkreis Schwäbisch Hall](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Landkreis Schwäbisch Hall](/doc/source/lrasha_de.md) / lrasha.de
- [Landkreis Sigmaringen](/doc/source/abfall_io.md) / landkreis-sigmaringen.de
- [Landkreis soest](/doc/ics/abfall_app_net.md) / kreis-soest.de
Expand Down Expand Up @@ -887,16 +880,13 @@ Waste collection schedules in the following formats and countries are supported.
- [Stadt Darmstadt](/doc/source/muellmax_de.md) / darmstadt.de
- [Stadt Detmold](/doc/ics/detmold_de.md) / detmold.de
- [Stadt Dorsten](/doc/source/abfallnavi_de.md) / ebd-dorsten.de
- [Stadt Ehingen](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Stadt Emden](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Stadt Emmendingen](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Stadt Fulda](/doc/source/awido_de.md) / fulda.de
- [Stadt Haltern am See](/doc/source/muellmax_de.md) / haltern-am-see.de
- [Stadt Hamm](/doc/source/muellmax_de.md) / hamm.de
- [Stadt Hanau](/doc/source/muellmax_de.md) / hanau.de
- [Stadt Kaufbeuren](/doc/source/awido_de.md) / kaufbeuren.de
- [Stadt Koblenz](/doc/ics/koblenz_de.md) / koblenz.de
- [Stadt Kraichtal](/doc/source/cmcitymedia_de.md) / cmcitymedia.de
- [Stadt Landshut](/doc/source/abfall_io.md) / landshut.de
- [Stadt Maintal](/doc/source/muellmax_de.md) / maintal.de
- [Stadt Memmingen](/doc/source/awido_de.md) / umwelt.memmingen.de
Expand Down Expand Up @@ -1224,6 +1214,7 @@ Waste collection schedules in the following formats and countries are supported.
- [Lichfield District Council](/doc/source/lichfielddc_gov_uk.md) / lichfielddc.gov.uk
- [Lisburn and Castlereagh City Council](/doc/source/lisburn_castlereagh_gov_uk.md) / lisburncastlereagh.gov.uk
- [Liverpool City Council](/doc/source/liverpool_gov_uk.md) / liverpool.gov.uk
- [London Borough of Barking and Dagenham](/doc/source/lbbd_gov_uk.md) / lbbd.gov.uk
- [London Borough of Bexley](/doc/source/bexley_gov_uk.md) / bexley.gov.uk
- [London Borough of Bromley](/doc/source/bromley_gov_uk.md) / bromley.gov.uk
- [London Borough of Camden](/doc/source/camden_gov_uk.md) / camden.gov.uk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"realm": 9501,
"name": "www.lrasha.de - Müllkalender",
"region": "Landkreis Schwäbisch Hall",
"disabled": True,
"icons": {
"16": "mdi:trash-can", # Bio- und Restmüllabfuhr (60 l/120 l/240 l/1,1 m³)
"12": "mdi:recycle", # Gelbe Säcke
Expand All @@ -32,17 +33,31 @@
"realm": 100,
"name": "www.buehlerzell.de - Müllkalender",
"region": "Gemeinde Bühlerzell",
"disabled": True,
"icons": {
"44": "mdi:trash-can", # Bio- und Restmüllabfuhr (60 l/120 l/240 l/1,1 m³)
"42": "mdi:recycle", # Gelbe Säcke
"43": "mdi:package-variant", # Papiertonne
},
},
{
"hpid": 107,
"realm": 10701,
"name": "www.kressbronn.de - Müllkalender",
"region": "Gemeinde Kressbronn am Bodensee",
"disabled": True,
"icons": {
"47": "mdi:trash-can", # Bio- und Restmüllabfuhr
"46": "mdi:recycle", # Gelbe Säcke
"48": "mdi:package-variant", # Papiertonne
},
},
{
"hpid": 168,
"realm": 16801,
"name": "www.hohenlohekreis.de - Müllkalender",
"region": "Hohenlohekreis",
"disabled": True,
"icons": {
"31": "mdi:leaf", # Bioenergietonne
"36": "mdi:pine-tree", # Christbaumsammlung
Expand Down Expand Up @@ -75,6 +90,7 @@
"realm": 23301,
"name": "kraichtal.de - Müllkalender 1",
"region": "Stadt Kraichtal",
"disabled": True,
"icons": {
"19": "mdi:package-variant", # Altpapier
"21": "mdi:trash-can", # Reststoff
Expand All @@ -87,6 +103,7 @@
"realm": 24800,
"name": "www.kappelrodeck.de - Müllkalender",
"region": "Gemeinde Kappelrodeck",
"disabled": True,
"icons": {
"75": "mdi:trash-can", # Bio- und Restmüllabfuhr (60 l/120 l/240 l/1,1 m³)
"73": "mdi:recycle", # Gelbe Säcke
Expand All @@ -109,6 +126,7 @@
"realm": 37401,
"name": "www.aschheim.de - Müllkalender",
"region": "Gemeinde Aschheim",
"disabled": True,
"icons": {
"38": "mdi:leaf", # Biomüll
"147": "mdi:vacuum", # Biotonnenreinigung
Expand All @@ -127,6 +145,7 @@
"realm": 39000,
"name": "Mittelbiberach App - Müllkalender",
"region": "Gemeinde Mittelbiberach",
"disabled": True,
"icons": {
"149": "mdi:trash-can", # Bio- und Restmüllabfuhr
"148": "mdi:recycle", # Gelbe Säcke
Expand All @@ -138,6 +157,7 @@
"realm": 39100,
"name": "www.ehingen.de - Müllkalender",
"region": "Stadt Ehingen",
"disabled": True,
"icons": {
"116": "mdi:leaf", # Biotonne
"121": "mdi:package-variant", # Blaue Tonne
Expand All @@ -154,6 +174,7 @@
"realm": 42000,
"name": "Senden (Westfalen) App - Müllkalender",
"region": "Gemeinde Senden (Westfalen)",
"disabled": True,
"icons": {
"97": "mdi:leaf", # Biotonne
"95": "mdi:recycle", # gelbe Tonne/säcke
Expand All @@ -172,6 +193,7 @@
"realm": 42100,
"name": "KEPTN App - Müllkalender",
"region": "Stadt Emden",
"disabled": True,
"icons": {
"56": "mdi:recycle", # Gelber Sack (Gelbe Tonne)
"57": "mdi:package-variant", # Papier, Pappe, Karton (Blaue Tonne)
Expand Down Expand Up @@ -229,6 +251,7 @@
"realm": 44700,
"name": "Oberstadion App - Müllkalender",
"region": "Gemeinde Oberstadion",
"disabled": True,
"icons": {
"128": "mdi:tshirt-crew", # Altkleider
"133": "mdi:nail", # Altmetall
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
"Blankenheim": {"hpid": 415, "realmid": 41500},
"Oberstadion": {"hpid": 447, "district": 1349},
}
TEST_CASES.update({s["region"]: {"hpid": s["hpid"]} for s in SERVICE_MAP})



def EXTRA_INFO():
return [{"title": s["region"], "url": URL} for s in SERVICE_MAP]
return [
{"title": s["region"], "url": URL}
for s in SERVICE_MAP
if not s.get('disabled', False)
]


API_URL = "http://slim.cmcitymedia.de/v1/{}/waste/{}/dates"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def fetch(self):
return entries

def fetch_year(self, year):
arg = convert_to_arg(self._district)
r = requests.get(API_URL.format(year=year, arg=arg))
args = convert_to_arg(self._district)
r = requests.get(API_URL.format(year=year, arg=args[0]))
r.raise_for_status()
entries = self._ics.convert(r.text)
for prefix in (
Expand All @@ -56,13 +56,14 @@ def fetch_year(self, year):
"Papiertonne_Gollan",
"Papiertonne_Veolia",
):
try:
r = requests.get(API_URL.format(year=year, arg=f"{prefix}_{arg}"))
r.raise_for_status()
new_entries = self._ics.convert(r.text)
entries.extend(new_entries)
except (ValueError, requests.exceptions.HTTPError):
pass
for arg in args:
try:
r = requests.get(API_URL.format(year=year, arg=f"{prefix}_{arg}"))
r.raise_for_status()
new_entries = self._ics.convert(r.text)
entries.extend(new_entries)
except (ValueError, requests.exceptions.HTTPError):
pass
return entries


Expand All @@ -78,4 +79,6 @@ def convert_to_arg(district, prefix=""):
district = district.replace(" ", "_")
prefix = prefix + "_" if prefix else ""
arg = urllib.parse.quote(f"{prefix}Ortsteil_{district}")
return arg
if "-_" in arg: # no uniform format e.g Seefeld/ Testorf- Steinfort
return [arg, arg.replace("-_", "-")]
return [arg]
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
from datetime import datetime

import requests
import urllib3
from waste_collection_schedule import Collection # type: ignore[attr-defined]
from waste_collection_schedule.service.ICS import ICS

# With verify=True the POST fails due to a SSLCertVerificationError.
# Using verify=False works, but is not ideal. The following links may provide a better way of dealing with this:
# https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#ssl-warnings
# https://urllib3.readthedocs.io/en/1.26.x/user-guide.html#ssl
# These two lines areused to suppress the InsecureRequestWarning when using verify=False
urllib3.disable_warnings()

TITLE = "City of Karlsruhe"
DESCRIPTION = "Source for City of Karlsruhe."
URL = "https://www.karlsruhe.de/"
Expand Down Expand Up @@ -36,7 +44,7 @@
}


API_URL = "https://web6.karlsruhe.de/service/abfall/akal/akal_{year}.php"
API_URL = "https://web{i}.karlsruhe.de/service/abfall/akal/akal_{year}.php"


class Source:
Expand All @@ -50,10 +58,11 @@ def fetch(self):
now = datetime.now()
error = None
for year in (now.year, now.year + 1, now.year - 1):
try:
return self.get_data(API_URL.format(year=year))
except Exception as e:
error = e
for i in (4, 6):
try:
return self.get_data(API_URL.format(year=year, i=i))
except Exception as e:
error = e
raise error

def get_data(self, url):
Expand All @@ -65,7 +74,7 @@ def get_data(self, url):
}
params = {"hausnr": self._hnr}

r = requests.post(url, data=data, params=params)
r = requests.post(url, data=data, params=params, verify=False)
dates = self.ics.convert(r.text)

entries = []
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import datetime
import json

import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
from datetime import datetime

TITLE = "London Borough of Barking and Dagenham"
DESCRIPTION = "Source for London Borough of Barking and Dagenham."
URL = "https://www.lbbd.gov.uk/"
TEST_CASES = {
"100 Heathway": {"uprn": "100014033"},
"40 Porters Avenue": {"uprn": "100024629"},

}

COLLECTION_MAP = {
"Grey-Household": {
"waste_type": "General waste",
"icon": "mdi:trash-can",
},
"Brown-Recycling": {
"waste_type": "Recycling",
"icon": "mdi:recycle",
},
}

API_URL = "https://www.lbbd.gov.uk/rest/bin/{uprn}"


class Source:
def __init__(self, uprn: str | int):
self._uprn: str = str(uprn)

def fetch(self):
r = requests.get(API_URL.format(uprn=self._uprn))
rubbish_data = json.loads(r.content)

entries = []

for next_collection in rubbish_data["results"]:
collection_type = COLLECTION_MAP[next_collection["bin_type"]]
collection_date = next_collection["nextcollection"]
entries.append(
Collection(
date=datetime.strptime(collection_date, "%A %d %B %Y").date(),
t=collection_type["waste_type"],
icon=collection_type["icon"],
)
)

return entries
Loading