Skip to content

Commit

Permalink
feat: Adding Dundee City Council
Browse files Browse the repository at this point in the history
fix: #1108
  • Loading branch information
m26dvd committed Jan 6, 2025
1 parent 5de7b0a commit 280a594
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
6 changes: 6 additions & 0 deletions uk_bin_collection/tests/input.json
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,12 @@
"wiki_name": "Dudley Council",
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
},
"DundeeCityCouncil": {
"url": "https://www.dundeecity.gov.uk/",
"uprn": "9059043390",
"wiki_name": "Dundee City Council",
"wiki_note": "You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN."
},
"DurhamCouncil": {
"skip_get_url": true,
"uprn": "200003218818",
Expand Down
44 changes: 44 additions & 0 deletions uk_bin_collection/uk_bin_collection/councils/DundeeCityCouncil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import time

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": []}

URI = f"https://www.dundee-mybins.co.uk/get_calendar.php?rn={user_uprn}"

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

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

for item in bin_collection:
dict_data = {
"type": item["title"],
"collectionDate": datetime.strptime(item["start"], "%Y-%m-%d").strftime(
date_format
),
}
bindata["bins"].append(dict_data)

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

return bindata
12 changes: 12 additions & 0 deletions wiki/Councils.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ This document is still a work in progress, don't worry if your council isn't lis
- [Dorset Council](#dorset-council)
- [Dover District Council](#dover-district-council)
- [Dudley Council](#dudley-council)
- [Dundee City Council](#dundee-city-council)
- [Durham Council](#durham-council)
- [Ealing Council](#ealing-council)
- [East Ayrshire Council](#east-ayrshire-council)
Expand Down Expand Up @@ -1181,6 +1182,17 @@ Note: You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/searc

---

### Dundee City Council
```commandline
python collect_data.py DundeeCityCouncil https://www.dundeecity.gov.uk/ -u XXXXXXXX
```
Additional parameters:
- `-u` - UPRN

Note: You will need to use [FindMyAddress](https://www.findmyaddress.co.uk/search) to find the UPRN.

---

### Durham Council
```commandline
python collect_data.py DurhamCouncil https://www.durham.gov.uk/bincollections?uprn= -s -u XXXXXXXX
Expand Down

0 comments on commit 280a594

Please sign in to comment.