mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-09 01:16:50 +08:00
discover更新为异步实现
This commit is contained in:
@@ -3,13 +3,13 @@ from typing import Any, List, Optional
|
|||||||
from fastapi import APIRouter, Depends
|
from fastapi import APIRouter, Depends
|
||||||
|
|
||||||
from app import schemas
|
from app import schemas
|
||||||
|
from app.chain.bangumi import BangumiChain
|
||||||
|
from app.chain.douban import DoubanChain
|
||||||
|
from app.chain.tmdb import TmdbChain
|
||||||
from app.core.event import eventmanager
|
from app.core.event import eventmanager
|
||||||
from app.core.security import verify_token
|
from app.core.security import verify_token
|
||||||
from app.schemas import DiscoverSourceEventData
|
from app.schemas import DiscoverSourceEventData
|
||||||
from app.schemas.types import ChainEventType, MediaType
|
from app.schemas.types import ChainEventType, MediaType
|
||||||
from app.chain.bangumi import BangumiChain
|
|
||||||
from app.chain.douban import DoubanChain
|
|
||||||
from app.chain.tmdb import TmdbChain
|
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@@ -31,100 +31,100 @@ def source(_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
|||||||
|
|
||||||
|
|
||||||
@router.get("/bangumi", summary="探索Bangumi", response_model=List[schemas.MediaInfo])
|
@router.get("/bangumi", summary="探索Bangumi", response_model=List[schemas.MediaInfo])
|
||||||
def bangumi(type: Optional[int] = 2,
|
async def bangumi(type: Optional[int] = 2,
|
||||||
cat: Optional[int] = None,
|
cat: Optional[int] = None,
|
||||||
sort: Optional[str] = 'rank',
|
sort: Optional[str] = 'rank',
|
||||||
year: Optional[str] = None,
|
year: Optional[str] = None,
|
||||||
page: Optional[int] = 1,
|
page: Optional[int] = 1,
|
||||||
count: Optional[int] = 30,
|
count: Optional[int] = 30,
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
"""
|
"""
|
||||||
探索Bangumi
|
探索Bangumi
|
||||||
"""
|
"""
|
||||||
medias = BangumiChain().discover(type=type, cat=cat, sort=sort, year=year,
|
medias = await BangumiChain().async_discover(type=type, cat=cat, sort=sort, year=year,
|
||||||
limit=count, offset=(page - 1) * count)
|
limit=count, offset=(page - 1) * count)
|
||||||
if medias:
|
if medias:
|
||||||
return [media.to_dict() for media in medias]
|
return [media.to_dict() for media in medias]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
@router.get("/douban_movies", summary="探索豆瓣电影", response_model=List[schemas.MediaInfo])
|
@router.get("/douban_movies", summary="探索豆瓣电影", response_model=List[schemas.MediaInfo])
|
||||||
def douban_movies(sort: Optional[str] = "R",
|
async def douban_movies(sort: Optional[str] = "R",
|
||||||
tags: Optional[str] = "",
|
tags: Optional[str] = "",
|
||||||
page: Optional[int] = 1,
|
page: Optional[int] = 1,
|
||||||
count: Optional[int] = 30,
|
count: Optional[int] = 30,
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
"""
|
"""
|
||||||
浏览豆瓣电影信息
|
浏览豆瓣电影信息
|
||||||
"""
|
"""
|
||||||
movies = DoubanChain().douban_discover(mtype=MediaType.MOVIE,
|
movies = await DoubanChain().async_douban_discover(mtype=MediaType.MOVIE,
|
||||||
sort=sort, tags=tags, page=page, count=count)
|
sort=sort, tags=tags, page=page, count=count)
|
||||||
return [media.to_dict() for media in movies] if movies else []
|
return [media.to_dict() for media in movies] if movies else []
|
||||||
|
|
||||||
|
|
||||||
@router.get("/douban_tvs", summary="探索豆瓣剧集", response_model=List[schemas.MediaInfo])
|
@router.get("/douban_tvs", summary="探索豆瓣剧集", response_model=List[schemas.MediaInfo])
|
||||||
def douban_tvs(sort: Optional[str] = "R",
|
async def douban_tvs(sort: Optional[str] = "R",
|
||||||
tags: Optional[str] = "",
|
tags: Optional[str] = "",
|
||||||
page: Optional[int] = 1,
|
page: Optional[int] = 1,
|
||||||
count: Optional[int] = 30,
|
count: Optional[int] = 30,
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
"""
|
"""
|
||||||
浏览豆瓣剧集信息
|
浏览豆瓣剧集信息
|
||||||
"""
|
"""
|
||||||
tvs = DoubanChain().douban_discover(mtype=MediaType.TV,
|
tvs = await DoubanChain().async_douban_discover(mtype=MediaType.TV,
|
||||||
sort=sort, tags=tags, page=page, count=count)
|
sort=sort, tags=tags, page=page, count=count)
|
||||||
return [media.to_dict() for media in tvs] if tvs else []
|
return [media.to_dict() for media in tvs] if tvs else []
|
||||||
|
|
||||||
|
|
||||||
@router.get("/tmdb_movies", summary="探索TMDB电影", response_model=List[schemas.MediaInfo])
|
@router.get("/tmdb_movies", summary="探索TMDB电影", response_model=List[schemas.MediaInfo])
|
||||||
def tmdb_movies(sort_by: Optional[str] = "popularity.desc",
|
async def tmdb_movies(sort_by: Optional[str] = "popularity.desc",
|
||||||
with_genres: Optional[str] = "",
|
with_genres: Optional[str] = "",
|
||||||
with_original_language: Optional[str] = "",
|
with_original_language: Optional[str] = "",
|
||||||
with_keywords: Optional[str] = "",
|
with_keywords: Optional[str] = "",
|
||||||
with_watch_providers: Optional[str] = "",
|
with_watch_providers: Optional[str] = "",
|
||||||
vote_average: Optional[float] = 0.0,
|
vote_average: Optional[float] = 0.0,
|
||||||
vote_count: Optional[int] = 0,
|
vote_count: Optional[int] = 0,
|
||||||
release_date: Optional[str] = "",
|
release_date: Optional[str] = "",
|
||||||
page: Optional[int] = 1,
|
page: Optional[int] = 1,
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
"""
|
"""
|
||||||
浏览TMDB电影信息
|
浏览TMDB电影信息
|
||||||
"""
|
"""
|
||||||
movies = TmdbChain().tmdb_discover(mtype=MediaType.MOVIE,
|
movies = await TmdbChain().async_tmdb_discover(mtype=MediaType.MOVIE,
|
||||||
sort_by=sort_by,
|
sort_by=sort_by,
|
||||||
with_genres=with_genres,
|
with_genres=with_genres,
|
||||||
with_original_language=with_original_language,
|
with_original_language=with_original_language,
|
||||||
with_keywords=with_keywords,
|
with_keywords=with_keywords,
|
||||||
with_watch_providers=with_watch_providers,
|
with_watch_providers=with_watch_providers,
|
||||||
vote_average=vote_average,
|
vote_average=vote_average,
|
||||||
vote_count=vote_count,
|
vote_count=vote_count,
|
||||||
release_date=release_date,
|
release_date=release_date,
|
||||||
page=page)
|
page=page)
|
||||||
return [movie.to_dict() for movie in movies] if movies else []
|
return [movie.to_dict() for movie in movies] if movies else []
|
||||||
|
|
||||||
|
|
||||||
@router.get("/tmdb_tvs", summary="探索TMDB剧集", response_model=List[schemas.MediaInfo])
|
@router.get("/tmdb_tvs", summary="探索TMDB剧集", response_model=List[schemas.MediaInfo])
|
||||||
def tmdb_tvs(sort_by: Optional[str] = "popularity.desc",
|
async def tmdb_tvs(sort_by: Optional[str] = "popularity.desc",
|
||||||
with_genres: Optional[str] = "",
|
with_genres: Optional[str] = "",
|
||||||
with_original_language: Optional[str] = "",
|
with_original_language: Optional[str] = "",
|
||||||
with_keywords: Optional[str] = "",
|
with_keywords: Optional[str] = "",
|
||||||
with_watch_providers: Optional[str] = "",
|
with_watch_providers: Optional[str] = "",
|
||||||
vote_average: Optional[float] = 0.0,
|
vote_average: Optional[float] = 0.0,
|
||||||
vote_count: Optional[int] = 0,
|
vote_count: Optional[int] = 0,
|
||||||
release_date: Optional[str] = "",
|
release_date: Optional[str] = "",
|
||||||
page: Optional[int] = 1,
|
page: Optional[int] = 1,
|
||||||
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
_: schemas.TokenPayload = Depends(verify_token)) -> Any:
|
||||||
"""
|
"""
|
||||||
浏览TMDB剧集信息
|
浏览TMDB剧集信息
|
||||||
"""
|
"""
|
||||||
tvs = TmdbChain().tmdb_discover(mtype=MediaType.TV,
|
tvs = await TmdbChain().async_tmdb_discover(mtype=MediaType.TV,
|
||||||
sort_by=sort_by,
|
sort_by=sort_by,
|
||||||
with_genres=with_genres,
|
with_genres=with_genres,
|
||||||
with_original_language=with_original_language,
|
with_original_language=with_original_language,
|
||||||
with_keywords=with_keywords,
|
with_keywords=with_keywords,
|
||||||
with_watch_providers=with_watch_providers,
|
with_watch_providers=with_watch_providers,
|
||||||
vote_average=vote_average,
|
vote_average=vote_average,
|
||||||
vote_count=vote_count,
|
vote_count=vote_count,
|
||||||
release_date=release_date,
|
release_date=release_date,
|
||||||
page=page)
|
page=page)
|
||||||
return [tv.to_dict() for tv in tvs] if tvs else []
|
return [tv.to_dict() for tv in tvs] if tvs else []
|
||||||
|
|||||||
Reference in New Issue
Block a user