Merge pull request #651 from gingemonster/southderbyshire_gov_uk

adding South Derbyshire District Council
This commit is contained in:
Steffen Zimmermann
2023-01-31 07:29:09 +01:00
committed by GitHub
4 changed files with 97 additions and 2 deletions

View File

@@ -393,7 +393,8 @@ Waste collection schedules in the following formats and countries are supported.
- [Rushmoor Borough Council](/doc/source/rushmoor_gov_uk.md) / rushmoor.gov.uk
- [Salford City Council](/doc/source/salford_gov_uk.md) / salford.gov.uk
- [Sheffield City Council](/doc/source/sheffield_gov_uk.md) / sheffield.gov.uk
- [South Cambridgeshire District Council](/doc/source/scambs_gov_uk.md) / scambs.gov.uk
- [South Cambridgeshire District Council](/doc/source/scambs_gov_uk.md) / southderbyshire.gov.uk
- [South Derbyshire District Council](/doc/source/southderbyshire_gov_uk.md) / scambs.gov.uk
- [South Hams District Council](/doc/source/fccenvironment_co_uk.md) / southhams.gov.uk
- [South Norfolk and Broadland Council](/doc/source/south_norfolk_and_broadland_gov_uk.md) / area.southnorfolkandbroadland.gov.uk
- [Southampton City Council](/doc/source/southampton_gov_uk.md) / southampton.gov.uk

View File

@@ -0,0 +1,61 @@
import re
from datetime import datetime
import requests
from bs4 import BeautifulSoup
from waste_collection_schedule import Collection
TITLE = "South Derbyshire District Council"
DESCRIPTION = (
"Source for www.southderbyshire.gov.uk services for South Derbyshire "
)
URL = "https://www.southderbyshire.gov.uk/"
TEST_CASES = {
"test case 1": {"uprn": "100030233745"},
"test case 2": {"uprn": "10090304958"},
}
API_URL = "https://maps.southderbyshire.gov.uk/iShareLIVE.web/getdata.aspx?RequestType=LocalInfo&ms=mapsources/MyHouse&format=JSON&group=Recycling%20Bins%20and%20Waste|Next%20Bin%20Collections&uid="
ICON_MAP = {
"Black": "mdi:trash-can",
"Green": "mdi:recycle",
"Brown": "mdi:leaf",
"Podback": "mdi:coffee",
}
class Source:
def __init__(self, uprn: str):
self._uprn = uprn
def _extract_date(self, text):
# find date and return
date = re.search(r'(\d{2} \w+ \d{4})', text).group(1)
date = datetime.strptime(date, '%d %B %Y').date()
return date
def fetch(self):
entries = []
session = requests.Session()
r = session.get(f"{API_URL}{self._uprn}")
soup = BeautifulSoup(r.json()['Results']['Next_Bin_Collections']['_'], features="html.parser")
collections = soup.find_all("div", recursive=False)
if not collections:
raise Exception("No collections found for given UPRN")
for collection in collections:
bintypes = re.findall(r'Green|Brown|Black|Podback', collection.find("img")["alt"])
for bintype in bintypes:
entries.append(
Collection(
date=self._extract_date(collection.text),
t=bintype if bintype == "Podback" else bintype + " bin",
icon=ICON_MAP.get(bintype),
)
)
return entries

View File

@@ -0,0 +1,33 @@
# South Derbyshire District Council
Support for schedules provided by [South Derbyshire District Council](https://www.southderbyshire.gov.uk/our-services/recycling-bins-and-waste/bin-collection-dates), serving the
district of South Derbyshire, UK.
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: southderbyshire_gov_uk
args:
uprn: UPRN_CODE
```
### Configuration Variables
**uprn**
*(string) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: southderbyshire_gov_uk
args:
uprn: "100030233745"
```
## How to get the uprn argument above
The UPRN code for your property is not easy to extract from the South Derbyshire District Council website so we recommend using [FindMyAddress](https://www.findmyaddress.co.uk/search). Search using your address and it will return the UPRN for your property to use with this integration.

View File

@@ -28,7 +28,7 @@ Waste collection schedules from service provider web sites are updated daily, de
| Poland | Ecoharmonogram, Warsaw |
| Sweden | Jönköping - June Avfall & Miljö, Landskrona - Svalövs Renhållning, Lerum Vatten och Avlopp, Linköping - Tekniska Verken, Region Gotland, Ronneby Miljöteknik, SRV Återvinning, SSAM, Sysav Sophämntning, VA Syd Sophämntning |
| Switzerland | A-Region, Andwil, Appenzell, Berg, Bühler, Eggersriet, Gais, Gaiserwald, Goldach, Grosswangen, Grub, Heiden, Herisau, Horn, Hundwil, Häggenschwil, Lindau, Lutzenberg, Muolen, Mörschwil, Münchenstein, Rehetobel, Rorschach, Rorschacherberg, Schwellbrunn, Schönengrund, Speicher, Stein, Steinach, Teufen, Thal, Trogen, Tübach, Untereggen, Urnäsch, Wald, Waldkirch, Waldstatt, Wittenbach, Wolfhalden |
| United Kingdom | Amber Valley Borough Council, Ashfield District Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Horsham District Council, Huntingdonshire District Council, Lewes District Council, London Borough of Lewisham, Maldon District Council, Manchester City Council, Middlesbrough Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Somerset Council, Nottingham City Council, Oxford City Council, Peterborough City Council, Richmondshire District Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Hams District Council, South Norfolk and Broadland Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, Wiltshire Council, Wyre Forest District Council |
| United Kingdom | Amber Valley Borough Council, Ashfield District Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, FCC Environment, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Horsham District Council, Huntingdonshire District Council, Lewes District Council, London Borough of Lewisham, Maldon District Council, Manchester City Council, Middlesbrough Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Somerset Council, Nottingham City Council, Oxford City Council, Peterborough City Council, Richmondshire District Council, Rushmoor Borough Council, Salford City Council, Sheffield City Council, South Cambridgeshire District Council, South Derbyshire District Council, South Hams District Council, South Norfolk and Broadland Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, Wiltshire Council, Wyre Forest District Council |
| United States of America | City of Pittsburgh, Republic Services, Seattle Public Utilities |
<!--End of country section-->