Pijush2023 commited on
Commit
90998cc
·
verified ·
1 Parent(s): 89c6e54

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -13
app.py CHANGED
@@ -988,20 +988,54 @@ def fetch_google_hotels(query="Birmingham hotels", check_in="2024-08-14", check_
988
  hotel_results = results.get("hotel_results", [])
989
 
990
  response_text = ""
991
- for hotel in hotel_results[:5]: # Limiting to top 5 hotels
992
- name = hotel.get("title", "No name")
993
- address = hotel.get("address", "No address")
994
- rating = hotel.get("rating", "No rating")
995
- price = hotel.get("price", "No price")
996
- link = hotel.get("link", "#")
997
-
998
- response_text += f"[{name}]({link})\n"
999
- response_text += f"*{address}*\n"
1000
- response_text += f"**Rating:** {rating} stars\n"
1001
- response_text += f"**Price:** {price}\n"
1002
- response_text += "-" * 50 + "\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1003
 
1004
- return response_text
1005
 
1006
 
1007
 
 
988
  hotel_results = results.get("hotel_results", [])
989
 
990
  response_text = ""
991
+ def extract_hotel_info(hotel_data):
992
+ hotel_info = ""
993
+
994
+ for hotel in hotel_data:
995
+ name = hotel.get('name', 'No name')
996
+ description = hotel.get('description', 'No description')
997
+ link = hotel.get('link', '#')
998
+ latitude = hotel.get('gps_coordinates', {}).get('latitude', 'N/A')
999
+ longitude = hotel.get('gps_coordinates', {}).get('longitude', 'N/A')
1000
+ check_in_time = hotel.get('check_in_time', 'N/A')
1001
+ check_out_time = hotel.get('check_out_time', 'N/A')
1002
+ rate_per_night = hotel.get('rate_per_night', {}).get('lowest', 'N/A')
1003
+ before_taxes_fees = hotel.get('rate_per_night', {}).get('before_taxes_fees', 'N/A')
1004
+ total_rate = hotel.get('total_rate', {}).get('lowest', 'N/A')
1005
+ deal = hotel.get('deal', 'N/A')
1006
+ deal_description = hotel.get('deal_description', 'N/A')
1007
+ nearby_places = hotel.get('nearby_places', [])
1008
+ amenities = hotel.get('amenities', [])
1009
+
1010
+ hotel_info += f"**Hotel Name:** [{name}]({link})\n"
1011
+ hotel_info += f"**Description:** {description}\n"
1012
+ hotel_info += f"**Location:** Latitude: {latitude}, Longitude: {longitude}\n"
1013
+ hotel_info += f"**Check-in Time:** {check_in_time}\n"
1014
+ hotel_info += f"**Check-out Time:** {check_out_time}\n"
1015
+ hotel_info += f"**Rate per Night:** {rate_per_night} (Before taxes/fees: {before_taxes_fees})\n"
1016
+ hotel_info += f"**Total Rate:** {total_rate}\n"
1017
+ hotel_info += f"**Deal:** {deal} ({deal_description})\n"
1018
+
1019
+ if nearby_places:
1020
+ hotel_info += "**Nearby Places:**\n"
1021
+ for place in nearby_places:
1022
+ place_name = place.get('name', 'Unknown Place')
1023
+ transportations = place.get('transportations', [])
1024
+ hotel_info += f" - {place_name}:\n"
1025
+ for transport in transportations:
1026
+ transport_type = transport.get('type', 'N/A')
1027
+ duration = transport.get('duration', 'N/A')
1028
+ hotel_info += f" - {transport_type}: {duration}\n"
1029
+
1030
+ if amenities:
1031
+ hotel_info += "**Amenities:**\n"
1032
+ hotel_info += ", ".join(amenities) + "\n"
1033
+
1034
+ hotel_info += "-" * 50 + "\n"
1035
+
1036
+ return hotel_info
1037
+
1038
 
 
1039
 
1040
 
1041