feat 新增已入库媒体是否跟随TMDB信息变化开关,关闭则延用媒体库名称

This commit is contained in:
thsrite
2023-09-07 10:55:01 +08:00
parent e5dc40e3c1
commit b01621049b
5 changed files with 165 additions and 143 deletions

View File

@ -65,6 +65,7 @@ docker pull jxxghp/moviepilot:latest
- **DOWNLOAD_SUBTITLE** 下载站点字幕,`true`/`false`,默认`true` - **DOWNLOAD_SUBTITLE** 下载站点字幕,`true`/`false`,默认`true`
- **REFRESH_MEDIASERVER** 入库刷新媒体库,`true`/`false`,默认`true` - **REFRESH_MEDIASERVER** 入库刷新媒体库,`true`/`false`,默认`true`
- **SCRAP_METADATA** 刮削入库的媒体文件,`true`/`false`,默认`true` - **SCRAP_METADATA** 刮削入库的媒体文件,`true`/`false`,默认`true`
- **SCRAP_FOLLOW_TMDB** 新增已入库媒体是否跟随TMDB信息变化`true`/`false`,默认`true`
- **TORRENT_TAG** 种子标签,默认为`MOVIEPILOT`设置后只有MoviePilot添加的下载才会处理留空所有下载器中的任务均会处理 - **TORRENT_TAG** 种子标签,默认为`MOVIEPILOT`设置后只有MoviePilot添加的下载才会处理留空所有下载器中的任务均会处理
- **LIBRARY_PATH** 媒体库目录,多个目录使用`,`分隔 - **LIBRARY_PATH** 媒体库目录,多个目录使用`,`分隔
- **LIBRARY_MOVIE_NAME** 电影媒体库目录名,默认`电影` - **LIBRARY_MOVIE_NAME** 电影媒体库目录名,默认`电影`

View File

@ -351,6 +351,11 @@ class TransferChain(ChainBase):
# 媒体目录 # 媒体目录
if transfer_info.target_path.is_file(): if transfer_info.target_path.is_file():
transfer_info.target_path = transfer_info.target_path.parent transfer_info.target_path = transfer_info.target_path.parent
# 如果未开启新增已入库媒体是否跟随TMDB信息变化则根据tmdbid查询之前的title
if not settings.SCRAP_FOLLOW_TMDB:
transfer_historys = self.transferhis.get_by(tmdbid=str(mediainfo.tmdb_id))
if not transfer_historys:
mediainfo.title = transfer_historys[0].title
# 刮削 # 刮削
self.scrape_metadata(path=transfer_info.target_path, mediainfo=media) self.scrape_metadata(path=transfer_info.target_path, mediainfo=media)
# 刷新媒体库,根目录或季目录 # 刷新媒体库,根目录或季目录

View File

@ -39,6 +39,8 @@ class Settings(BaseSettings):
SEARCH_SOURCE: str = "themoviedb" SEARCH_SOURCE: str = "themoviedb"
# 刮削入库的媒体文件 # 刮削入库的媒体文件
SCRAP_METADATA: bool = True SCRAP_METADATA: bool = True
# 新增已入库媒体是否跟随TMDB信息变化
SCRAP_FOLLOW_TMDB: bool = True
# 刮削来源 # 刮削来源
SCRAP_SOURCE: str = "themoviedb" SCRAP_SOURCE: str = "themoviedb"
# TMDB图片地址 # TMDB图片地址

View File

@ -308,6 +308,12 @@ class DirMonitor(_PluginBase):
transferinfo=transferinfo transferinfo=transferinfo
) )
# 如果未开启新增已入库媒体是否跟随TMDB信息变化则根据tmdbid查询之前的title
if not settings.SCRAP_FOLLOW_TMDB:
transfer_historys = self.transferhis.get_by(tmdbid=str(mediainfo.tmdb_id))
if not transfer_historys:
mediainfo.title = transfer_historys[0].title
# 刮削元数据,根目录或季目录 # 刮削元数据,根目录或季目录
self.chain.scrape_metadata(path=transferinfo.target_path.parent, self.chain.scrape_metadata(path=transferinfo.target_path.parent,
mediainfo=mediainfo) mediainfo=mediainfo)
@ -478,149 +484,149 @@ class DirMonitor(_PluginBase):
def get_form(self) -> Tuple[List[dict], Dict[str, Any]]: def get_form(self) -> Tuple[List[dict], Dict[str, Any]]:
return [ return [
{ {
'component': 'VForm', 'component': 'VForm',
'content': [ 'content': [
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 6 'md': 6
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'enabled', 'model': 'enabled',
'label': '启用插件', 'label': '启用插件',
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 6 'md': 6
}, },
'content': [ 'content': [
{ {
'component': 'VSwitch', 'component': 'VSwitch',
'props': { 'props': {
'model': 'notify', 'model': 'notify',
'label': '发送通知', 'label': '发送通知',
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 6 'md': 6
}, },
'content': [ 'content': [
{ {
'component': 'VSelect', 'component': 'VSelect',
'props': { 'props': {
'model': 'mode', 'model': 'mode',
'label': '监控模式', 'label': '监控模式',
'items': [ 'items': [
{'title': '兼容模式', 'value': 'compatibility'}, {'title': '兼容模式', 'value': 'compatibility'},
{'title': '性能模式', 'value': 'fast'} {'title': '性能模式', 'value': 'fast'}
] ]
} }
} }
] ]
}, },
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12, 'cols': 12,
'md': 6 'md': 6
}, },
'content': [ 'content': [
{ {
'component': 'VSelect', 'component': 'VSelect',
'props': { 'props': {
'model': 'transfer_type', 'model': 'transfer_type',
'label': '转移方式', 'label': '转移方式',
'items': [ 'items': [
{'title': '移动', 'value': 'move'}, {'title': '移动', 'value': 'move'},
{'title': '复制', 'value': 'copy'}, {'title': '复制', 'value': 'copy'},
{'title': '硬链接', 'value': 'link'}, {'title': '硬链接', 'value': 'link'},
{'title': '软链接', 'value': 'softlink'} {'title': '软链接', 'value': 'softlink'}
] ]
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12 'cols': 12
}, },
'content': [ 'content': [
{ {
'component': 'VTextarea', 'component': 'VTextarea',
'props': { 'props': {
'model': 'monitor_dirs', 'model': 'monitor_dirs',
'label': '监控目录', 'label': '监控目录',
'rows': 5, 'rows': 5,
'placeholder': '每一行一个目录,支持两种配置方式:\n' 'placeholder': '每一行一个目录,支持两种配置方式:\n'
'监控目录\n' '监控目录\n'
'监控目录:转移目的目录' '监控目录:转移目的目录'
} }
} }
] ]
} }
] ]
}, },
{ {
'component': 'VRow', 'component': 'VRow',
'content': [ 'content': [
{ {
'component': 'VCol', 'component': 'VCol',
'props': { 'props': {
'cols': 12 'cols': 12
}, },
'content': [ 'content': [
{ {
'component': 'VTextarea', 'component': 'VTextarea',
'props': { 'props': {
'model': 'exclude_keywords', 'model': 'exclude_keywords',
'label': '排除关键词', 'label': '排除关键词',
'rows': 2, 'rows': 2,
'placeholder': '每一行一个关键词' 'placeholder': '每一行一个关键词'
} }
} }
] ]
} }
] ]
} }
] ]
} }
], { ], {
"enabled": False, "enabled": False,
"notify": False, "notify": False,
"mode": "fast", "mode": "fast",
"transfer_type": settings.TRANSFER_TYPE, "transfer_type": settings.TRANSFER_TYPE,
"monitor_dirs": "", "monitor_dirs": "",
"exclude_keywords": "" "exclude_keywords": ""
} }
def get_page(self) -> List[dict]: def get_page(self) -> List[dict]:
pass pass

View File

@ -10,6 +10,7 @@ from apscheduler.triggers.cron import CronTrigger
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.metainfo import MetaInfo from app.core.metainfo import MetaInfo
from app.db.transferhistory_oper import TransferHistoryOper
from app.helper.nfo import NfoReader from app.helper.nfo import NfoReader
from app.log import logger from app.log import logger
from app.plugins import _PluginBase from app.plugins import _PluginBase
@ -41,6 +42,7 @@ class LibraryScraper(_PluginBase):
user_level = 1 user_level = 1
# 私有属性 # 私有属性
transferhis = None
_scheduler = None _scheduler = None
_scraper = None _scraper = None
# 限速开关 # 限速开关
@ -66,6 +68,7 @@ class LibraryScraper(_PluginBase):
# 启动定时任务 & 立即运行一次 # 启动定时任务 & 立即运行一次
if self._enabled or self._onlyonce: if self._enabled or self._onlyonce:
self.transferhis = TransferHistoryOper(self.db)
self._scheduler = BackgroundScheduler(timezone=settings.TZ) self._scheduler = BackgroundScheduler(timezone=settings.TZ)
if self._cron: if self._cron:
logger.info(f"媒体库刮削服务启动,周期:{self._cron}") logger.info(f"媒体库刮削服务启动,周期:{self._cron}")
@ -304,6 +307,11 @@ class LibraryScraper(_PluginBase):
if not mediainfo: if not mediainfo:
logger.warn(f"未识别到媒体信息:{file}") logger.warn(f"未识别到媒体信息:{file}")
continue continue
# 如果未开启新增已入库媒体是否跟随TMDB信息变化则根据tmdbid查询之前的title
if not settings.SCRAP_FOLLOW_TMDB:
transfer_historys = self.transferhis.get_by(tmdbid=str(mediainfo.tmdb_id))
if not transfer_historys:
mediainfo.title = transfer_historys[0].title
# 开始刮削 # 开始刮削
self.chain.scrape_metadata(path=file, mediainfo=mediainfo) self.chain.scrape_metadata(path=file, mediainfo=mediainfo)