add hull_gov_uk

This commit is contained in:
5ila5
2024-06-18 20:03:38 +02:00
committed by 5ila5
parent 85bcc71442
commit 0354b9cfb0
4 changed files with 87 additions and 1 deletions

View File

@@ -1299,6 +1299,7 @@ Waste collection schedules in the following formats and countries are supported.
- [Herefordshire City Council](/doc/source/herefordshire_gov_uk.md) / herefordshire.gov.uk
- [Highland](/doc/source/highland_gov_uk.md) / highland.gov.uk
- [Horsham District Council](/doc/source/horsham_gov_uk.md) / horsham.gov.uk
- [Hull City Council](/doc/source/hull_gov_uk.md) / hull.gov.uk
- [Huntingdonshire District Council](/doc/source/huntingdonshire_gov_uk.md) / huntingdonshire.gov.uk
- [iTouchVision](/doc/source/iweb_itouchvision_com.md) / iweb.itouchvision.com
- [Joint Waste Solutions](/doc/source/jointwastesolutions_org.md) / jointwastesolutions.org

View File

@@ -0,0 +1,51 @@
from datetime import datetime
import requests
from waste_collection_schedule import Collection # type: ignore[attr-defined]
TITLE = "Hull City Council"
DESCRIPTION = "Source for Hull City Council."
URL = "https://hull.gov.uk/"
TEST_CASES = {
"21095794": {"uprn": 21095794},
"21009164": {"uprn": "21009164"},
}
ICON_MAP = {
"black": "mdi:trash-can",
"blue": "mdi:package-variant",
"brown": "mdi:food-apple",
"bulky": "mdi:sofa",
}
API_URL = "https://www.hull.gov.uk/ajax/bin-collection"
class Source:
def __init__(self, uprn: str | int):
self._uprn: str | int = uprn
def fetch(self):
# get json
r = requests.get(
API_URL,
params={"bindate": self._uprn},
headers={"Referer": "https://www.hull.gov.uk/household-collections"},
)
r.raise_for_status()
data = r.json()
data = data[0] if isinstance(data[0], list) else data
entries = []
for entry in data:
date = datetime.strptime(entry["next_collection_date"], "%Y-%m-%d").date()
icon = ICON_MAP.get(
entry["collection_type"].lower().replace("bin", "").strip()
) # Collection icon
type = entry["collection_type"]
entries.append(Collection(date=date, t=type, icon=icon))
return entries

34
doc/source/hull_gov_uk.md Normal file
View File

@@ -0,0 +1,34 @@
# Hull City Council
Support for schedules provided by [Hull City Council](https://hull.gov.uk/), serving Hull, UK.
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: hull_gov_uk
args:
uprn: "UPRN"
```
### Configuration Variables
**uprn**
*(String | Integer) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: hull_gov_uk
args:
uprn: "21095794"
```
## How to get the source argument
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.

File diff suppressed because one or more lines are too long