New Source: South Tyneside, UK (#931)

* initial commit

* .md added

* integer uprn test case added

* Update_docu_links run
This commit is contained in:
dt215git
2023-04-29 17:15:25 +01:00
committed by GitHub
parent 691e376d19
commit 8c6e74a61f
4 changed files with 122 additions and 1 deletions

View File

@@ -716,6 +716,7 @@ Waste collection schedules in the following formats and countries are supported.
- [South Hams District Council](/doc/source/fccenvironment_co_uk.md) / southhams.gov.uk
- [South Norfolk and Broadland Council](/doc/source/south_norfolk_and_broadland_gov_uk.md) / area.southnorfolkandbroadland.gov.uk
- [South Oxfordshire District Council](/doc/source/binzone_uk.md) / southoxon.gov.uk
- [South Tyneside Council](/doc/source/southtyneside_gov_uk.md) / southtyneside.gov.uk
- [Southampton City Council](/doc/source/southampton_gov_uk.md) / southampton.gov.uk
- [Stevenage Borough Council](/doc/source/stevenage_gov_uk.md) / stevenage.gov.uk
- [Stockport Council](/doc/source/stockport_gov_uk.md) / stockport.gov.uk

View File

@@ -0,0 +1,83 @@
import json
import requests
from datetime import datetime
from waste_collection_schedule import Collection # type: ignore[attr-defined]
TITLE = "South Tyneside Council"
DESCRIPTION = "Source for southtyneside.gov.uk services for South Tyneside Council, UK."
URL = "https://southtyneside.gov.uk"
HEADERS = {
"Content-Type": "application/json; charset=UTF-8",
"Referer": "https://www.southtyneside.gov.uk/article/1023/Bin-collection-dates",
"User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/112.0",
}
API = "https://www.southtyneside.gov.uk/apiserver/ajaxlibrary"
TEST_CASES = {
"Test_001": {"postcode": "NE34 8RY", "uprn": "100000342955"},
"Test_002": {"postcode": "SR6 7AJ", "uprn": "100000359535"},
"Test_003": {"postcode": "NE31 1LY", "uprn": 100000304486},
}
ICON_MAP = {
"HOUSEHOLD": "mdi:trash-can",
"RECYCLING": "mdi:recycle",
"GARDEN": "mdi:leaf",
}
class Source:
def __init__(self, postcode, uprn):
self._postcode = str(postcode).replace(" ","")
self._uprn = str(uprn).zfill(12)
def fetch(self):
s = requests.Session()
# get uprn and full address for subsequent query
payload = json.dumps(
{
"id": "1682761045902",
"jsonrpc": "2.0",
"method": "stc.common.snippets.getAddressList",
"params": {
"localonly": "true",
"postcode": self._postcode
}
}
)
r1 = s.post(API, headers=HEADERS, data=payload)
json_data = json.loads(r1.text)["result"]["ReturnedList"]
for item in json_data:
if self._uprn in item["UPRN"]:
self._uprn = item["UPRN"]
self._address = item["Address"]
# get collection schedule
payload = json.dumps(
{
"id": "1682761056660",
"jsonrpc": "2.0",
"method": "stc.waste.collections.getDates",
"params": {
"addresscode": f"{self._uprn}|{self._address}"
}
}
)
r2 = s.post(API, headers=HEADERS, data=payload)
json_data = json.loads(r2.text)["result"]["SortedCollections"]
entries = []
for item in json_data:
for monthyear in item["Collections"]:
entries.append(
Collection(
date=datetime.strptime(
monthyear["DateofCollection"], "%Y-%m-%dT00:00:00").date(),
t=monthyear["TypeClass"],
icon=ICON_MAP.get(monthyear["TypeClass"].upper()),
)
)
return entries

View File

@@ -0,0 +1,37 @@
# South Tyneside Council
Support for schedules provided by [South Tyneside Council](https://www.southtyneside.gov.uk/article/1023/Bin-collection-dates), serving South Tyneside, UK.
## Configuration via configuration.yaml
```yaml
waste_collection_schedule:
sources:
- name: southtyneside_gov_uk
args:
postcode: POSTCODE
uprn: UPRN_CODE
```
### Configuration Variables
**postcode**
*(string) (required)*
**uprn**
*(string) (required)*
## Example
```yaml
waste_collection_schedule:
sources:
- name: southtyneside_gov_uk
args:
postcode: "NE34 8RY"
uprn: "100000342955"
```
## How to get the uprn argument above
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.

View File

@@ -30,7 +30,7 @@ Waste collection schedules from service provider web sites are updated daily, de
| Slovenia | Moji odpadki, Ljubljana |
| Sweden | Affärsverken, 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, Uppsala Vatten och Avfall AB, 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, Basildon Council, Basingstoke and Deane Borough Council, Bedford Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cherwell District Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of Doncaster Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, Fareham Council, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Herefordshire City Council, Horsham District Council, Huntingdonshire District Council, Leicester City Council, Lewes District Council, Liverpool City Council, London Borough of Bexley, London Borough of Bromley, London Borough of Lewisham, London Borough of Merton, 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 Lincolnshire Council, North Somerset Council, Nottingham City Council, Oxford City Council, Peterborough City Council, Reading Council, Reigate & Banstead Borough Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough 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, South Oxfordshire District Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Swindon Borough Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Tonbridge and Malling Borough Council, Uttlesford District Council, Vale of White Horse District Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Wyre Forest District Council |
| United Kingdom | Amber Valley Borough Council, Ashfield District Council, Basildon Council, Basingstoke and Deane Borough Council, Bedford Borough Council, Binzone, Blackburn with Darwen Borough Council, Bracknell Forest Council, Bradford Metropolitan District Council, Braintree District Council, Breckland Council, Bristol City Council, Buckinghamshire Waste Collection - Former Chiltern, South Bucks or Wycombe areas, Cambridge City Council, Canterbury City Council, Central Bedfordshire Council, Cherwell District Council, Cheshire East Council, Chesterfield Borough Council, Chichester District Council, City of Doncaster Council, City of York Council, Colchester City Council, Cornwall Council, Derby City Council, East Cambridgeshire District Council, East Herts Council, East Northamptonshire and Wellingborough, Eastbourne Borough Council, Elmbridge Borough Council, Environment First, Fareham Council, FCC Environment, Fenland District Council, Fife Council, Gateshead Council, Glasgow City Council, Guildford Borough Council, Harborough District Council, Harlow Council, Herefordshire City Council, Horsham District Council, Huntingdonshire District Council, Leicester City Council, Lewes District Council, Liverpool City Council, London Borough of Bexley, London Borough of Bromley, London Borough of Lewisham, London Borough of Merton, 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 Lincolnshire Council, North Somerset Council, Nottingham City Council, Oxford City Council, Peterborough City Council, Reading Council, Reigate & Banstead Borough Council, Richmondshire District Council, Rotherham Metropolitan Borough Council, Runnymede Borough 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, South Oxfordshire District Council, South Tyneside Council, Southampton City Council, Stevenage Borough Council, Stockport Council, Stockton-on-Tees Borough Council, Swindon Borough Council, Telford and Wrekin Council, Tewkesbury Borough Council, The Royal Borough of Kingston Council, Tonbridge and Malling Borough Council, Uttlesford District Council, Vale of White Horse District Council, Walsall Council, Waverley Borough Council, West Berkshire Council, West Devon Borough Council, West Dunbartonshire Council, Wigan Council, Wiltshire Council, Wyre Forest District Council |
| United States of America | City of Oklahoma City, City of Pittsburgh, Republic Services, Seattle Public Utilities |
<!--End of country section-->