Skip to content

Commit

Permalink
Merge pull request #1216 from m26dvd/master
Browse files Browse the repository at this point in the history
fix: 2025 Council Pack 4
  • Loading branch information
robbrad authored Feb 17, 2025
2 parents 5bf8503 + 29bd623 commit a009ab0
Show file tree
Hide file tree
Showing 16 changed files with 1,023 additions and 219 deletions.
45 changes: 41 additions & 4 deletions uk_bin_collection/tests/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
"wiki_name": "Adur and Worthing Councils",
"wiki_note": "Replace XXXXXXXX with your UPRN. You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find it."
},
"AmberValleyBoroughCouncil": {
"url": "https://ambervalley.gov.uk",
"uprn": "100030026621",
"wiki_name": "Amber Valley Borough Council",
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
},
"AntrimAndNewtonabbeyCouncil": {
"url": "https://antrimandnewtownabbey.gov.uk/residents/bins-recycling/bins-schedule/?Id=643",
"wiki_command_url_override": "https://antrimandnewtownabbey.gov.uk/residents/bins-recycling/bins-schedule/?Id=XXXX",
Expand Down Expand Up @@ -197,6 +203,12 @@
"wiki_name": "Blaenau Gwent County Borough Council",
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
},
"BolsoverCouncil": {
"url": "https://bolsover.gov.uk",
"uprn": "100030066827",
"wiki_name": "Bolsover Council",
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
},
"BoltonCouncil": {
"postcode": "BL1 5PQ",
"skip_get_url": true,
Expand Down Expand Up @@ -391,6 +403,12 @@
"wiki_name": "Cheltenham Borough Council",
"wiki_note": "Pass the UPRN. You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search)."
},
"CherwellDistrictCouncil": {
"uprn": "100121292407",
"url": "https://www.cherwell.gov.uk",
"wiki_name": "Cherwell District Council",
"wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
},
"CheshireEastCouncil": {
"url": "https://online.cheshireeast.gov.uk/MyCollectionDay/SearchByAjax/GetBartecJobList?uprn=100012791226&onelineaddress=3%20COBBLERS%20YARD,%20SK9%207DZ&_=1689413260149",
"wiki_command_url_override": "https://online.cheshireeast.gov.uk/MyCollectionDay/SearchByAjax/GetBartecJobList?uprn=XXXXXXXX&onelineaddress=XXXXXXXX&_=1689413260149",
Expand Down Expand Up @@ -440,11 +458,10 @@
"wiki_note": "Pass the house name/number in the house number parameter, wrapped in double quotes."
},
"ConwyCountyBorough": {
"postcode": "LL30 2DF",
"uprn": "100100429249",
"url": "https://www.conwy.gov.uk/Contensis-Forms/erf/collection-result-soap-xmas.asp?ilangid=1&uprn=100100429249",
"url": "https://www.conwy.gov.uk",
"wiki_name": "Conwy County Borough Council",
"wiki_note": "Conwy County Borough Council uses a straight UPRN in the URL, e.g., `&uprn=XXXXXXXXXXXXX`."
"wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
},
"CopelandBoroughCouncil": {
"uprn": "100110734613",
Expand Down Expand Up @@ -535,7 +552,6 @@
"skip_get_url": true,
"uprn": "10070102161",
"url": "https://www.derbyshiredales.gov.uk/",
"web_driver": "http://selenium:4444",
"wiki_name": "Derbyshire Dales District Council",
"wiki_note": "Pass the UPRN and postcode. To get the UPRN, you can use [FindMyAddress](https://www.findmyaddress.co.uk/search)."
},
Expand Down Expand Up @@ -709,6 +725,12 @@
"wiki_name": "Epping Forest District Council",
"wiki_note": "Replace the postcode in the URL with your own."
},
"EpsomandEwellBoroughCouncil": {
"uprn": "100061349083",
"url": "https://www.epsom-ewell.gov.uk",
"wiki_name": "Epsom and Ewell Borough Council",
"wiki_note": "Use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find your UPRN."
},
"ErewashBoroughCouncil": {
"skip_get_url": true,
"uprn": "10003582028",
Expand Down Expand Up @@ -1457,6 +1479,14 @@
"wiki_name": "Reading Borough Council",
"wiki_note": "Replace XXXXXXXX with your property's UPRN."
},
"RedcarandClevelandCouncil": {
"house_number": "11",
"postcode": "TS10 2RE",
"skip_get_url": true,
"url": "https://www.redcar-cleveland.gov.uk",
"wiki_name": "Redcar and Cleveland Council",
"wiki_note": "Pass the house name/number and postcode in their respective parameters"
},
"RedditchBoroughCouncil": {
"uprn": "10094557691",
"url": "https://redditchbc.gov.uk",
Expand Down Expand Up @@ -1531,6 +1561,13 @@
"wiki_name": "Rugby Borough Council",
"wiki_note": "Provide your UPRN and postcode. You can find your UPRN using [FindMyAddress](https://www.findmyaddress.co.uk/search)."
},
"RunnymedeBoroughCouncil": {
"skip_get_url": true,
"uprn": "100061483636",
"url": "https://www.runnymede.gov.uk/",
"wiki_name": "Runnymede Borough Council",
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
},
"RushcliffeBoroughCouncil": {
"postcode": "NG13 8TZ",
"skip_get_url": true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from datetime import datetime

import requests

from uk_bin_collection.uk_bin_collection.common import *
from uk_bin_collection.uk_bin_collection.get_bin_data import AbstractGetBinDataClass


# import the wonderful Beautiful Soup and the URL grabber
class CouncilClass(AbstractGetBinDataClass):
"""
Concrete classes have to implement all abstract operations of the
base class. They can also override some operations with a default
implementation.
"""

def parse_data(self, page: str, **kwargs) -> dict:

user_uprn = kwargs.get("uprn")
check_uprn(user_uprn)
bindata = {"bins": []}

WASTE_TYPES_DATE_KEY = {
"REFUSE": "refuseNextDate",
"RECYCLING": "recyclingNextDate",
"GREEN": "greenNextDate",
"COMMUNAL REFUSE": "communalRefNextDate",
"COMMUNAL RECYCLING": "communalRycNextDate",
}

URI = f"https://info.ambervalley.gov.uk/WebServices/AVBCFeeds/WasteCollectionJSON.asmx/GetCollectionDetailsByUPRN?uprn={user_uprn}"

# Make the GET request
response = requests.get(URI)

# Parse the JSON response
bin_collection = response.json()

# print(bin_collection)

for bin, datge_key in WASTE_TYPES_DATE_KEY.items():
date_ = datetime.strptime(
bin_collection[datge_key], "%Y-%m-%dT%H:%M:%S"
).strftime(date_format)
if date_ == "01/01/1":
continue
elif date_ == "01/01/1900":
continue

dict_data = {
"type": bin,
"collectionDate": date_,
}
bindata["bins"].append(dict_data)

bindata["bins"].sort(
key=lambda x: datetime.strptime(x.get("collectionDate"), "%d/%m/%Y")
)

return bindata
Loading

0 comments on commit a009ab0

Please sign in to comment.