mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 00:04:11 +01:00
added liverpool_gov_uk
Adding liverpool_gov_uk sources file, documentation file and updated info.md and README.md
This commit is contained in:
@@ -439,6 +439,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Horsham District Council](/doc/source/horsham_gov_uk.md) / horsham.gov.uk
|
||||
- [Huntingdonshire District Council](/doc/source/huntingdonshire_gov_uk.md) / huntingdonshire.gov.uk
|
||||
- [Lewes District Council](/doc/source/environmentfirst_co_uk.md) / lewes-eastbourne.gov.uk
|
||||
- [Liverpool City Council](/doc/source/liverpool_gov_uk.md) / liverpool.gov.uk
|
||||
- [London Borough of Lewisham](/doc/source/lewisham_gov_uk.md) / lewisham.gov.uk
|
||||
- [Maldon District Council](/doc/source/maldon_gov_uk.md) / maldon.gov.uk
|
||||
- [Manchester City Council](/doc/source/manchester_uk.md) / manchester.gov.uk
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
from datetime import datetime
|
||||
|
||||
import re
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from waste_collection_schedule import Collection
|
||||
|
||||
TITLE = "Liverpool City Council"
|
||||
DESCRIPTION = "Source for liverpool.gov.uk services for Liverpool City"
|
||||
URL = "https://www.liverpool.gov.uk"
|
||||
|
||||
TEST_CASES = {
|
||||
"52 Swallowhurst Crescent Liverpool L11 2UZ": {"uprn": "38148233"},
|
||||
"1 Aston Street Liverpool L19 8LR": {"uprn": "38010019"},
|
||||
}
|
||||
|
||||
API_URL = "https://liverpool.gov.uk/Bins/BinDatesTable?UPRN={uprn}&HideGreenBin=False&ShowTable=True"
|
||||
|
||||
ICON_MAP = {
|
||||
"Refuse": "mdi:trash-can",
|
||||
"Recycling": "mdi:recycle",
|
||||
"Green": "mdi:leaf",
|
||||
}
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, uprn=None, postcode=None, name_number=None):
|
||||
self._uprn = uprn
|
||||
|
||||
def fetch(self):
|
||||
today = datetime.today().date()
|
||||
entries = []
|
||||
|
||||
def trimsuffix(s):
|
||||
return re.sub(r'(\d)(st|nd|rd|th)', r'\1', s)
|
||||
|
||||
q = str(API_URL).format(uprn=self._uprn)
|
||||
|
||||
r = requests.get(q)
|
||||
r.raise_for_status()
|
||||
|
||||
soup = BeautifulSoup(r.text, "html.parser")
|
||||
table = soup.findAll('table')
|
||||
|
||||
rows = table[0].findAll(lambda tag: tag.name=='tr')
|
||||
|
||||
for row in rows[1:]:
|
||||
type=' '.join(row.find('th').text.split())
|
||||
fields = row.find_all('td')
|
||||
for field in fields:
|
||||
collectiondate = trimsuffix(' '.join(field.text.split()) + " " + datetime.today().strftime("%Y"))
|
||||
if re.match('Today',collectiondate):
|
||||
date = today
|
||||
elif re.match('Tomorrow',collectiondate):
|
||||
date = today + datetime.timedelta(days=1).date()
|
||||
else:
|
||||
date = datetime.strptime(collectiondate, '%A, %d %B %Y').date()
|
||||
|
||||
# As no year is specified we might need to add one year if it crosses Dec 31st
|
||||
if date < today:
|
||||
date.replace(year = today.year + 1)
|
||||
|
||||
entries.append(
|
||||
Collection(
|
||||
date=date,
|
||||
t=type,
|
||||
icon=ICON_MAP.get(type),
|
||||
)
|
||||
)
|
||||
|
||||
return entries
|
||||
52
doc/source/liverpool_gov_uk.md
Normal file
52
doc/source/liverpool_gov_uk.md
Normal file
@@ -0,0 +1,52 @@
|
||||
# Liverpool City Council
|
||||
|
||||
Support for schedules provided by [Liverpool City Council](http://liverpool.gov.uk/), serving Liverpool, UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: liverpool_gov_uk
|
||||
args:
|
||||
uprn: UPRN
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**uprn**
|
||||
*(string) (required)*
|
||||
|
||||
This is required to unambiguously identify the property.
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: liverpool_gov_uk
|
||||
args:
|
||||
uprn: "312345"
|
||||
|
||||
```
|
||||
|
||||
## How to find your `uprn`
|
||||
|
||||
You can find your house reference number by going to https://www.findmyaddress.co.uk/search and searching for your property.
|
||||
|
||||
You can also check the Liverpool City Council website by browsing to https://liverpool.gov.uk/Address/GetAddressesByPostcode/?postcode=L19 8LR and replacing postcode with your own. (You can leave a space in the URL or use %20 instead of the space)
|
||||
|
||||
## Returned collectons
|
||||
The API will return the next collection dates for each container type. This will typically be the collections for the next 3 weeks but may vary over holiday periods
|
||||
|
||||
## Returned collection types
|
||||
|
||||
### Green
|
||||
Green garden recycling
|
||||
|
||||
### Refuse
|
||||
Purple non-recycling
|
||||
|
||||
### Recycling
|
||||
Blue recycling bin/bag
|
||||
|
||||
2
info.md
2
info.md
@@ -29,7 +29,7 @@ Waste collection schedules from service provider web sites are updated daily, de
|
||||
| Slovenia | Moji odpadki, Ljubljana |
|
||||
| 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, Samverkan Återvinning Miljö (SÅM), 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, Basingstoke and Deane Borough Council, Blackburn with Darwen Borough 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, Herefordshire City Council, Horsham District Council, Huntingdonshire District Council, Lewes District Council, London Borough of Lewisham, Maldon District Council, Manchester City Council, Mid-Sussex District Council, Middlesbrough Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Herts 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, Uttlesford District 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, Basingstoke and Deane Borough Council, Blackburn with Darwen Borough 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, Herefordshire City Council, Horsham District Council, Huntingdonshire District Council, Lewes District Council, Liverpool City Council, London Borough of Lewisham, Maldon District Council, Manchester City Council, Mid-Sussex District Council, Middlesbrough Council, Newcastle City Council, Newcastle Under Lyme Borough Council, Newport City Council, North Herts 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, Uttlesford District 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-->
|
||||
|
||||
|
||||
Reference in New Issue
Block a user