Update airbnb parse previous airbnb stays.
This commit is contained in:
parent
86bea456b1
commit
4b8c29a8d0
|
@ -73,11 +73,11 @@ def get_room_url(tree: Any) -> str | None:
|
||||||
|
|
||||||
|
|
||||||
def get_price_from_reservation(reservation: StrDict) -> str:
|
def get_price_from_reservation(reservation: StrDict) -> str:
|
||||||
price_string = reservation["payment_summary"]["subtitle"]
|
price = reservation["payment_summary"]["subtitle"]
|
||||||
assert isinstance(price_string, str)
|
assert isinstance(price, str)
|
||||||
tc = "Total cost: "
|
tc = "Total cost: "
|
||||||
assert price_string.startswith(tc)
|
if price.startswith(tc):
|
||||||
price = price_string[len(tc) :]
|
price = price[len(tc) :]
|
||||||
assert price[0] == "£"
|
assert price[0] == "£"
|
||||||
return price[1:]
|
return price[1:]
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ def extract_booking_from_html(html_file: str) -> StrDict:
|
||||||
metadata["check_out_date"], check_out_time, metadata["timezone"]
|
metadata["check_out_date"], check_out_time, metadata["timezone"]
|
||||||
)
|
)
|
||||||
|
|
||||||
address = reservation["map"]["address"]
|
address = reservation["map"]["address"] if "map" in reservation else None
|
||||||
|
|
||||||
if "header_action.pdp" in reservation:
|
if "header_action.pdp" in reservation:
|
||||||
name = reservation["header_action.pdp"]["subtitle"]
|
name = reservation["header_action.pdp"]["subtitle"]
|
||||||
|
@ -143,7 +143,6 @@ def extract_booking_from_html(html_file: str) -> StrDict:
|
||||||
"location": location,
|
"location": location,
|
||||||
"booking_reference": confirmation_code,
|
"booking_reference": confirmation_code,
|
||||||
"booking_url": f"https://www.airbnb.co.uk/trips/v1/reservation-details/ro/RESERVATION2_CHECKIN/{confirmation_code}",
|
"booking_url": f"https://www.airbnb.co.uk/trips/v1/reservation-details/ro/RESERVATION2_CHECKIN/{confirmation_code}",
|
||||||
"address": address,
|
|
||||||
"country": country_code,
|
"country": country_code,
|
||||||
"latitude": metadata["lat"],
|
"latitude": metadata["lat"],
|
||||||
"longitude": metadata["lng"],
|
"longitude": metadata["lng"],
|
||||||
|
@ -154,6 +153,8 @@ def extract_booking_from_html(html_file: str) -> StrDict:
|
||||||
"currency": "GBP",
|
"currency": "GBP",
|
||||||
"number_of_adults": number_of_adults,
|
"number_of_adults": number_of_adults,
|
||||||
}
|
}
|
||||||
|
if address:
|
||||||
|
booking["address"] = address
|
||||||
|
|
||||||
room_url = get_room_url(tree)
|
room_url = get_room_url(tree)
|
||||||
if room_url is not None:
|
if room_url is not None:
|
||||||
|
|
Loading…
Reference in a new issue