Update airbnb parse previous airbnb stays.

This commit is contained in:
Edward Betts 2025-07-18 11:08:34 +02:00
parent 86bea456b1
commit 4b8c29a8d0

View file

@ -73,11 +73,11 @@ def get_room_url(tree: Any) -> str | None:
def get_price_from_reservation(reservation: StrDict) -> str:
price_string = reservation["payment_summary"]["subtitle"]
assert isinstance(price_string, str)
price = reservation["payment_summary"]["subtitle"]
assert isinstance(price, str)
tc = "Total cost: "
assert price_string.startswith(tc)
price = price_string[len(tc) :]
if price.startswith(tc):
price = price[len(tc) :]
assert price[0] == "£"
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"]
)
address = reservation["map"]["address"]
address = reservation["map"]["address"] if "map" in reservation else None
if "header_action.pdp" in reservation:
name = reservation["header_action.pdp"]["subtitle"]
@ -143,7 +143,6 @@ def extract_booking_from_html(html_file: str) -> StrDict:
"location": location,
"booking_reference": confirmation_code,
"booking_url": f"https://www.airbnb.co.uk/trips/v1/reservation-details/ro/RESERVATION2_CHECKIN/{confirmation_code}",
"address": address,
"country": country_code,
"latitude": metadata["lat"],
"longitude": metadata["lng"],
@ -154,6 +153,8 @@ def extract_booking_from_html(html_file: str) -> StrDict:
"currency": "GBP",
"number_of_adults": number_of_adults,
}
if address:
booking["address"] = address
room_url = get_room_url(tree)
if room_url is not None: