Pull title, description and tags from an F95zone thread
Admin/uploader pastes a thread link and presses "Подтянуть" on the new game and edit forms; the backend reads the public first post (no login). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
ac164d1782
commit
ae8e175376
5 files changed
+227
No files matched your search
@@ -0,0 +1,29 @@
|
||||
from fastapi import APIRouter, HTTPException, status
|
||||
from pydantic import BaseModel
|
||||
from starlette.concurrency import run_in_threadpool
|
||||
|
||||
from app import f95
|
||||
from app.deps import CurrentUser, has_perm
|
||||
|
||||
router = APIRouter(prefix="/api/metadata", tags=["metadata"])
|
||||
|
||||
|
||||
class F95In(BaseModel):
|
||||
url: str
|
||||
|
||||
|
||||
class MetaOut(BaseModel):
|
||||
url: str
|
||||
title: str
|
||||
description: str
|
||||
tags: list[str]
|
||||
|
||||
|
||||
@router.post("/f95", response_model=MetaOut)
|
||||
async def from_f95(body: F95In, user: CurrentUser) -> dict:
|
||||
if not (has_perm(user, "games.upload") or has_perm(user, "games.edit")):
|
||||
raise HTTPException(status.HTTP_403_FORBIDDEN, "Нет прав")
|
||||
try:
|
||||
return await run_in_threadpool(f95.load, body.url)
|
||||
except f95.F95Error as e:
|
||||
raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(e))
|
||||
Reference in new issue
Block a user