This commit is contained in:
jxxghp
2023-06-17 17:34:18 +08:00
parent f85e960fa9
commit acdec220f7
42 changed files with 423 additions and 253 deletions

View File

@ -0,0 +1,24 @@
from typing import List, Any
from fastapi import APIRouter, Depends
from app import schemas
from app.chain.search import SearchChain
from app.db.models.user import User
from app.db.userauth import get_current_active_user
from app.schemas.types import MediaType
router = APIRouter()
@router.get("/tmdbid", response_model=List[schemas.Context])
async def search_by_tmdbid(tmdbid: int,
mtype: str = None,
_: User = Depends(get_current_active_user)) -> Any:
"""
根据TMDBID搜索资源
"""
if mtype:
mtype = MediaType.TV if mtype == MediaType.TV.value else MediaType.MOVIE
torrents = SearchChain().search_by_tmdbid(tmdbid=tmdbid, mtype=mtype)
return [torrent.to_dict() for torrent in torrents]