mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 23:47:41 +08:00
feat(themoviedb): 添加对 ConfigChanged 事件的监听支持
- 调整 username 字段类型以兼容整数形式
This commit is contained in:
@@ -1,12 +1,10 @@
|
|||||||
import copy
|
import copy
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from typing import Dict
|
from typing import Dict, Optional, Union, List, Tuple, Any
|
||||||
from typing import Optional, Union, List, Tuple, Any
|
|
||||||
|
|
||||||
from app.core.context import MediaInfo, Context
|
from app.core.context import MediaInfo, Context
|
||||||
from app.core.event import Event
|
from app.core.event import eventmanager, Event
|
||||||
from app.core.event import eventmanager
|
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.modules import _ModuleBase, _MessageBase
|
from app.modules import _ModuleBase, _MessageBase
|
||||||
from app.modules.telegram.telegram import Telegram
|
from app.modules.telegram.telegram import Telegram
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import zhconv
|
|||||||
from app import schemas
|
from app import schemas
|
||||||
from app.core.config import settings
|
from app.core.config import settings
|
||||||
from app.core.context import MediaInfo
|
from app.core.context import MediaInfo
|
||||||
|
from app.core.event import eventmanager, Event
|
||||||
from app.core.meta import MetaBase
|
from app.core.meta import MetaBase
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.modules import _ModuleBase
|
from app.modules import _ModuleBase
|
||||||
@@ -14,8 +15,7 @@ from app.modules.themoviedb.category import CategoryHelper
|
|||||||
from app.modules.themoviedb.scraper import TmdbScraper
|
from app.modules.themoviedb.scraper import TmdbScraper
|
||||||
from app.modules.themoviedb.tmdb_cache import TmdbCache
|
from app.modules.themoviedb.tmdb_cache import TmdbCache
|
||||||
from app.modules.themoviedb.tmdbapi import TmdbApi
|
from app.modules.themoviedb.tmdbapi import TmdbApi
|
||||||
from app.schemas import MediaPerson
|
from app.schemas.types import MediaType, MediaImageType, ModuleType, MediaRecognizeType, EventType
|
||||||
from app.schemas.types import MediaType, MediaImageType, ModuleType, MediaRecognizeType
|
|
||||||
from app.utils.http import RequestUtils
|
from app.utils.http import RequestUtils
|
||||||
|
|
||||||
|
|
||||||
@@ -39,6 +39,23 @@ class TheMovieDbModule(_ModuleBase):
|
|||||||
self.category = CategoryHelper()
|
self.category = CategoryHelper()
|
||||||
self.scraper = TmdbScraper()
|
self.scraper = TmdbScraper()
|
||||||
|
|
||||||
|
@eventmanager.register(EventType.ConfigChanged)
|
||||||
|
def handle_config_changed(self, event: Event):
|
||||||
|
"""
|
||||||
|
处理配置变更事件
|
||||||
|
:param event: 事件对象
|
||||||
|
"""
|
||||||
|
if not event:
|
||||||
|
return
|
||||||
|
event_data: schemas.ConfigChangeEventData = event.event_data
|
||||||
|
if event_data.key not in ["PROXY", "TMDB_API_DOMAIN", "TMDB_API_KEY", "TMDB_LOCALE"]:
|
||||||
|
return
|
||||||
|
logger.info("配置变更,重新初始化TheMovieDb模块...")
|
||||||
|
# 停止模块
|
||||||
|
self.stop()
|
||||||
|
# 初始化模块
|
||||||
|
self.init_module()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_name() -> str:
|
def get_name() -> str:
|
||||||
return "TheMovieDb"
|
return "TheMovieDb"
|
||||||
@@ -635,7 +652,7 @@ class TheMovieDbModule(_ModuleBase):
|
|||||||
return medias
|
return medias
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def search_persons(self, name: str) -> Optional[List[MediaPerson]]:
|
def search_persons(self, name: str) -> Optional[List[schemas.MediaPerson]]:
|
||||||
"""
|
"""
|
||||||
搜索人物信息
|
搜索人物信息
|
||||||
"""
|
"""
|
||||||
@@ -645,10 +662,10 @@ class TheMovieDbModule(_ModuleBase):
|
|||||||
return []
|
return []
|
||||||
results = self.tmdb.search_persons(name)
|
results = self.tmdb.search_persons(name)
|
||||||
if results:
|
if results:
|
||||||
return [MediaPerson(source='themoviedb', **person) for person in results]
|
return [schemas.MediaPerson(source='themoviedb', **person) for person in results]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
async def async_search_persons(self, name: str) -> Optional[List[MediaPerson]]:
|
async def async_search_persons(self, name: str) -> Optional[List[schemas.MediaPerson]]:
|
||||||
"""
|
"""
|
||||||
异步搜索人物信息
|
异步搜索人物信息
|
||||||
"""
|
"""
|
||||||
@@ -658,7 +675,7 @@ class TheMovieDbModule(_ModuleBase):
|
|||||||
return []
|
return []
|
||||||
results = await self.tmdb.async_search_persons(name)
|
results = await self.tmdb.async_search_persons(name)
|
||||||
if results:
|
if results:
|
||||||
return [MediaPerson(source='themoviedb', **person) for person in results]
|
return [schemas.MediaPerson(source='themoviedb', **person) for person in results]
|
||||||
return []
|
return []
|
||||||
|
|
||||||
def search_collections(self, name: str) -> Optional[List[MediaInfo]]:
|
def search_collections(self, name: str) -> Optional[List[MediaInfo]]:
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ class Notification(BaseModel):
|
|||||||
# 用户ID
|
# 用户ID
|
||||||
userid: Optional[Union[str, int]] = None
|
userid: Optional[Union[str, int]] = None
|
||||||
# 用户名称
|
# 用户名称
|
||||||
username: Optional[str] = None
|
username: Optional[Union[str, int]] = None
|
||||||
# 时间
|
# 时间
|
||||||
date: Optional[str] = None
|
date: Optional[str] = None
|
||||||
# 消息方向
|
# 消息方向
|
||||||
|
|||||||
Reference in New Issue
Block a user