feat: add ability to display info even if title in komga, fix requests, fix not all results showing up, fixes #11 fixes #10 fixes #8

This commit is contained in:
2025-05-05 12:03:53 +02:00
parent 8081d419cc
commit 65b929a1ca
3 changed files with 55 additions and 17 deletions

View File

@@ -70,7 +70,6 @@ async def fetch_data(data: Dict[str, Any]) -> List[Dict[str, Any]]:
in_komga = komga.getSeries(
manga.title.english if manga.title.english else manga.title.romaji
)
print(in_komga, manga.title.english)
results.append(
{
"id": manga.id,
@@ -81,7 +80,7 @@ async def fetch_data(data: Dict[str, Any]) -> List[Dict[str, Any]]:
if manga.coverImage
else "https://demofree.sirv.com/nope-not-here.jpg",
"status": manga.status,
"type": manga.type,
"type": manga.format,
"genres": manga.genres or [],
"tags": [tag.name for tag in (manga.tags or [])],
"description": manga.description.replace("<br>", "\n")
@@ -106,7 +105,7 @@ async def get_genres():
async with httpx.AsyncClient() as client:
try:
response = await client.post(
f"https://graphql.anilist.co",
"https://graphql.anilist.co",
json={"query": GENRES_QUERY},
)
response.raise_for_status()
@@ -124,7 +123,7 @@ async def get_tags():
async with httpx.AsyncClient() as client:
try:
response = await client.post(
f"https://graphql.anilist.co",
"https://graphql.anilist.co",
json={"query": TAGS_QUERY},
)
response.raise_for_status()
@@ -139,7 +138,6 @@ async def get_tags():
@app.route("/search", methods=["POST"])
async def search():
data = await request.get_json()
print(data)
results = await fetch_data(data)
if not results:
return jsonify({"error": "No results found"}), 404
@@ -154,13 +152,12 @@ async def index():
@app.route("/request", methods=["POST"])
async def log_request():
data = await request.get_json()
item = data.get("title")
item = data.get("item")
if item:
asynccache = KomCache()
manga_title = data.get("title")
asynccache.insert(
"INSERT INTO manga_requests (manga_id, manga_title) VALUES (?, ?)",
(item, manga_title),
"INSERT INTO manga_requests (manga_id) VALUES (?)",
(item,),
)
return jsonify({"status": "success"})
return jsonify({"status": "failed"}), 400