Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -72,8 +72,7 @@ def search_anime(keyword: str):
|
|
| 72 |
@app.get("/metadata")
|
| 73 |
def get_metadata(path: str):
|
| 74 |
"""
|
| 75 |
-
Fetch full anime metadata from AniWave.
|
| 76 |
-
Example: /metadata?path=/anime-watch/naruto
|
| 77 |
"""
|
| 78 |
try:
|
| 79 |
full_url = f"https://www.aniwave.se{path}"
|
|
@@ -104,31 +103,47 @@ def get_metadata(path: str):
|
|
| 104 |
desc_elem = soup.select_one(".synopsis .content")
|
| 105 |
description = desc_elem.text.strip() if desc_elem else None
|
| 106 |
|
| 107 |
-
#
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
|
| 133 |
return {
|
| 134 |
"title": title,
|
|
@@ -137,7 +152,7 @@ def get_metadata(path: str):
|
|
| 137 |
"has_sub": has_sub,
|
| 138 |
"has_dub": has_dub,
|
| 139 |
"description": description,
|
| 140 |
-
"type":
|
| 141 |
"source": source,
|
| 142 |
"premiered": premiered,
|
| 143 |
"date_aired": date_aired,
|
|
|
|
| 72 |
@app.get("/metadata")
|
| 73 |
def get_metadata(path: str):
|
| 74 |
"""
|
| 75 |
+
Fetch full anime metadata from AniWave with proper fields.
|
|
|
|
| 76 |
"""
|
| 77 |
try:
|
| 78 |
full_url = f"https://www.aniwave.se{path}"
|
|
|
|
| 103 |
desc_elem = soup.select_one(".synopsis .content")
|
| 104 |
description = desc_elem.text.strip() if desc_elem else None
|
| 105 |
|
| 106 |
+
# bmeta fields
|
| 107 |
+
bmeta_divs = soup.select(".bmeta .meta")
|
| 108 |
+
type_ = source = premiered = date_aired = broadcast = status = mal_rating = duration = total_episodes = None
|
| 109 |
+
genres = []
|
| 110 |
+
studios = []
|
| 111 |
+
producers = []
|
| 112 |
+
|
| 113 |
+
if bmeta_divs:
|
| 114 |
+
for div in bmeta_divs:
|
| 115 |
+
for item in div.find_all("div", recursive=False):
|
| 116 |
+
text = item.get_text(separator="|", strip=True)
|
| 117 |
+
if text.startswith("Type:"):
|
| 118 |
+
type_elem = item.find("a")
|
| 119 |
+
type_ = type_elem.text.strip() if type_elem else None
|
| 120 |
+
elif text.startswith("Source:"):
|
| 121 |
+
source_elem = item.find("span")
|
| 122 |
+
source = source_elem.text.strip() if source_elem else None
|
| 123 |
+
elif text.startswith("Premiered:"):
|
| 124 |
+
premiered_elem = item.find("a")
|
| 125 |
+
premiered = premiered_elem.text.strip() if premiered_elem else None
|
| 126 |
+
elif text.startswith("Date aired:"):
|
| 127 |
+
date_elem = item.find("span")
|
| 128 |
+
date_aired = date_elem.text.strip() if date_elem else None
|
| 129 |
+
elif text.startswith("Broadcast:"):
|
| 130 |
+
broadcast = item.text.replace("Broadcast:", "").strip()
|
| 131 |
+
elif text.startswith("Status:"):
|
| 132 |
+
status_elem = item.find("a")
|
| 133 |
+
status = status_elem.text.strip() if status_elem else None
|
| 134 |
+
elif text.startswith("Genres:"):
|
| 135 |
+
genres = [g.text.strip() for g in item.find_all("a")]
|
| 136 |
+
elif text.startswith("MAL:"):
|
| 137 |
+
mal_rating = item.find(text=True, recursive=False).strip()
|
| 138 |
+
elif text.startswith("Duration:"):
|
| 139 |
+
duration = item.text.replace("Duration:", "").strip()
|
| 140 |
+
elif text.startswith("Episodes:"):
|
| 141 |
+
ep_elem = item.find("span")
|
| 142 |
+
total_episodes = ep_elem.text.strip() if ep_elem else None
|
| 143 |
+
elif text.startswith("Studios:"):
|
| 144 |
+
studios = [s.text.strip() for s in item.find_all("span")]
|
| 145 |
+
elif text.startswith("Producers:"):
|
| 146 |
+
producers = [p.text.strip() for p in item.find_all("span")]
|
| 147 |
|
| 148 |
return {
|
| 149 |
"title": title,
|
|
|
|
| 152 |
"has_sub": has_sub,
|
| 153 |
"has_dub": has_dub,
|
| 154 |
"description": description,
|
| 155 |
+
"type": type_,
|
| 156 |
"source": source,
|
| 157 |
"premiered": premiered,
|
| 158 |
"date_aired": date_aired,
|