mirror of
https://github.com/sascha-hemi/hacs_waste_collection_schedule.git
synced 2026-03-21 04:06:03 +01:00
Add City of Onkaparinga Council
This commit is contained in:
@@ -41,6 +41,7 @@ Waste collection schedules in the following formats and countries are supported.
|
||||
- [Melton City Council](/doc/source/melton_vic_gov_au.md) / melton.vic.gov.au
|
||||
- [Nillumbik Shire Council](/doc/source/nillumbik_vic_gov_au.md) / nillumbik.vic.gov.au
|
||||
- [North Adelaide Waste Management Authority](/doc/source/nawma_sa_gov_au.md) / nawma.sa.gov.au
|
||||
- [City of Onkaparinga Council](/doc/source/onkaparingacity_com.md) / onkaparingacity.com
|
||||
- [RecycleSmart](/doc/source/recyclesmart_com.md) / recyclesmart.com
|
||||
- [Stonnington City Council](/doc/source/stonnington_vic_gov_au.md) / stonnington.vic.gov.au
|
||||
- [The Hills Shire Council, Sydney](/doc/source/thehills_nsw_gov_au.md) / thehills.nsw.gov.au
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
from datetime import datetime
|
||||
from waste_collection_schedule import Collection # type: ignore[attr-defined]
|
||||
import json
|
||||
import requests
|
||||
from bs4 import BeautifulSoup
|
||||
|
||||
TITLE = "City of Onkaparinga Council"
|
||||
DESCRIPTION = "Source for City of Onkaparinga Council, Australia."
|
||||
URL = "https://www.onkaparingacity.com/"
|
||||
COUNTRY = "au"
|
||||
TEST_CASES = {
|
||||
"TestcaseI": {"address": "18 Flagstaff Road, FLAGSTAFF HILL 5159"},
|
||||
}
|
||||
|
||||
ICON_MAP = {
|
||||
"General Waste": "mdi:trash-can",
|
||||
"Recycling Waste": "mdi:recycle",
|
||||
"Green Waste": "mdi:leaf",
|
||||
}
|
||||
|
||||
class Source:
|
||||
def __init__(self, address):
|
||||
self._address = address
|
||||
|
||||
def fetch(self):
|
||||
url = "https://www.onkaparingacity.com/api/v1/myarea/search"
|
||||
|
||||
headers = {
|
||||
'referer': 'https://www.onkaparingacity.com/Services/Waste-and-recycling/Bin-collections'
|
||||
}
|
||||
|
||||
params = {
|
||||
'keywords': self._address
|
||||
}
|
||||
|
||||
r = requests.get(url, params=params, headers=headers)
|
||||
|
||||
addresses = r.json()
|
||||
|
||||
if addresses == 0:
|
||||
return []
|
||||
|
||||
url = 'https://www.onkaparingacity.com/ocapi/Public/myarea/wasteservices'
|
||||
|
||||
params = {
|
||||
'geolocationid': addresses['Items'][0]['Id'],
|
||||
'ocsvclang': 'en-AU'
|
||||
|
||||
}
|
||||
|
||||
r = requests.get(url, params=params, headers=headers)
|
||||
|
||||
waste = r.json()
|
||||
|
||||
soup = BeautifulSoup(waste['responseContent'], "html.parser")
|
||||
|
||||
waste_type = []
|
||||
|
||||
for tag in soup.find_all("h3"):
|
||||
if tag.text.startswith('Calendar'):
|
||||
continue
|
||||
waste_type.append(tag.text)
|
||||
|
||||
waste_date = []
|
||||
for tag in soup.find_all("div", {"class":"next-service"}):
|
||||
tag_text = tag.text.strip()
|
||||
if tag_text != "":
|
||||
date_object = datetime.strptime(tag_text, '%a %d/%m/%Y').date()
|
||||
waste_date.append(date_object)
|
||||
|
||||
waste = list(zip(waste_type, waste_date))
|
||||
|
||||
entries = []
|
||||
for item in waste:
|
||||
icon = ICON_MAP.get(item[0])
|
||||
entries.append(
|
||||
Collection(item[1], item[0], icon=icon)
|
||||
)
|
||||
|
||||
return entries
|
||||
35
doc/source/onkaparingacity_com.md
Normal file
35
doc/source/onkaparingacity_com.md
Normal file
@@ -0,0 +1,35 @@
|
||||
# City of Onkaparinga Council
|
||||
|
||||
Support for schedules provided by [City of Onkaparinga Council Waste and Recycling](https://www.onkaparingacity.com/Services/Waste-and-recycling/Bin-collections).
|
||||
|
||||
## Configuration via configuration.yaml
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: onkaparingacity_com
|
||||
args:
|
||||
address: ADDRESS
|
||||
```
|
||||
|
||||
### Configuration Variables
|
||||
|
||||
**address**
|
||||
*(string) (required)*
|
||||
|
||||
|
||||
## Example
|
||||
|
||||
```yaml
|
||||
waste_collection_schedule:
|
||||
sources:
|
||||
- name: onkaparingacity_com
|
||||
args:
|
||||
address: 18 Flagstaff Road, FLAGSTAFF HILL 5159
|
||||
```
|
||||
|
||||
## How to get the source arguments
|
||||
|
||||
Visit the [City of Onkaparinga Council Waste and Recycling](https://www.onkaparingacity.com/Services/Waste-and-recycling/Bin-collections) page and search for your address.
|
||||
The argument address should match the first result in the search list.
|
||||
Only the first match will be collected.
|
||||
2
info.md
2
info.md
@@ -16,7 +16,7 @@ Waste collection schedules from service provider web sites are updated daily, de
|
||||
|--|--|
|
||||
| Generic | ICS / iCal files |
|
||||
| Static | User-defined dates or repeating date patterns |<!--Begin of country section-->
|
||||
| Australia | Banyule City Council, Belmont City Council, Brisbane City Council, Campbelltown City Council, City of Canada Bay Council, Gold Coast City Council, Inner West Council (NSW), Ipswich City Council, Ku-ring-gai Council, Lake Macquarie City Council, Macedon Ranges Shire Council, Maribyrnong Council, Maroondah City Council, Melton City Council, Nillumbik Shire Council, North Adelaide Waste Management Authority, RecycleSmart, Stonnington City Council, The Hills Shire Council, Sydney, Wollongong City Council, Wyndham City Council, Melbourne |
|
||||
| Australia | Banyule City Council, Belmont City Council, Brisbane City Council, Campbelltown City Council, City of Canada Bay Council, Gold Coast City Council, Inner West Council (NSW), Ipswich City Council, Ku-ring-gai Council, Lake Macquarie City Council, Macedon Ranges Shire Council, Maribyrnong Council, Maroondah City Council, Melton City Council, Nillumbik Shire Council, North Adelaide Waste Management Authority, City of Onkaparinga Council, RecycleSmart, Stonnington City Council, The Hills Shire Council, Sydney, Wollongong City Council, Wyndham City Council, Melbourne |
|
||||
| Austria | Burgenländischer Müllverband, infeo, Stadtservice Korneuburg, Umweltprofis, WSZ Moosburg |
|
||||
| Belgium | Hygea, Recycle! |
|
||||
| Canada | City of Toronto |
|
||||
|
||||
Reference in New Issue
Block a user