bnbingo 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bnbingo/__init__.py +1 -0
- bnbingo/amenities.json +34 -0
- bnbingo/amenities.py +412 -0
- bnbingo/auth.py +61 -0
- bnbingo/benchmarks.json +74 -0
- bnbingo/climate.py +157 -0
- bnbingo/config.py +63 -0
- bnbingo/fetcher.py +681 -0
- bnbingo/host_review.py +430 -0
- bnbingo/main.py +1365 -0
- bnbingo/reporter.py +449 -0
- bnbingo/scorer.py +687 -0
- bnbingo/utils.py +184 -0
- bnbingo-0.1.0.dist-info/METADATA +149 -0
- bnbingo-0.1.0.dist-info/RECORD +18 -0
- bnbingo-0.1.0.dist-info/WHEEL +4 -0
- bnbingo-0.1.0.dist-info/entry_points.txt +2 -0
- bnbingo-0.1.0.dist-info/licenses/LICENSE +21 -0
bnbingo/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.0"
|
bnbingo/amenities.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"essentials": {
|
|
3
|
+
"wifi": 4,
|
|
4
|
+
"kitchen": 8,
|
|
5
|
+
"washer": 33,
|
|
6
|
+
"dryer": 34,
|
|
7
|
+
"ac": 5,
|
|
8
|
+
"air_conditioning": 5,
|
|
9
|
+
"heating": 30,
|
|
10
|
+
"dedicated_workspace": 47,
|
|
11
|
+
"tv": 1,
|
|
12
|
+
"iron": 40
|
|
13
|
+
},
|
|
14
|
+
"features": {
|
|
15
|
+
"pool": 7,
|
|
16
|
+
"free_parking": 9,
|
|
17
|
+
"gym": 15,
|
|
18
|
+
"hot_tub": 25,
|
|
19
|
+
"elevator": 21,
|
|
20
|
+
"ev_charger": 41
|
|
21
|
+
},
|
|
22
|
+
"safety": {
|
|
23
|
+
"smoke_alarm": 35,
|
|
24
|
+
"carbon_monoxide_alarm": 36,
|
|
25
|
+
"fire_extinguisher": 39,
|
|
26
|
+
"first_aid_kit": 37
|
|
27
|
+
},
|
|
28
|
+
"services": {
|
|
29
|
+
"breakfast": 16,
|
|
30
|
+
"self_check_in": 51,
|
|
31
|
+
"luggage_drop_off": 73,
|
|
32
|
+
"long_term_stays": 85
|
|
33
|
+
}
|
|
34
|
+
}
|
bnbingo/amenities.py
ADDED
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
"""Canonical Amenity Registry and Multi-Layer Kitchen & Living Evaluation Module."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
import re
|
|
5
|
+
from typing import Any, Dict, List, Optional
|
|
6
|
+
|
|
7
|
+
logger = logging.getLogger("bnbingo")
|
|
8
|
+
|
|
9
|
+
AMENITY_REGISTRY: Dict[str, Dict[str, Any]] = {
|
|
10
|
+
"ac": {
|
|
11
|
+
"search_id": 5,
|
|
12
|
+
"titles": [
|
|
13
|
+
"air conditioning",
|
|
14
|
+
"central air conditioning",
|
|
15
|
+
"portable air conditioning",
|
|
16
|
+
"split-type ductless ac",
|
|
17
|
+
"split type ductless ac",
|
|
18
|
+
"window ac unit",
|
|
19
|
+
"aire acondicionado",
|
|
20
|
+
"a/c",
|
|
21
|
+
"minisplit",
|
|
22
|
+
"mini-split",
|
|
23
|
+
"split",
|
|
24
|
+
"climatizador",
|
|
25
|
+
"climatiseur",
|
|
26
|
+
"ar condicionado",
|
|
27
|
+
],
|
|
28
|
+
"icons": ["SYSTEM_SNOWFLAKE"],
|
|
29
|
+
"name": "Air Conditioning",
|
|
30
|
+
},
|
|
31
|
+
"air_conditioning": {
|
|
32
|
+
"search_id": 5,
|
|
33
|
+
"alias_of": "ac",
|
|
34
|
+
},
|
|
35
|
+
"kitchen": {
|
|
36
|
+
"search_id": 8,
|
|
37
|
+
"titles": ["kitchen", "cocina"],
|
|
38
|
+
"icons": ["SYSTEM_COOKING_BASICS"],
|
|
39
|
+
"name": "Kitchen",
|
|
40
|
+
},
|
|
41
|
+
"stove": {
|
|
42
|
+
"search_id": None,
|
|
43
|
+
"titles": [
|
|
44
|
+
"stove",
|
|
45
|
+
"gas stove",
|
|
46
|
+
"electric stove",
|
|
47
|
+
"induction stove",
|
|
48
|
+
"cocina a gas",
|
|
49
|
+
"cocina electrica",
|
|
50
|
+
"cocina eléctrica",
|
|
51
|
+
"estufa",
|
|
52
|
+
"anafe",
|
|
53
|
+
"anafe electrico",
|
|
54
|
+
"anafe eléctrico",
|
|
55
|
+
"hornalla",
|
|
56
|
+
"hornallas",
|
|
57
|
+
"parrilla",
|
|
58
|
+
"parrilla de gas",
|
|
59
|
+
"vitroceramica",
|
|
60
|
+
"vitrocerámica",
|
|
61
|
+
"vitro",
|
|
62
|
+
"placa de induccion",
|
|
63
|
+
"placa de inducción",
|
|
64
|
+
"fogao",
|
|
65
|
+
"fogão",
|
|
66
|
+
"cooktop",
|
|
67
|
+
],
|
|
68
|
+
"icons": ["SYSTEM_STOVE"],
|
|
69
|
+
"name": "Stove",
|
|
70
|
+
},
|
|
71
|
+
"oven": {
|
|
72
|
+
"search_id": None,
|
|
73
|
+
"titles": [
|
|
74
|
+
"oven",
|
|
75
|
+
"baking oven",
|
|
76
|
+
"gas oven",
|
|
77
|
+
"electric oven",
|
|
78
|
+
"horno",
|
|
79
|
+
"horno a gas",
|
|
80
|
+
"horno electrico",
|
|
81
|
+
"horno eléctrico",
|
|
82
|
+
"horno convencional",
|
|
83
|
+
],
|
|
84
|
+
"exclude_substrings": ["microondas", "microwave"],
|
|
85
|
+
"icons": ["SYSTEM_OVEN"],
|
|
86
|
+
"name": "Oven",
|
|
87
|
+
},
|
|
88
|
+
"refrigerator": {
|
|
89
|
+
"search_id": None,
|
|
90
|
+
"titles": [
|
|
91
|
+
"refrigerator",
|
|
92
|
+
"fridge",
|
|
93
|
+
"full-size refrigerator",
|
|
94
|
+
"mini fridge",
|
|
95
|
+
"refrigerador",
|
|
96
|
+
"refrigeradora",
|
|
97
|
+
"heladera",
|
|
98
|
+
"heladera con freezer",
|
|
99
|
+
"nevera",
|
|
100
|
+
"frigobar",
|
|
101
|
+
"geladeira",
|
|
102
|
+
],
|
|
103
|
+
"icons": ["SYSTEM_REFRIGERATOR"],
|
|
104
|
+
"name": "Refrigerator",
|
|
105
|
+
},
|
|
106
|
+
"cooking_basics": {
|
|
107
|
+
"search_id": None,
|
|
108
|
+
"titles": [
|
|
109
|
+
"cooking basics",
|
|
110
|
+
"pots and pans",
|
|
111
|
+
"ollas y sartenes",
|
|
112
|
+
"elementos basicos para cocinar",
|
|
113
|
+
"elementos básicos para cocinar",
|
|
114
|
+
],
|
|
115
|
+
"icons": ["SYSTEM_COOKING_BASICS"],
|
|
116
|
+
"name": "Cooking Basics",
|
|
117
|
+
},
|
|
118
|
+
"dishwasher": {
|
|
119
|
+
"search_id": None,
|
|
120
|
+
"titles": ["dishwasher", "lavavajillas", "lava-louças"],
|
|
121
|
+
"icons": ["SYSTEM_DISHWASHER"],
|
|
122
|
+
"name": "Dishwasher",
|
|
123
|
+
},
|
|
124
|
+
"washer": {
|
|
125
|
+
"search_id": 33,
|
|
126
|
+
"titles": [
|
|
127
|
+
"washer",
|
|
128
|
+
"free washer – in unit",
|
|
129
|
+
"free washer - in unit",
|
|
130
|
+
"lavadora",
|
|
131
|
+
"máquina de lavar",
|
|
132
|
+
"maquina de lavar",
|
|
133
|
+
],
|
|
134
|
+
"icons": ["SYSTEM_WASHER"],
|
|
135
|
+
"name": "Washer",
|
|
136
|
+
},
|
|
137
|
+
"dryer": {
|
|
138
|
+
"search_id": 34,
|
|
139
|
+
"titles": [
|
|
140
|
+
"dryer",
|
|
141
|
+
"free dryer – in unit",
|
|
142
|
+
"free dryer - in unit",
|
|
143
|
+
"secadora",
|
|
144
|
+
"secadora de ropa",
|
|
145
|
+
],
|
|
146
|
+
"icons": ["SYSTEM_DRYER"],
|
|
147
|
+
"name": "Dryer",
|
|
148
|
+
},
|
|
149
|
+
"dedicated_workspace": {
|
|
150
|
+
"search_id": 47,
|
|
151
|
+
"titles": [
|
|
152
|
+
"dedicated workspace",
|
|
153
|
+
"workspace",
|
|
154
|
+
"desk",
|
|
155
|
+
"zona de trabajo",
|
|
156
|
+
"espacio de trabajo",
|
|
157
|
+
"espacio de trabajo exclusivo",
|
|
158
|
+
"mesa de trabajo",
|
|
159
|
+
"mesa para laptop",
|
|
160
|
+
"escritorio",
|
|
161
|
+
],
|
|
162
|
+
"icons": ["SYSTEM_DESK", "SYSTEM_OFFICE", "SYSTEM_WORKSPACE"],
|
|
163
|
+
"name": "Dedicated Workspace",
|
|
164
|
+
},
|
|
165
|
+
"wifi": {
|
|
166
|
+
"search_id": 4,
|
|
167
|
+
"titles": ["wifi", "wi-fi", "wireless internet", "fast wifi", "internet"],
|
|
168
|
+
"icons": ["SYSTEM_WI_FI"],
|
|
169
|
+
"name": "Wi-Fi",
|
|
170
|
+
},
|
|
171
|
+
"heating": {
|
|
172
|
+
"search_id": 30,
|
|
173
|
+
"titles": ["heating", "calefaccion", "calefacción", "aquecedor"],
|
|
174
|
+
"icons": ["SYSTEM_THERMOMETER"],
|
|
175
|
+
"name": "Heating",
|
|
176
|
+
},
|
|
177
|
+
"pool": {
|
|
178
|
+
"search_id": 7,
|
|
179
|
+
"titles": ["pool", "piscina", "swimming pool"],
|
|
180
|
+
"icons": ["SYSTEM_POOL"],
|
|
181
|
+
"name": "Pool",
|
|
182
|
+
},
|
|
183
|
+
"gym": {
|
|
184
|
+
"search_id": 15,
|
|
185
|
+
"titles": ["gym", "fitness center", "gimnasio", "academia"],
|
|
186
|
+
"icons": ["SYSTEM_GYM"],
|
|
187
|
+
"name": "Gym",
|
|
188
|
+
},
|
|
189
|
+
"elevator": {
|
|
190
|
+
"search_id": 21,
|
|
191
|
+
"titles": ["elevator", "ascensor", "elevador"],
|
|
192
|
+
"icons": ["SYSTEM_ELEVATOR"],
|
|
193
|
+
"name": "Elevator",
|
|
194
|
+
},
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
DESCRIPTION_FALLBACK_PATTERNS = {
|
|
198
|
+
"stove": re.compile(
|
|
199
|
+
r"\b(estufa|cooktop|anafe|hornalla|hornallas|parrilla\s+de\s+gas|vitrocer[aá]mica|fog[aã]o|gas\s+stove|electric\s+stove|induction\s+stove)\b",
|
|
200
|
+
re.IGNORECASE,
|
|
201
|
+
),
|
|
202
|
+
"oven": re.compile(
|
|
203
|
+
r"(?<!microondas\s)(?<!microwave\s)\b(horno\s+(?:a\s+gas|el[eé]ctrico|convencional|para\s+hornear)|baking\s+oven|gas\s+oven|electric\s+oven)\b(?!\s*microondas)(?!\s*microwave)",
|
|
204
|
+
re.IGNORECASE,
|
|
205
|
+
),
|
|
206
|
+
"refrigerator": re.compile(
|
|
207
|
+
r"\b(refrigerador[a]?|refrigerator|fridge|heladera|nevera|geladeira|frigobar)\b",
|
|
208
|
+
re.IGNORECASE,
|
|
209
|
+
),
|
|
210
|
+
"dedicated_workspace": re.compile(
|
|
211
|
+
r"\b(escritorio|dedicated\s+desk|workspace|zona\s+de\s+trabajo|espacio\s+de\s+trabajo|mesa\s+de\s+trabajo|silla\s+(?:ergon[oó]mica|de\s+oficina)|office\s+chair)\b",
|
|
212
|
+
re.IGNORECASE,
|
|
213
|
+
),
|
|
214
|
+
"ac": re.compile(
|
|
215
|
+
r"(?<!sin\s)(?<!no\s)\b(aire\s+acondicionado|air\s+conditioning|a/c|minisplit|mini-split|climatizador|ar\s+condicionado)\b",
|
|
216
|
+
re.IGNORECASE,
|
|
217
|
+
),
|
|
218
|
+
"washer": re.compile(
|
|
219
|
+
r"(?<!sin\s)(?<!laundromat\s)\b(lavadora|washing\s+machine|washer)\b",
|
|
220
|
+
re.IGNORECASE,
|
|
221
|
+
),
|
|
222
|
+
"heating": re.compile(
|
|
223
|
+
r"(?<!sin\s)(?<!no\s)\b(calefacci[oó]n|calefactor|radiador|aquecedor|chimenea|estufa\s+a\s+le[nñ]a|heater|heating)\b",
|
|
224
|
+
re.IGNORECASE,
|
|
225
|
+
),
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def get_search_id(slug: str) -> Optional[int]:
|
|
230
|
+
"""Returns the Airbnb search filter ID for a canonical amenity slug."""
|
|
231
|
+
norm_slug = slug.strip().lower()
|
|
232
|
+
entry = AMENITY_REGISTRY.get(norm_slug)
|
|
233
|
+
if not entry:
|
|
234
|
+
return None
|
|
235
|
+
if "alias_of" in entry:
|
|
236
|
+
entry = AMENITY_REGISTRY.get(entry["alias_of"], {})
|
|
237
|
+
return entry.get("search_id")
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
def extract_available_amenities(
|
|
241
|
+
listing_details: Dict[str, Any],
|
|
242
|
+
) -> List[Dict[str, str]]:
|
|
243
|
+
"""
|
|
244
|
+
Extracts all available amenities from the listing's categorized amenity blocks.
|
|
245
|
+
Filters out items where 'available' is explicitly False.
|
|
246
|
+
"""
|
|
247
|
+
available = []
|
|
248
|
+
categories = listing_details.get("amenities") or []
|
|
249
|
+
for category in categories:
|
|
250
|
+
if not isinstance(category, dict):
|
|
251
|
+
continue
|
|
252
|
+
values = category.get("values") or []
|
|
253
|
+
for item in values:
|
|
254
|
+
if not isinstance(item, dict):
|
|
255
|
+
continue
|
|
256
|
+
if item.get("available") is False:
|
|
257
|
+
continue
|
|
258
|
+
title = (item.get("title") or item.get("name") or "").strip().lower()
|
|
259
|
+
icon = (item.get("icon") or "").strip()
|
|
260
|
+
if title or icon:
|
|
261
|
+
available.append({"title": title, "icon": icon})
|
|
262
|
+
return available
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
def has_amenity(
|
|
266
|
+
listing_details: Dict[str, Any], slug_or_title: str, check_description: bool = True
|
|
267
|
+
) -> bool:
|
|
268
|
+
"""
|
|
269
|
+
Checks whether the listing provides an amenity matching the given slug or title.
|
|
270
|
+
Multi-layer:
|
|
271
|
+
1. Structured amenity checkboxes & system icons (with false-positive exclusion for microwaves).
|
|
272
|
+
2. Description text regex inspection fallback.
|
|
273
|
+
"""
|
|
274
|
+
if not slug_or_title:
|
|
275
|
+
return False
|
|
276
|
+
|
|
277
|
+
available = extract_available_amenities(listing_details)
|
|
278
|
+
norm_query = slug_or_title.strip().lower()
|
|
279
|
+
entry = AMENITY_REGISTRY.get(norm_query)
|
|
280
|
+
if entry and "alias_of" in entry:
|
|
281
|
+
entry = AMENITY_REGISTRY.get(entry["alias_of"])
|
|
282
|
+
|
|
283
|
+
if entry:
|
|
284
|
+
target_titles = [t.lower() for t in entry.get("titles", [])]
|
|
285
|
+
target_icons = set(entry.get("icons", []))
|
|
286
|
+
exclude_substrings = entry.get("exclude_substrings", [])
|
|
287
|
+
|
|
288
|
+
for item in available:
|
|
289
|
+
item_title = item["title"]
|
|
290
|
+
item_icon = item["icon"]
|
|
291
|
+
|
|
292
|
+
# Check exclusions (e.g. microwave oven must not match oven)
|
|
293
|
+
if exclude_substrings and any(
|
|
294
|
+
exc in item_title for exc in exclude_substrings
|
|
295
|
+
):
|
|
296
|
+
continue
|
|
297
|
+
|
|
298
|
+
if item_icon and item_icon in target_icons:
|
|
299
|
+
return True
|
|
300
|
+
|
|
301
|
+
for target in target_titles:
|
|
302
|
+
if len(target) <= 3:
|
|
303
|
+
if re.search(rf"\b{re.escape(target)}\b", item_title):
|
|
304
|
+
return True
|
|
305
|
+
elif target in item_title:
|
|
306
|
+
return True
|
|
307
|
+
|
|
308
|
+
# Fallback check on normalized query within structured amenities
|
|
309
|
+
clean_query = norm_query.replace("_", " ")
|
|
310
|
+
for item in available:
|
|
311
|
+
item_title = item["title"]
|
|
312
|
+
# Exclude microwave false positive if querying oven
|
|
313
|
+
if norm_query in ("oven", "horno") and any(
|
|
314
|
+
x in item_title for x in ("microondas", "microwave")
|
|
315
|
+
):
|
|
316
|
+
continue
|
|
317
|
+
if len(clean_query) <= 3:
|
|
318
|
+
if re.search(rf"\b{re.escape(clean_query)}\b", item_title):
|
|
319
|
+
return True
|
|
320
|
+
elif clean_query in item_title or norm_query in item_title:
|
|
321
|
+
return True
|
|
322
|
+
|
|
323
|
+
# Layer 2: Host description text regex fallback
|
|
324
|
+
if check_description:
|
|
325
|
+
desc_text = f"{listing_details.get('description', '')} {listing_details.get('title', '')}".lower()
|
|
326
|
+
pat = DESCRIPTION_FALLBACK_PATTERNS.get(norm_query)
|
|
327
|
+
if pat and pat.search(desc_text):
|
|
328
|
+
logger.debug(
|
|
329
|
+
f" Amenity '{norm_query}' detected via host description regex."
|
|
330
|
+
)
|
|
331
|
+
return True
|
|
332
|
+
|
|
333
|
+
return False
|
|
334
|
+
|
|
335
|
+
|
|
336
|
+
def evaluate_kitchen(
|
|
337
|
+
listing_details: Dict[str, Any], review_evidence: Optional[Dict[str, Any]] = None
|
|
338
|
+
) -> Dict[str, Any]:
|
|
339
|
+
"""
|
|
340
|
+
Multi-layer kitchen quality evaluation:
|
|
341
|
+
Layer 1: Structured amenities (Stove, Oven, Refrigerator, Cooking basics, Dishwasher).
|
|
342
|
+
Layer 2: Host description regex (mentions of cooktop, conventional oven, fridge).
|
|
343
|
+
Layer 3: Guest review sentiment verification (cooking praise vs complaints).
|
|
344
|
+
"""
|
|
345
|
+
has_kit = has_amenity(listing_details, "kitchen")
|
|
346
|
+
has_stove = has_amenity(listing_details, "stove")
|
|
347
|
+
has_oven = has_amenity(listing_details, "oven")
|
|
348
|
+
has_fridge = has_amenity(listing_details, "refrigerator")
|
|
349
|
+
has_basics = has_amenity(listing_details, "cooking_basics")
|
|
350
|
+
has_dw = has_amenity(listing_details, "dishwasher")
|
|
351
|
+
|
|
352
|
+
equipment = {
|
|
353
|
+
"kitchen": has_kit,
|
|
354
|
+
"stove": has_stove,
|
|
355
|
+
"oven": has_oven,
|
|
356
|
+
"refrigerator": has_fridge,
|
|
357
|
+
"cooking_basics": has_basics,
|
|
358
|
+
"dishwasher": has_dw,
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
evidence = review_evidence or {}
|
|
362
|
+
kitchen_neg = evidence.get("kitchen_negative") or []
|
|
363
|
+
kitchen_pos = evidence.get("kitchen_positive") or []
|
|
364
|
+
flags: List[str] = []
|
|
365
|
+
|
|
366
|
+
# Review evidence overrides
|
|
367
|
+
review_complains_no_oven = any(
|
|
368
|
+
"sin horno" in com.lower() or "no oven" in com.lower() for com in kitchen_neg
|
|
369
|
+
)
|
|
370
|
+
review_complains_bare_kitchenette = any(
|
|
371
|
+
"cocina básica" in com.lower()
|
|
372
|
+
or "cocina basica" in com.lower()
|
|
373
|
+
or "little equipment" in com.lower()
|
|
374
|
+
or "solo microondas" in com.lower()
|
|
375
|
+
for com in kitchen_neg
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
# Full kitchen strictly requires refrigerator + (stove or oven)
|
|
379
|
+
if (
|
|
380
|
+
has_kit
|
|
381
|
+
and (has_stove or has_oven)
|
|
382
|
+
and has_fridge
|
|
383
|
+
and not review_complains_bare_kitchenette
|
|
384
|
+
):
|
|
385
|
+
tier = "full_kitchen"
|
|
386
|
+
if not has_oven or review_complains_no_oven:
|
|
387
|
+
flags.append("[FLAG: No Oven]")
|
|
388
|
+
elif has_kit and (has_stove or has_fridge):
|
|
389
|
+
tier = "standard_kitchen"
|
|
390
|
+
if not has_oven or review_complains_no_oven:
|
|
391
|
+
flags.append("[FLAG: No Oven]")
|
|
392
|
+
if not has_stove:
|
|
393
|
+
flags.append("[FLAG: No Stove]")
|
|
394
|
+
if not has_fridge:
|
|
395
|
+
flags.append("[FLAG: No Refrigerator]")
|
|
396
|
+
elif has_kit:
|
|
397
|
+
tier = "kitchenette"
|
|
398
|
+
flags.append("[FLAG: Kitchenette Only / No Stove or Oven]")
|
|
399
|
+
else:
|
|
400
|
+
tier = "no_kitchen"
|
|
401
|
+
flags.append("[FLAG: No Kitchen]")
|
|
402
|
+
|
|
403
|
+
if kitchen_neg:
|
|
404
|
+
flags.append("[FLAG: Kitchen Complaints in Reviews]")
|
|
405
|
+
elif kitchen_pos and tier == "full_kitchen":
|
|
406
|
+
flags.append("[SIGNAL: Verified Cooking Kitchen]")
|
|
407
|
+
|
|
408
|
+
return {
|
|
409
|
+
"tier": tier,
|
|
410
|
+
"equipment": equipment,
|
|
411
|
+
"flags": flags,
|
|
412
|
+
}
|
bnbingo/auth.py
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import shutil
|
|
2
|
+
import sqlite3
|
|
3
|
+
import subprocess
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def get_brave_cookies():
|
|
8
|
+
"""
|
|
9
|
+
Automatically extracts and decrypts Airbnb session cookies from Brave Browser on macOS.
|
|
10
|
+
Returns a dictionary of cookie name -> value.
|
|
11
|
+
"""
|
|
12
|
+
try:
|
|
13
|
+
cmd = ["security", "find-generic-password", "-w", "-s", "Brave Safe Storage"]
|
|
14
|
+
res = subprocess.run(cmd, capture_output=True, text=True, check=True)
|
|
15
|
+
password = res.stdout.strip().encode("utf-8")
|
|
16
|
+
|
|
17
|
+
from cryptography.hazmat.primitives import hashes
|
|
18
|
+
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
|
19
|
+
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
|
|
20
|
+
|
|
21
|
+
kdf = PBKDF2HMAC(
|
|
22
|
+
algorithm=hashes.SHA1(),
|
|
23
|
+
length=16,
|
|
24
|
+
salt=b"saltysalt",
|
|
25
|
+
iterations=1003,
|
|
26
|
+
)
|
|
27
|
+
key = kdf.derive(password)
|
|
28
|
+
|
|
29
|
+
cookie_db = (
|
|
30
|
+
Path.home()
|
|
31
|
+
/ "Library/Application Support/BraveSoftware/Brave-Browser/Default/Cookies"
|
|
32
|
+
)
|
|
33
|
+
if not cookie_db.exists():
|
|
34
|
+
return {}
|
|
35
|
+
|
|
36
|
+
tmp_path = Path("/tmp/brave_airbnb_cookies.db")
|
|
37
|
+
shutil.copy2(cookie_db, tmp_path)
|
|
38
|
+
conn = sqlite3.connect(tmp_path)
|
|
39
|
+
c = conn.cursor()
|
|
40
|
+
c.execute(
|
|
41
|
+
"SELECT host_key, name, encrypted_value FROM cookies WHERE host_key LIKE '%airbnb%'"
|
|
42
|
+
)
|
|
43
|
+
rows = c.fetchall()
|
|
44
|
+
conn.close()
|
|
45
|
+
tmp_path.unlink(missing_ok=True)
|
|
46
|
+
|
|
47
|
+
cookies = {}
|
|
48
|
+
for host, name, enc_val in rows:
|
|
49
|
+
if enc_val and enc_val[:3] == b"v10":
|
|
50
|
+
enc_data = enc_val[3:]
|
|
51
|
+
iv = b" " * 16
|
|
52
|
+
cipher = Cipher(algorithms.AES(key), modes.CBC(iv))
|
|
53
|
+
dec = cipher.decryptor().update(enc_data)
|
|
54
|
+
pad = dec[-1]
|
|
55
|
+
raw_val = dec[32:-pad] if pad <= 16 else dec[32:]
|
|
56
|
+
val = raw_val.decode("utf-8", errors="ignore")
|
|
57
|
+
if val:
|
|
58
|
+
cookies[name] = val
|
|
59
|
+
return cookies
|
|
60
|
+
except Exception:
|
|
61
|
+
return {}
|
bnbingo/benchmarks.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"metrics": {
|
|
3
|
+
"amenities": {
|
|
4
|
+
"weight": 0.35,
|
|
5
|
+
"function": "percentage_match",
|
|
6
|
+
"params": {
|
|
7
|
+
"bonus_amenities": [
|
|
8
|
+
"balcony",
|
|
9
|
+
"projector",
|
|
10
|
+
"hammock",
|
|
11
|
+
"dishwasher"
|
|
12
|
+
]
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"value": {
|
|
16
|
+
"weight": 0.25,
|
|
17
|
+
"function": "market_relative",
|
|
18
|
+
"params": {
|
|
19
|
+
"target_ratio": 0.75,
|
|
20
|
+
"base_ratio": 1.0
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"sentiment": {
|
|
24
|
+
"weight": 0.4,
|
|
25
|
+
"function": "keyword_analysis",
|
|
26
|
+
"params": {
|
|
27
|
+
"positive_keywords": [
|
|
28
|
+
"bright",
|
|
29
|
+
"spacious",
|
|
30
|
+
"cozy",
|
|
31
|
+
"luminoso",
|
|
32
|
+
"tranquilo"
|
|
33
|
+
],
|
|
34
|
+
"negative_keywords": [
|
|
35
|
+
"damp",
|
|
36
|
+
"smelly",
|
|
37
|
+
"thin walls",
|
|
38
|
+
"húmedo",
|
|
39
|
+
"ruidoso"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"penalties": [
|
|
45
|
+
{
|
|
46
|
+
"id": "tiny_bedroom",
|
|
47
|
+
"name": "Tiny Bedroom",
|
|
48
|
+
"type": "missing_amenity",
|
|
49
|
+
"amenity": "dedicated_workspace",
|
|
50
|
+
"multiplier": 0.8,
|
|
51
|
+
"flag": "[FLAG: No Workspace]"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
"name": "Low Review Count",
|
|
55
|
+
"condition": {
|
|
56
|
+
"field": "review_count",
|
|
57
|
+
"operator": "<",
|
|
58
|
+
"value": 7
|
|
59
|
+
},
|
|
60
|
+
"multiplier": 0.6
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"hard_filters": {
|
|
64
|
+
"must_have_amenities": [
|
|
65
|
+
"wifi",
|
|
66
|
+
"kitchen"
|
|
67
|
+
]
|
|
68
|
+
},
|
|
69
|
+
"scoring_thresholds": {
|
|
70
|
+
"excellent": 85,
|
|
71
|
+
"good": 65,
|
|
72
|
+
"pass": 45
|
|
73
|
+
}
|
|
74
|
+
}
|