-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1216 from m26dvd/master
fix: 2025 Council Pack 4
- Loading branch information
Showing
16 changed files
with
1,023 additions
and
219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
uk_bin_collection/uk_bin_collection/councils/AmberValleyBoroughCouncil.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.