Skip to content

Commit 52cb5ca

Browse files
committed
fix fkf_bo_hu
1 parent 9617389 commit 52cb5ca

File tree

5 files changed

+44
-26
lines changed

5 files changed

+44
-26
lines changed

custom_components/waste_collection_schedule/translations/de.json

+2
Original file line numberDiff line numberDiff line change
@@ -9961,6 +9961,7 @@
99619961
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/fkf_bo_hu.md",
99629962
"data": {
99639963
"calendar_title": "Kalender Titel",
9964+
"ssl_verify": "Ssl Verify",
99649965
"street": "Straße"
99659966
},
99669967
"data_description": {
@@ -9972,6 +9973,7 @@
99729973
"description": "Konfiguriere deinen Service Provider. Mehr details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/fkf_bo_hu.md",
99739974
"data": {
99749975
"calendar_title": "Kalender Titel",
9976+
"ssl_verify": "Ssl Verify",
99759977
"street": "Straße"
99769978
},
99779979
"data_description": {}

custom_components/waste_collection_schedule/translations/en.json

+2
Original file line numberDiff line numberDiff line change
@@ -9988,6 +9988,7 @@
99889988
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/fkf_bo_hu.md.",
99899989
"data": {
99909990
"calendar_title": "Calendar Title",
9991+
"ssl_verify": "Ssl Verify",
99919992
"street": "Street"
99929993
},
99939994
"data_description": {
@@ -9999,6 +10000,7 @@
999910000
"description": "Configure your service provider. More details: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/fkf_bo_hu.md.",
1000010001
"data": {
1000110002
"calendar_title": "Calendar Title",
10003+
"ssl_verify": "Ssl Verify",
1000210004
"street": "Street"
1000310005
},
1000410006
"data_description": {}

custom_components/waste_collection_schedule/translations/fr.json

+2
Original file line numberDiff line numberDiff line change
@@ -9912,6 +9912,7 @@
99129912
"description": "Configurez votre fournisseur de services. Plus de détails : https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/fkf_bo_hu.md.",
99139913
"data": {
99149914
"calendar_title": "Titre du Calendrier",
9915+
"ssl_verify": "Ssl Verify",
99159916
"street": "Street"
99169917
},
99179918
"data_description": {
@@ -9923,6 +9924,7 @@
99239924
"description": "Configurez votre fournisseur de services. Plus de détails : https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/fkf_bo_hu.md.",
99249925
"data": {
99259926
"calendar_title": "Titre du Calendrier",
9927+
"ssl_verify": "Ssl Verify",
99269928
"street": "Street"
99279929
},
99289930
"data_description": {}

custom_components/waste_collection_schedule/translations/it.json

+2
Original file line numberDiff line numberDiff line change
@@ -9919,6 +9919,7 @@
99199919
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. Maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/fkf_bo_hu.md.",
99209920
"data": {
99219921
"calendar_title": "Nome Calendario",
9922+
"ssl_verify": "Ssl Verify",
99229923
"street": "Strada"
99239924
},
99249925
"data_description": {
@@ -9930,6 +9931,7 @@
99309931
"description": "Compila i campi per ottenere le informazioni sul tuo servizio di raccolta. Per maggiori informazioni: https://github.com/mampfes/hacs_waste_collection_schedule/blob/master/doc/source/fkf_bo_hu.md.",
99319932
"data": {
99329933
"calendar_title": "Nome Calendario",
9934+
"ssl_verify": "Ssl Verify",
99339935
"street": "Strada"
99349936
},
99359937
"data_description": {}

custom_components/waste_collection_schedule/waste_collection_schedule/source/fkf_bo_hu.py

+36-26
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import json
2-
import requests
31
import datetime
2+
import json
43

4+
import requests
55
from bs4 import BeautifulSoup
66
from waste_collection_schedule import Collection
77

@@ -10,12 +10,12 @@
1010
URL = "https://www.fkf.hu"
1111
COUNTRY = "hu"
1212
TEST_CASES = {
13-
"Test_1": {"street": "Templom tér"},
14-
"Test_2": {"street": "Völgy utca"},
15-
"Test_3": {"street": "Zombori utca"}
13+
"Test_1": {"street": "Templom tér", "ssl_verify": False},
14+
"Test_2": {"street": "Völgy utca", "ssl_verify": False},
15+
"Test_3": {"street": "Zombori utca", "ssl_verify": False},
1616
}
1717

18-
API_URL = "https://www.fkf.hu/hulladeknaptar-budaors"
18+
API_URL = "https://www.mohubudapest.hu/hulladeknaptar-budaors"
1919
ICON_MAP = {
2020
"COMMUNAL": "mdi:trash-can",
2121
"SELECTIVE": "mdi:recycle",
@@ -24,61 +24,71 @@
2424

2525

2626
class Source:
27-
def __init__(self, street):
27+
def __init__(self, street, ssl_verify: bool = True):
2828
self._street = street
29+
self._ssl_verify = ssl_verify
2930

3031
def fetch(self):
3132
session = requests.Session()
3233

3334
r = session.post(
3435
API_URL,
35-
data={
36-
"publicPlace": self._street
37-
},
36+
data={"publicPlace": self._street},
3837
headers={
3938
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
4039
"X-October-Request-Handler": "onSearch",
4140
"X-October-Request-Partials": "ajax/budaorsResults",
4241
"X-Requested-With": "XMLHttpRequest",
43-
}
42+
},
43+
verify=self._ssl_verify,
4444
)
4545
r.raise_for_status()
46-
soup = BeautifulSoup(json.loads(r.text)["ajax/budaorsResults"], features="html.parser")
46+
soup = BeautifulSoup(
47+
json.loads(r.text)["ajax/budaorsResults"], features="html.parser"
48+
)
4749

48-
if soup.find("div", attrs={"class":"alert"}) is not None:
50+
if soup.find("div", attrs={"class": "alert"}) is not None:
4951
raise Exception("Address not found")
5052

5153
entries = []
52-
communal_divs = soup.find_all("div", attrs={"class":"communal"})
54+
communal_divs = soup.find_all("div", attrs={"class": "communal"})
5355

54-
selective = soup.find_all("div", attrs={"class":"selective"})
55-
communal = [i for i in filter(lambda div:div.text=="Kommunális", communal_divs)]
56-
green = [i for i in filter(lambda div:div.text=="Zöld", communal_divs)]
56+
selective = soup.find_all("div", attrs={"class": "selective"})
57+
communal = [
58+
i for i in filter(lambda div: div.text == "Kommunális", communal_divs)
59+
]
60+
green = [i for i in filter(lambda div: div.text == "Zöld", communal_divs)]
5761

5862
for element in communal:
5963
entries.append(
6064
Collection(
61-
date = datetime.datetime.strptime(element.parent.parent.findAll("td")[1].text, "%Y.%m.%d").date(),
62-
t = "Communal",
63-
icon = ICON_MAP.get("COMMUNAL"),
65+
date=datetime.datetime.strptime(
66+
element.parent.parent.findAll("td")[1].text, "%Y.%m.%d"
67+
).date(),
68+
t="Communal",
69+
icon=ICON_MAP.get("COMMUNAL"),
6470
)
6571
)
6672

6773
for element in selective:
6874
entries.append(
6975
Collection(
70-
date = datetime.datetime.strptime(element.parent.parent.findAll("td")[1].text, "%Y.%m.%d").date(),
71-
t = "Selective",
72-
icon = ICON_MAP.get("SELECTIVE"),
76+
date=datetime.datetime.strptime(
77+
element.parent.parent.findAll("td")[1].text, "%Y.%m.%d"
78+
).date(),
79+
t="Selective",
80+
icon=ICON_MAP.get("SELECTIVE"),
7381
)
7482
)
7583

7684
for element in green:
7785
entries.append(
7886
Collection(
79-
date = datetime.datetime.strptime(element.parent.parent.findAll("td")[1].text, "%Y.%m.%d").date(),
80-
t = "Green",
81-
icon = ICON_MAP.get("GREEN"),
87+
date=datetime.datetime.strptime(
88+
element.parent.parent.findAll("td")[1].text, "%Y.%m.%d"
89+
).date(),
90+
t="Green",
91+
icon=ICON_MAP.get("GREEN"),
8292
)
8393
)
8494

0 commit comments

Comments
 (0)