Neon-AI commited on
Commit
fbd240a
·
verified ·
1 Parent(s): 159d216

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
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
- thumbnail = thumb_elem.get("src") or thumb_elem.get("data-src") or thumb_elem.get("data-lazy-src")
 
 
 
 
 
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
- # Optionally filter out incomplete results
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)}")