Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -57,15 +57,21 @@ def search_anime(keyword: str):
|
|
| 57 |
title_elem = item.select_one(".film-name a")
|
| 58 |
thumb_elem = item.select_one("img")
|
| 59 |
thumbnail = None
|
|
|
|
| 60 |
if thumb_elem:
|
| 61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 62 |
results.append({
|
| 63 |
"title": title_elem.text.strip() if title_elem else None,
|
| 64 |
"url": title_elem["href"] if title_elem else None,
|
| 65 |
"thumbnail": thumbnail
|
| 66 |
})
|
| 67 |
|
| 68 |
-
#
|
| 69 |
results = [r for r in results if r["title"] and r["url"]]
|
| 70 |
except Exception as e:
|
| 71 |
raise HTTPException(status_code=500, detail=f"Failed to search anime: {str(e)}")
|
|
|
|
| 57 |
title_elem = item.select_one(".film-name a")
|
| 58 |
thumb_elem = item.select_one("img")
|
| 59 |
thumbnail = None
|
| 60 |
+
|
| 61 |
if thumb_elem:
|
| 62 |
+
# Try multiple attributes for lazy-loaded images
|
| 63 |
+
for attr in ["src", "data-src", "data-lazy-src", "data-original"]:
|
| 64 |
+
thumbnail = thumb_elem.get(attr)
|
| 65 |
+
if thumbnail:
|
| 66 |
+
break
|
| 67 |
+
|
| 68 |
results.append({
|
| 69 |
"title": title_elem.text.strip() if title_elem else None,
|
| 70 |
"url": title_elem["href"] if title_elem else None,
|
| 71 |
"thumbnail": thumbnail
|
| 72 |
})
|
| 73 |
|
| 74 |
+
# Filter out incomplete results
|
| 75 |
results = [r for r in results if r["title"] and r["url"]]
|
| 76 |
except Exception as e:
|
| 77 |
raise HTTPException(status_code=500, detail=f"Failed to search anime: {str(e)}")
|