mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
refactor: 推进后端分层架构治理
This commit is contained in:
@@ -3,7 +3,7 @@ from typing import Any, List, Optional, Tuple, Union
|
||||
|
||||
import cn2an
|
||||
|
||||
from app import schemas
|
||||
from app.schemas.context import MediaPerson as _SchemaMediaPerson
|
||||
from app.runtime.config import settings
|
||||
from app.domain.context import (
|
||||
MediaInfo,
|
||||
@@ -17,7 +17,8 @@ from app.runtime.log import logger
|
||||
from app.modules import _ModuleBase
|
||||
from app.modules.douban.apiv2 import DoubanApi
|
||||
from app.modules.douban.scraper import DoubanScraper
|
||||
from app.schemas import MediaPerson, APIRateLimitException
|
||||
from app.schemas.context import MediaPerson
|
||||
from app.schemas.exception import APIRateLimitException
|
||||
from app.schemas.types import (
|
||||
MUSIC_ENTITY_ALBUM,
|
||||
MUSIC_ENTITY_RECORDING,
|
||||
@@ -1777,7 +1778,7 @@ class DoubanModule(_ModuleBase):
|
||||
self.doubanapi.clear_cache()
|
||||
logger.info("豆瓣缓存清除完成")
|
||||
|
||||
def douban_movie_credits(self, doubanid: str) -> List[schemas.MediaPerson]:
|
||||
def douban_movie_credits(self, doubanid: str) -> List[_SchemaMediaPerson]:
|
||||
"""
|
||||
根据豆瓣ID查询电影演职员表
|
||||
:param doubanid: 豆瓣ID
|
||||
@@ -1785,7 +1786,7 @@ class DoubanModule(_ModuleBase):
|
||||
result = self.doubanapi.movie_celebrities(subject_id=doubanid)
|
||||
return self._process_celebrity_data(result)
|
||||
|
||||
def douban_tv_credits(self, doubanid: str) -> List[schemas.MediaPerson]:
|
||||
def douban_tv_credits(self, doubanid: str) -> List[_SchemaMediaPerson]:
|
||||
"""
|
||||
根据豆瓣ID查询电视剧演职员表
|
||||
:param doubanid: 豆瓣ID
|
||||
@@ -1813,7 +1814,7 @@ class DoubanModule(_ModuleBase):
|
||||
return [MediaInfo(douban_info=info) for info in recommend]
|
||||
return []
|
||||
|
||||
def douban_person_detail(self, person_id: int) -> schemas.MediaPerson:
|
||||
def douban_person_detail(self, person_id: int) -> _SchemaMediaPerson:
|
||||
"""
|
||||
获取人物详细信息
|
||||
:param person_id: 豆瓣人物ID
|
||||
@@ -1827,14 +1828,14 @@ class DoubanModule(_ModuleBase):
|
||||
image = detail.get("cover_img", {}).get("url")
|
||||
if image:
|
||||
image = image.replace("/l/public/", "/s/public/")
|
||||
return schemas.MediaPerson(source='douban', **{
|
||||
return _SchemaMediaPerson(source='douban', **{
|
||||
"id": detail.get("id"),
|
||||
"name": detail.get("title"),
|
||||
"avatar": image,
|
||||
"biography": detail.get("extra", {}).get("short_info"),
|
||||
"also_known_as": also_known_as,
|
||||
})
|
||||
return schemas.MediaPerson(source='douban')
|
||||
return _SchemaMediaPerson(source='douban')
|
||||
|
||||
def douban_person_credits(self, person_id: int, page: int = 1) -> List[MediaInfo]:
|
||||
"""
|
||||
@@ -1859,7 +1860,7 @@ class DoubanModule(_ModuleBase):
|
||||
return []
|
||||
|
||||
@staticmethod
|
||||
def _process_celebrity_data(result: dict) -> List[schemas.MediaPerson]:
|
||||
def _process_celebrity_data(result: dict) -> List[_SchemaMediaPerson]:
|
||||
"""
|
||||
处理演职员表数据的公共方法
|
||||
:param result: API返回的演职员表数据
|
||||
@@ -1872,10 +1873,10 @@ class DoubanModule(_ModuleBase):
|
||||
# 更新豆瓣演员信息中的ID,从URI中提取'douban://douban.com/celebrity/1316132?subject_id=27503705' subject_id
|
||||
for doubaninfo in ret_list:
|
||||
doubaninfo['id'] = doubaninfo.get('uri', '').split('?subject_id=')[-1]
|
||||
return [schemas.MediaPerson(source='douban', **doubaninfo) for doubaninfo in ret_list]
|
||||
return [_SchemaMediaPerson(source='douban', **doubaninfo) for doubaninfo in ret_list]
|
||||
return []
|
||||
|
||||
async def async_douban_movie_credits(self, doubanid: str) -> List[schemas.MediaPerson]:
|
||||
async def async_douban_movie_credits(self, doubanid: str) -> List[_SchemaMediaPerson]:
|
||||
"""
|
||||
根据豆瓣ID查询电影演职员表(异步版本)
|
||||
:param doubanid: 豆瓣ID
|
||||
@@ -1883,7 +1884,7 @@ class DoubanModule(_ModuleBase):
|
||||
result = await self.doubanapi.async_movie_celebrities(subject_id=doubanid)
|
||||
return self._process_celebrity_data(result)
|
||||
|
||||
async def async_douban_tv_credits(self, doubanid: str) -> List[schemas.MediaPerson]:
|
||||
async def async_douban_tv_credits(self, doubanid: str) -> List[_SchemaMediaPerson]:
|
||||
"""
|
||||
根据豆瓣ID查询电视剧演职员表(异步版本)
|
||||
:param doubanid: 豆瓣ID
|
||||
@@ -1911,7 +1912,7 @@ class DoubanModule(_ModuleBase):
|
||||
return [MediaInfo(douban_info=info) for info in recommend]
|
||||
return []
|
||||
|
||||
async def async_douban_person_detail(self, person_id: int) -> schemas.MediaPerson:
|
||||
async def async_douban_person_detail(self, person_id: int) -> _SchemaMediaPerson:
|
||||
"""
|
||||
获取人物详细信息(异步版本)
|
||||
:param person_id: 豆瓣人物ID
|
||||
@@ -1925,14 +1926,14 @@ class DoubanModule(_ModuleBase):
|
||||
image = detail.get("cover_img", {}).get("url")
|
||||
if image:
|
||||
image = image.replace("/l/public/", "/s/public/")
|
||||
return schemas.MediaPerson(source='douban', **{
|
||||
return _SchemaMediaPerson(source='douban', **{
|
||||
"id": detail.get("id"),
|
||||
"name": detail.get("title"),
|
||||
"avatar": image,
|
||||
"biography": detail.get("extra", {}).get("short_info"),
|
||||
"also_known_as": also_known_as,
|
||||
})
|
||||
return schemas.MediaPerson(source='douban')
|
||||
return _SchemaMediaPerson(source='douban')
|
||||
|
||||
async def async_douban_person_credits(self, person_id: int, page: int = 1) -> List[MediaInfo]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user