mirror of
https://github.com/d0zingcat/MoviePilot-Plugins.git
synced 2026-05-14 07:26:51 +00:00
Merge pull request #260 from Pixel-LH/main
This commit is contained in:
@@ -259,10 +259,13 @@
|
||||
"name": "整理VCB动漫压制组作品",
|
||||
"description": "提高部分VCB-Studio作品的识别准确率,将VCB-Studio的作品统一转移到指定目录同时进行刮削整理",
|
||||
"labels": "文件整理,识别",
|
||||
"version": "1.7",
|
||||
"version": "1.7.1",
|
||||
"icon": "vcbmonitor.png",
|
||||
"author": "pixel@qingwa",
|
||||
"level": 2
|
||||
"level": 2,
|
||||
"history": {
|
||||
"v1.7.1": "修复偶尔安装失败问题"
|
||||
}
|
||||
},
|
||||
"TorrentTransfer": {
|
||||
"name": "自动转移做种",
|
||||
|
||||
@@ -5,8 +5,8 @@ import threading
|
||||
import time
|
||||
import traceback
|
||||
from pathlib import Path
|
||||
from time import sleep
|
||||
from typing import List, Tuple, Dict, Any, Optional
|
||||
|
||||
import pytz
|
||||
import qbittorrentapi
|
||||
from apscheduler.schedulers.background import BackgroundScheduler
|
||||
@@ -14,12 +14,13 @@ from apscheduler.triggers.cron import CronTrigger
|
||||
from watchdog.events import FileSystemEventHandler
|
||||
from watchdog.observers import Observer
|
||||
from watchdog.observers.polling import PollingObserver
|
||||
|
||||
from app import schemas
|
||||
from app.chain.tmdb import TmdbChain
|
||||
from app.chain.transfer import TransferChain
|
||||
from app.core.config import settings
|
||||
from app.core.context import MediaInfo
|
||||
from app.core.event import eventmanager, Event
|
||||
from app.core.metainfo import MetaInfoPath
|
||||
from app.db.downloadhistory_oper import DownloadHistoryOper
|
||||
from app.db.transferhistory_oper import TransferHistoryOper
|
||||
from app.log import logger
|
||||
@@ -76,7 +77,7 @@ class VCBAnimeMonitor(_PluginBase):
|
||||
# 插件图标
|
||||
plugin_icon = "vcbmonitor.png"
|
||||
# 插件版本
|
||||
plugin_version = "1.7"
|
||||
plugin_version = "1.7.1"
|
||||
# 插件作者
|
||||
plugin_author = "pixel@qingwa"
|
||||
# 作者主页
|
||||
@@ -155,15 +156,20 @@ class VCBAnimeMonitor(_PluginBase):
|
||||
self._scheduler.add_job(self.send_msg, trigger='interval', seconds=15)
|
||||
self.qb = Qbittorrent()
|
||||
|
||||
# 读取目录配置
|
||||
monitor_dirs = self._monitor_dirs.split("\n")
|
||||
if not monitor_dirs:
|
||||
return
|
||||
|
||||
# 启用种子目录监控
|
||||
if self._torrents_path is not None and Path(self._torrents_path).exists() and self._enabled:
|
||||
# 只取第一个目录作为新的保存
|
||||
first_path = monitor_dirs[0]
|
||||
if SystemUtils.is_windows():
|
||||
self.new_save_path = self._monitor_dirs.split(':')[0] + ":" + self._monitor_dirs.split(':')[1]
|
||||
self.new_save_path = first_path.split(':')[0] + ":" + first_path.split(':')[1]
|
||||
else:
|
||||
self.new_save_path = self._monitor_dirs.split(':')[0]
|
||||
print(self.new_save_path)
|
||||
|
||||
self.new_save_path = first_path.split(':')[0]
|
||||
# print(self.new_save_path)
|
||||
try:
|
||||
observer = Observer()
|
||||
self._observer.append(observer)
|
||||
@@ -177,10 +183,6 @@ class VCBAnimeMonitor(_PluginBase):
|
||||
else:
|
||||
logger.info("种子目录为空,不转移qb中正在下载的VCB-Studio文件")
|
||||
|
||||
# 读取目录配置
|
||||
monitor_dirs = self._monitor_dirs.split("\n")
|
||||
if not monitor_dirs:
|
||||
return
|
||||
for mon_path in monitor_dirs:
|
||||
# 格式源目录:目的目录
|
||||
if not mon_path:
|
||||
@@ -594,6 +596,7 @@ class VCBAnimeMonitor(_PluginBase):
|
||||
def torrent_event(self, event, mon_path: str, text: str):
|
||||
"""
|
||||
处理种子文件
|
||||
:param mon_path: 种子目录
|
||||
"""
|
||||
evc_path = Path(event.src_path)
|
||||
if not event.is_directory and (evc_path.suffix == ".torrent" or str(evc_path).split('.')[1] == "torrent"):
|
||||
@@ -1009,8 +1012,7 @@ class VCBAnimeMonitor(_PluginBase):
|
||||
'props': {
|
||||
'type': 'info',
|
||||
'variant': 'tonal',
|
||||
'text': '核心用法与目录同步插件相同,不同点在于只识别处理VCB-Studio资源,'
|
||||
'避免与目录同步插件的监控目录相同(否则会同时进行识别)'
|
||||
'text': '核心用法与目录同步插件相同,不同点在于只识别处理VCB-Studio资源,\n'
|
||||
'不处理SPs目录下的文件,OVA/OAD集数根据入库顺序累加命名,不保证与TMDB集数匹配'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,6 @@ import concurrent
|
||||
import re
|
||||
from pathlib import Path
|
||||
from typing import List
|
||||
|
||||
import roman
|
||||
|
||||
from app.chain.media import MediaChain
|
||||
from app.chain.tmdb import TmdbChain
|
||||
from app.core.metainfo import MetaInfoPath
|
||||
@@ -12,6 +9,26 @@ from app.log import logger
|
||||
from app.schemas import MediaType
|
||||
|
||||
|
||||
def roman_to_int(s) -> int:
|
||||
"""
|
||||
:param s: 罗马数字字符串
|
||||
罗马数字转整数
|
||||
"""
|
||||
roman_dict = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
|
||||
total = 0
|
||||
prev_value = 0
|
||||
|
||||
for char in reversed(s): # 反向遍历罗马数字字符串
|
||||
current_value = roman_dict[char]
|
||||
if current_value >= prev_value:
|
||||
total += current_value # 如果当前值大于等于前一个值,加上当前值
|
||||
else:
|
||||
total -= current_value # 如果当前值小于前一个值,减去当前值
|
||||
prev_value = current_value
|
||||
|
||||
return total
|
||||
|
||||
|
||||
class ReMeta:
|
||||
# 解析之后的标题:
|
||||
title: str = None
|
||||
@@ -41,7 +58,7 @@ class ReMeta:
|
||||
]
|
||||
_ova_patterns = [re.compile(r"\[.*?(OVA|OAD).*?]"),
|
||||
re.compile(r"\[\d+\.5]"),
|
||||
re.compile(r"\[00]")]
|
||||
re.compile(r"\[00\]")]
|
||||
|
||||
final_season_patterns = [re.compile('final season', re.IGNORECASE),
|
||||
re.compile('The Final', re.IGNORECASE),
|
||||
@@ -57,13 +74,14 @@ class ReMeta:
|
||||
def handel_file(self, file_path: Path):
|
||||
meta = MetaInfoPath(file_path)
|
||||
self.title = meta.title
|
||||
self.title = Path(self.title).stem.strip()
|
||||
if 'VCB-Studio' not in meta.title:
|
||||
logger.warn("不属于VCB的作品,不处理!")
|
||||
return None
|
||||
if meta.title.count("[") != 4 and meta.title.count("]") != 4:
|
||||
# 可能是电影,电影只有三组[],因此去除所有[]后只剩下电影名
|
||||
logger.warn("不符合VCB-Studio的剧集命名规范,跳过剧集模块处理!交给默认处理逻辑")
|
||||
meta.title = re.sub(r'\[.*?]', '', meta.title).strip()
|
||||
meta.title = re.sub(r'\[.*?\]', '', meta.title).strip()
|
||||
meta.en_name = meta.title
|
||||
return meta
|
||||
split_title: List[str] | None = self.split_season_ep(self.title)
|
||||
@@ -84,13 +102,12 @@ class ReMeta:
|
||||
return meta
|
||||
|
||||
# 分离季度部分和集数部分
|
||||
@staticmethod
|
||||
def split_season_ep(pre_title: str):
|
||||
def split_season_ep(self, pre_title: str):
|
||||
split_ep = re.findall(r"(\[.*?])", pre_title)[1]
|
||||
if not split_ep:
|
||||
logger.warn("未识别出集数位置信息,结束识别!")
|
||||
return None
|
||||
split_title = re.sub(r"\[.*?]", "", pre_title).strip()
|
||||
split_title = re.sub(r"\[.*?\]", "", pre_title).strip()
|
||||
logger.info(f"分离出包含季度的部分:{split_title} \n 分离出包含集数的部分: {split_ep}")
|
||||
return [split_title, split_ep]
|
||||
|
||||
@@ -126,7 +143,7 @@ class ReMeta:
|
||||
match = pattern.search(pre_title)
|
||||
if match:
|
||||
if type(group) == str:
|
||||
title_season["season"] = int(roman.fromRoman(match.group(int(group))))
|
||||
title_season["season"] = roman_to_int(match.group(int(group)))
|
||||
title_season["title"] = re.sub(pattern, "", pre_title).strip()
|
||||
else:
|
||||
title_season["season"] = int(match.group(group))
|
||||
@@ -142,8 +159,7 @@ class ReMeta:
|
||||
return title_season
|
||||
|
||||
# 处理存在“Final”字样命名的季度
|
||||
@staticmethod
|
||||
def handle_final_season(title: str) -> int | None:
|
||||
def handle_final_season(self, title: str) -> int | None:
|
||||
medias = MediaChain().search(title=title)[1]
|
||||
if not medias:
|
||||
logger.warn("没有找到对应的媒体信息!")
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
roman~=4.1
|
||||
Reference in New Issue
Block a user