move-newport-to-itouchvision

This commit is contained in:
ReneNulschDE
2024-07-17 08:53:42 +02:00
committed by 5ila5
parent 7329c162eb
commit 6b985ddaa6
4 changed files with 18 additions and 67 deletions

View File

@@ -1392,7 +1392,7 @@ Waste collection schedules in the following formats and countries are supported.
- [Newark & Sherwood District Council](/doc/source/newark_sherwooddc_gov_uk.md) / newark-sherwooddc.gov.uk
- [Newcastle City Council](/doc/source/newcastle_gov_uk.md) / community.newcastle.gov.uk
- [Newcastle Under Lyme Borough Council](/doc/source/newcastle_staffs_gov_uk.md) / newcastle-staffs.gov.uk
- [Newport City Council](/doc/source/newport_gov_uk.md) / newport.gov.uk
- [Newport City Council](/doc/source/iweb_itouchvision_com.md) / newport.gov.uk/
- [North Ayrshire Council](/doc/source/north_ayrshire_gov_uk.md) / north-ayrshire.gov.uk
- [North Herts Council](/doc/source/northherts_gov_uk.md) / north-herts.gov.uk
- [North Kesteven District Council](/doc/source/north_kesteven_org_uk.md) / n-kesteven.org.uk

View File

@@ -7364,8 +7364,10 @@
},
{
"title": "Newport City Council",
"module": "newport_gov_uk",
"default_params": {}
"module": "iweb_itouchvision_com",
"default_params": {
"council": "NEWPORT"
}
},
{
"title": "North Ayrshire Council",

View File

@@ -55,8 +55,15 @@ EXTRA_INFO = [
"country": "uk",
"default_params": {"council": "TEST_VALLEY"},
},
{
"title": "Newport City Council",
"url": "https://www.newport.gov.uk//",
"country": "uk",
"default_params": {"council": "NEWPORT"},
},
]
DESCRIPTION = """Consolidated source for waste collection services from:
Newport City Council
Somerset Council, comprising four former District Councils (Mendip, Sedgemoor, Somerset West & Taunton, South Somerset) and Somerset County Council
Test Valley Borough Council
"""
@@ -66,6 +73,7 @@ HEADERS = {
URLS = {
"TEST_VALLEY": "https://iweb.itouchvision.com/portal/f?p=customer:BIN_DAYS:::NO:RP:UID:13353F039C4B1454827EE05536414091A8C058F4",
"SOMERSET": "https://iweb.itouchvision.com/portal/f?p=customer:BIN_DAYS:::NO:RP:UID:625C791B4D9301137723E9095361401AE8C03934",
"NEWPORT": "https://iweb.itouchvision.com/portal/f?p=customer:BIN_DAYS:::NO:RP:UID:6CDD2A34C912312074D8E2410531401A8C00EFF7",
"FLOW.ACCEPT": "https://iweb.itouchvision.com/portal/wwv_flow.accept",
"BIN_DAYS": "https://iweb.itouchvision.com/portal/itouchvision/r/customer/bin_days",
}
@@ -114,6 +122,11 @@ TEST_CASES = {
"uprn": 100060571645,
"council": "TEST_VALLEY",
},
"Newport #1": {
"postcode": "NP20 2QL",
"uprn": "10090955364",
"council": "NEWPORT",
},
}
ICON_MAP = {
"GARDEN": "mdi:leaf",

View File

@@ -1,64 +0,0 @@
from dateutil import parser
import re
from xml.dom.minidom import parseString
import requests
from waste_collection_schedule import Collection
TITLE = "Newport City Council"
DESCRIPTION = "Source for newport.gov.uk, Newport City Council, UK"
URL = "https://www.newport.gov.uk"
TEST_CASES = {
"The Coach House, Newport": {"uprn": 100100688837},
}
API_URL = "https://api.newport.gov.uk/PropertyData/bincollection/properties/{uprn}/Waste Collection"
ICON_MAP = {
"rubbish bin": "mdi:trash-can",
"kerbside recycling": "mdi:recycle",
"garden waste": "mdi:leaf",
}
def getText(element):
s = ""
for e in element.childNodes:
if e.nodeType == e.TEXT_NODE:
s += e.nodeValue
return s
class Source:
def __init__(self, uprn=None):
self._uprn = uprn
def fetch(self):
q = str(API_URL).format(uprn=self._uprn)
r = requests.get(q)
r.raise_for_status()
responseContent = r.text
entries = []
doc = parseString(responseContent)
collections = doc.getElementsByTagName("channel")
for collection in collections:
nameFull = getText(collection.getElementsByTagName("title")[0])
when = getText(collection.getElementsByTagName("title")[1])
if "Info:" in when:
continue
if "will resume" in when:
continue
name = re.search('next (.+?) collection', nameFull).group(1)
entries.append(
Collection(
date=parser.parse(when).date(),
t=name,
icon=ICON_MAP.get(name),
)
)
return entries