mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 05:06:33 +01:00
add Dover District Council
This commit is contained in:
@@ -1502,6 +1502,7 @@ If your service provider is not listed, feel free to open a [source request issu
|
||||
- [Denbighshire County Council](/doc/source/denbighshire_gov_uk.md) / denbighshire.gov.uk
|
||||
- [Deprecated: Buckinghamshire](/doc/source/chiltern_gov_uk.md) / chiltern.gov.uk
|
||||
- [Derby City Council](/doc/source/derby_gov_uk.md) / derby.gov.uk
|
||||
- [Dover District Council](/doc/source/dover_gov_uk.md) / dover.gov.uk
|
||||
- [Dudley Metropolitan Borough Council](/doc/source/dudley_gov_uk.md) / dudley.gov.uk
|
||||
- [Durham County Council](/doc/source/durham_gov_uk.md) / durham.gov.uk
|
||||
- [East Ayrshire Council](/doc/source/east_ayrshire_gov_uk.md) / east-ayrshire.gov.uk
|
||||
|
||||
@@ -8107,6 +8107,11 @@
|
||||
"module": "derby_gov_uk",
|
||||
"default_params": {}
|
||||
},
|
||||
{
|
||||
"title": "Dover District Council",
|
||||
"module": "dover_gov_uk",
|
||||
"default_params": {}
|
||||
},
|
||||
{
|
||||
"title": "Dudley Metropolitan Borough Council",
|
||||
"module": "dudley_gov_uk",
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
from datetime import datetime
|
||||
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
|
||||
TITLE = "Dover District Council"
|
||||
DESCRIPTION = "Source for Dover District Council."
|
||||
URL = "https://www.dover.gov.uk"
|
||||
TEST_CASES = {
|
||||
"200002423404": {"uprn": 200002423404},
|
||||
"100060905828": {"uprn": "100060905828"},
|
||||
}
|
||||
|
||||
|
||||
ICON_MAP = {
|
||||
"Garden Waste Collection": "mdi:leaf",
|
||||
"Food Collection": "mdi:food-apple",
|
||||
"Refuse Collection": "mdi:trash-can",
|
||||
"Paper/Card Collection": "mdi:package-variant",
|
||||
"Recycling Collection": "mdi:recycle",
|
||||
}
|
||||
|
||||
|
||||
API_URL = "https://collections.dover.gov.uk/"
|
||||
|
||||
|
||||
class Source:
|
||||
def __init__(self, uprn: str | int):
|
||||
self._uprn: str | int = uprn
|
||||
|
||||
def fetch(self) -> list[Collection]:
|
||||
# copy of haringey_gov_uk.py just some minor changes
|
||||
api_url = f"https://collections.dover.gov.uk/property/{self._uprn}"
|
||||
response = requests.get(api_url)
|
||||
|
||||
soup = BeautifulSoup(response.text, features="html.parser")
|
||||
soup.prettify()
|
||||
|
||||
entries = []
|
||||
|
||||
service_elements = soup.select(".service-wrapper")
|
||||
|
||||
for service_element in service_elements:
|
||||
service_name = service_element.select(".service-name")[0].text.strip()
|
||||
|
||||
next_service_dates = service_element.select(
|
||||
"td.next-service"
|
||||
) + service_element.select("td.last-service")
|
||||
if len(next_service_dates) == 0:
|
||||
continue
|
||||
for next_service_date in next_service_dates:
|
||||
next_service_date.span.extract()
|
||||
|
||||
if next_service_date.text.strip().strip("-") == "":
|
||||
continue
|
||||
|
||||
entries.append(
|
||||
Collection(
|
||||
date=datetime.strptime(
|
||||
next_service_date.text.strip(), "%d/%m/%Y"
|
||||
).date(),
|
||||
t=service_name,
|
||||
icon=ICON_MAP.get(service_name),
|
||||
)
|
||||
)
|
||||
|
||||
return entries
|
||||
37
doc/source/dover_gov_uk.md
Normal file
37
doc/source/dover_gov_uk.md
Normal file
@@ -0,0 +1,37 @@
|
||||
# Dover District Council
|
||||
|
||||
Support for schedules provided by [Dover District Council](https://www.dover.gov.uk), serving Dover, UK.
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: dover_gov_uk
|
||||
args:
|
||||
uprn: "UPRN"
|
||||
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**uprn**
|
||||
*(String | Integer) (required)*
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: dover_gov_uk
|
||||
args:
|
||||
uprn: "200002423404"
|
||||
```
|
||||
|
||||
## How to get the source argument
|
||||
|
||||
You can find your UPRN when visiting the <https://collections.dover.gov.uk/> website and searching for your address. You can now see your UPRN in the address bar of your browser. e.g. `https://collections.dover.gov.uk/property/200002423404`, where `200002423404` is the UPRN.
|
||||
|
||||
### Getting your UPRN with an external service
|
||||
|
||||
An easy way to discover your Unique Property Reference Number (UPRN) is by going to <https://www.findmyaddress.co.uk/> and entering in your address details.
|
||||
Reference in New Issue
Block a user