Add bulk remove all 10/10 ratings
All checks were successful
Docker / docker (push) Successful in 1m43s
All checks were successful
Docker / docker (push) Successful in 1m43s
Bouton dans le header (visible uniquement en filtre 10/10) qui supprime toutes les notes 10/10 en une fois via l'API Trakt bulk. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
29
main.py
29
main.py
@@ -199,4 +199,33 @@ async def remove_rating(request: Request, trakt_id: int):
|
||||
return {"success": True}
|
||||
|
||||
|
||||
@app.delete("/api/rates/all10")
|
||||
async def remove_all_10(request: Request):
|
||||
token = request.session.get("access_token")
|
||||
if not token:
|
||||
raise HTTPException(401, "Not authenticated")
|
||||
|
||||
trakt = TraktClient(TRAKT_CLIENT_ID, token)
|
||||
_, ratings = await trakt.get_watched_and_ratings()
|
||||
ids = [{"ids": r["movie"]["ids"]} for r in ratings if r["rating"] == 10]
|
||||
|
||||
if not ids:
|
||||
return {"deleted": 0}
|
||||
|
||||
import asyncio, httpx
|
||||
async with httpx.AsyncClient(timeout=60) as client:
|
||||
tasks = [
|
||||
client.post(
|
||||
f"{TraktClient.BASE_URL}/sync/ratings/remove",
|
||||
headers=trakt.headers,
|
||||
json={"movies": ids[i:i + 100]},
|
||||
)
|
||||
for i in range(0, len(ids), 100)
|
||||
]
|
||||
responses = await asyncio.gather(*tasks)
|
||||
|
||||
cache_del(f"movies_{token[:16]}")
|
||||
return {"deleted": len(ids)}
|
||||
|
||||
|
||||
app.mount("/static", StaticFiles(directory="static"), name="static")
|
||||
|
||||
Reference in New Issue
Block a user