tmdb wallpaper
This commit is contained in:
parent
8609e97dd6
commit
50d644466e
@ -4,7 +4,7 @@ from app.api.endpoints import login, user, site, message, webhook, subscribe, \
|
|||||||
media, douban, search, plugin, tmdb, history, system, download, dashboard
|
media, douban, search, plugin, tmdb, history, system, download, dashboard
|
||||||
|
|
||||||
api_router = APIRouter()
|
api_router = APIRouter()
|
||||||
api_router.include_router(login.router, tags=["login"])
|
api_router.include_router(login.router, prefix="/login", tags=["login"])
|
||||||
api_router.include_router(user.router, prefix="/user", tags=["user"])
|
api_router.include_router(user.router, prefix="/user", tags=["user"])
|
||||||
api_router.include_router(site.router, prefix="/site", tags=["site"])
|
api_router.include_router(site.router, prefix="/site", tags=["site"])
|
||||||
api_router.include_router(message.router, prefix="/message", tags=["message"])
|
api_router.include_router(message.router, prefix="/message", tags=["message"])
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import random
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
@ -6,6 +7,7 @@ from fastapi.security import OAuth2PasswordRequestForm
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from app import schemas
|
from app import schemas
|
||||||
|
from app.chain.tmdb import TmdbChain
|
||||||
from app.chain.user import UserChain
|
from app.chain.user import UserChain
|
||||||
from app.core import security
|
from app.core import security
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
@ -18,7 +20,7 @@ from app.utils.http import RequestUtils
|
|||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
|
|
||||||
@router.post("/login/access-token", summary="获取token", response_model=schemas.Token)
|
@router.post("/access-token", summary="获取token", response_model=schemas.Token)
|
||||||
async def login_access_token(
|
async def login_access_token(
|
||||||
db: Session = Depends(get_db), form_data: OAuth2PasswordRequestForm = Depends()
|
db: Session = Depends(get_db), form_data: OAuth2PasswordRequestForm = Depends()
|
||||||
) -> Any:
|
) -> Any:
|
||||||
@ -57,7 +59,7 @@ async def login_access_token(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@router.get("/login/wallpaper", summary="Bing每日壁纸", response_model=schemas.Response)
|
@router.get("/bing", summary="Bing每日壁纸", response_model=schemas.Response)
|
||||||
def bing_wallpaper() -> Any:
|
def bing_wallpaper() -> Any:
|
||||||
"""
|
"""
|
||||||
获取Bing每日壁纸
|
获取Bing每日壁纸
|
||||||
@ -78,3 +80,21 @@ def bing_wallpaper() -> Any:
|
|||||||
except Exception as err:
|
except Exception as err:
|
||||||
print(str(err))
|
print(str(err))
|
||||||
return schemas.Response(success=False)
|
return schemas.Response(success=False)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/tmdb", summary="TMDB电影海报", response_model=schemas.Response)
|
||||||
|
def tmdb_wallpaper() -> Any:
|
||||||
|
"""
|
||||||
|
获取TMDB电影海报
|
||||||
|
"""
|
||||||
|
infos = TmdbChain().tmdb_trending()
|
||||||
|
if infos:
|
||||||
|
# 随机一个电影
|
||||||
|
while True:
|
||||||
|
info = random.choice(infos)
|
||||||
|
if info and info.get("backdrop_path"):
|
||||||
|
return schemas.Response(
|
||||||
|
success=True,
|
||||||
|
message=f"https://image.tmdb.org/t/p/original{info.get('backdrop_path')}"
|
||||||
|
)
|
||||||
|
return schemas.Response(success=False)
|
||||||
|
@ -113,7 +113,7 @@ class TransferChain(ChainBase):
|
|||||||
logger.warn(f'未识别到媒体信息,标题:{torrent.title}')
|
logger.warn(f'未识别到媒体信息,标题:{torrent.title}')
|
||||||
self.post_message(Notification(
|
self.post_message(Notification(
|
||||||
channel=channel,
|
channel=channel,
|
||||||
mtype=NotificationType.Organize,
|
mtype=NotificationType.Manual,
|
||||||
title=f"{torrent.title} 未识别到媒体信息,无法入库!\n"
|
title=f"{torrent.title} 未识别到媒体信息,无法入库!\n"
|
||||||
f"回复:```\n/transfer {torrent.hash} [tmdbid]\n``` 手动识别转移。",
|
f"回复:```\n/transfer {torrent.hash} [tmdbid]\n``` 手动识别转移。",
|
||||||
userid=userid))
|
userid=userid))
|
||||||
|
@ -91,6 +91,8 @@ class NotificationType(Enum):
|
|||||||
SiteMessage = "站点消息"
|
SiteMessage = "站点消息"
|
||||||
# 媒体服务器通知
|
# 媒体服务器通知
|
||||||
MediaServer = "媒体服务器通知"
|
MediaServer = "媒体服务器通知"
|
||||||
|
# 处理失败需要人工干预
|
||||||
|
Manual = "手动处理通知"
|
||||||
|
|
||||||
|
|
||||||
class MessageChannel(Enum):
|
class MessageChannel(Enum):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user