Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -51,13 +51,24 @@ def search_terms_of_service(company_name: str) -> Dict:
|
|
| 51 |
if not data.get('secondary_links') or len(data['secondary_links']) == 0:
|
| 52 |
return {"error": f"No Terms of Service links found for {company_name}"}
|
| 53 |
|
| 54 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
result = {
|
| 56 |
"company_name": data["name"],
|
| 57 |
-
"tos_link":
|
| 58 |
"all_links": data["secondary_links"] # več linkov
|
| 59 |
}
|
| 60 |
-
|
| 61 |
return result
|
| 62 |
|
| 63 |
except requests.exceptions.RequestException as e:
|
|
|
|
| 51 |
if not data.get('secondary_links') or len(data['secondary_links']) == 0:
|
| 52 |
return {"error": f"No Terms of Service links found for {company_name}"}
|
| 53 |
|
| 54 |
+
# Find link that contains "terms" (case insensitive)
|
| 55 |
+
tos_link = None
|
| 56 |
+
for link in data['secondary_links']:
|
| 57 |
+
if 'terms' in link.lower():
|
| 58 |
+
tos_link = link
|
| 59 |
+
break
|
| 60 |
+
|
| 61 |
+
# If no link with "terms" found, fall back to first link
|
| 62 |
+
if not tos_link:
|
| 63 |
+
tos_link = data["secondary_links"][0]
|
| 64 |
+
print(f"Warning: No link containing 'terms' found, using first link: {tos_link}")
|
| 65 |
+
|
| 66 |
+
# returnamo ime in link, lahko jih več
|
| 67 |
result = {
|
| 68 |
"company_name": data["name"],
|
| 69 |
+
"tos_link": tos_link,
|
| 70 |
"all_links": data["secondary_links"] # več linkov
|
| 71 |
}
|
|
|
|
| 72 |
return result
|
| 73 |
|
| 74 |
except requests.exceptions.RequestException as e:
|