parent
e785f20c5a
commit
082ec8d718
@ -1,3 +1,4 @@
|
|||||||
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
import threading
|
import threading
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@ -14,12 +15,14 @@ from app.core.metainfo import MetaInfo
|
|||||||
from app.db.downloadhistory_oper import DownloadHistoryOper
|
from app.db.downloadhistory_oper import DownloadHistoryOper
|
||||||
from app.db.models.downloadhistory import DownloadHistory
|
from app.db.models.downloadhistory import DownloadHistory
|
||||||
from app.db.models.transferhistory import TransferHistory
|
from app.db.models.transferhistory import TransferHistory
|
||||||
|
from app.db.systemconfig_oper import SystemConfigOper
|
||||||
from app.db.transferhistory_oper import TransferHistoryOper
|
from app.db.transferhistory_oper import TransferHistoryOper
|
||||||
from app.helper.format import FormatParser
|
from app.helper.format import FormatParser
|
||||||
from app.helper.progress import ProgressHelper
|
from app.helper.progress import ProgressHelper
|
||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.schemas import TransferInfo, TransferTorrent, Notification, EpisodeFormat
|
from app.schemas import TransferInfo, TransferTorrent, Notification, EpisodeFormat
|
||||||
from app.schemas.types import TorrentStatus, EventType, MediaType, ProgressKey, NotificationType, MessageChannel
|
from app.schemas.types import TorrentStatus, EventType, MediaType, ProgressKey, NotificationType, MessageChannel, \
|
||||||
|
SystemConfigKey
|
||||||
from app.utils.string import StringUtils
|
from app.utils.string import StringUtils
|
||||||
from app.utils.system import SystemUtils
|
from app.utils.system import SystemUtils
|
||||||
|
|
||||||
@ -37,6 +40,7 @@ class TransferChain(ChainBase):
|
|||||||
self.transferhis = TransferHistoryOper(self._db)
|
self.transferhis = TransferHistoryOper(self._db)
|
||||||
self.progress = ProgressHelper()
|
self.progress = ProgressHelper()
|
||||||
self.mediachain = MediaChain(self._db)
|
self.mediachain = MediaChain(self._db)
|
||||||
|
self.systemconfig = SystemConfigOper()
|
||||||
|
|
||||||
def process(self) -> bool:
|
def process(self) -> bool:
|
||||||
"""
|
"""
|
||||||
@ -136,6 +140,9 @@ class TransferChain(ChainBase):
|
|||||||
text=f"开始转移 {path},共 {total_num} 个文件 ...",
|
text=f"开始转移 {path},共 {total_num} 个文件 ...",
|
||||||
key=ProgressKey.FileTransfer)
|
key=ProgressKey.FileTransfer)
|
||||||
|
|
||||||
|
# 整理屏蔽词
|
||||||
|
transfer_exclude_words = self.systemconfig.get(SystemConfigKey.TransferExcludeWords)
|
||||||
|
|
||||||
# 处理所有待转移目录或文件,默认一个转移路径或文件只有一个媒体信息
|
# 处理所有待转移目录或文件,默认一个转移路径或文件只有一个媒体信息
|
||||||
for trans_path in trans_paths:
|
for trans_path in trans_paths:
|
||||||
# 如果是目录且不是⼀蓝光原盘,获取所有文件并转移
|
# 如果是目录且不是⼀蓝光原盘,获取所有文件并转移
|
||||||
@ -154,6 +161,7 @@ class TransferChain(ChainBase):
|
|||||||
|
|
||||||
# 转移所有文件
|
# 转移所有文件
|
||||||
for file_path in file_paths:
|
for file_path in file_paths:
|
||||||
|
|
||||||
# 回收站及隐藏的文件不处理
|
# 回收站及隐藏的文件不处理
|
||||||
file_path_str = str(file_path)
|
file_path_str = str(file_path)
|
||||||
if file_path_str.find('/@Recycle/') != -1 \
|
if file_path_str.find('/@Recycle/') != -1 \
|
||||||
@ -163,6 +171,13 @@ class TransferChain(ChainBase):
|
|||||||
logger.debug(f"{file_path_str} 是回收站或隐藏的文件")
|
logger.debug(f"{file_path_str} 是回收站或隐藏的文件")
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# 整理屏蔽词不处理
|
||||||
|
if transfer_exclude_words:
|
||||||
|
for keyword in transfer_exclude_words.split("\n"):
|
||||||
|
if keyword and re.findall(keyword, file_path_str):
|
||||||
|
logger.info(f"{file_path} 命中整理屏蔽词 {keyword},不处理")
|
||||||
|
continue
|
||||||
|
|
||||||
if not meta:
|
if not meta:
|
||||||
# 上级目录元数据
|
# 上级目录元数据
|
||||||
dir_meta = MetaInfo(title=file_path.parent.name)
|
dir_meta = MetaInfo(title=file_path.parent.name)
|
||||||
|
@ -21,7 +21,7 @@ from app.db.transferhistory_oper import TransferHistoryOper
|
|||||||
from app.log import logger
|
from app.log import logger
|
||||||
from app.plugins import _PluginBase
|
from app.plugins import _PluginBase
|
||||||
from app.schemas import Notification, NotificationType, TransferInfo
|
from app.schemas import Notification, NotificationType, TransferInfo
|
||||||
from app.schemas.types import EventType, MediaType
|
from app.schemas.types import EventType, MediaType, SystemConfigKey
|
||||||
from app.utils.string import StringUtils
|
from app.utils.string import StringUtils
|
||||||
from app.utils.system import SystemUtils
|
from app.utils.system import SystemUtils
|
||||||
|
|
||||||
@ -199,13 +199,6 @@ class DirMonitor(_PluginBase):
|
|||||||
logger.debug("文件已处理过:%s" % event_path)
|
logger.debug("文件已处理过:%s" % event_path)
|
||||||
return
|
return
|
||||||
|
|
||||||
# 命中过滤关键字不处理
|
|
||||||
if self._exclude_keywords:
|
|
||||||
for keyword in self._exclude_keywords.split("\n"):
|
|
||||||
if keyword and re.findall(keyword, event_path):
|
|
||||||
logger.debug(f"{event_path} 命中过滤关键字 {keyword}")
|
|
||||||
return
|
|
||||||
|
|
||||||
# 回收站及隐藏的文件不处理
|
# 回收站及隐藏的文件不处理
|
||||||
if event_path.find('/@Recycle/') != -1 \
|
if event_path.find('/@Recycle/') != -1 \
|
||||||
or event_path.find('/#recycle/') != -1 \
|
or event_path.find('/#recycle/') != -1 \
|
||||||
@ -214,6 +207,21 @@ class DirMonitor(_PluginBase):
|
|||||||
logger.debug(f"{event_path} 是回收站或隐藏的文件")
|
logger.debug(f"{event_path} 是回收站或隐藏的文件")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# 命中过滤关键字不处理
|
||||||
|
if self._exclude_keywords:
|
||||||
|
for keyword in self._exclude_keywords.split("\n"):
|
||||||
|
if keyword and re.findall(keyword, event_path):
|
||||||
|
logger.info(f"{event_path} 命中过滤关键字 {keyword},不处理")
|
||||||
|
return
|
||||||
|
|
||||||
|
# 整理屏蔽词不处理
|
||||||
|
transfer_exclude_words = self.systemconfig.get(SystemConfigKey.TransferExcludeWords)
|
||||||
|
if transfer_exclude_words:
|
||||||
|
for keyword in transfer_exclude_words.split("\n"):
|
||||||
|
if keyword and re.findall(keyword, event_path):
|
||||||
|
logger.info(f"{event_path} 命中整理屏蔽词 {keyword},不处理")
|
||||||
|
return
|
||||||
|
|
||||||
# 不是媒体文件不处理
|
# 不是媒体文件不处理
|
||||||
if file_path.suffix not in settings.RMT_MEDIAEXT:
|
if file_path.suffix not in settings.RMT_MEDIAEXT:
|
||||||
logger.debug(f"{event_path} 不是媒体文件")
|
logger.debug(f"{event_path} 不是媒体文件")
|
||||||
|
@ -64,6 +64,8 @@ class SystemConfigKey(Enum):
|
|||||||
FilterRules = "FilterRules"
|
FilterRules = "FilterRules"
|
||||||
# 洗版规则
|
# 洗版规则
|
||||||
FilterRules2 = "FilterRules2"
|
FilterRules2 = "FilterRules2"
|
||||||
|
# 转移屏蔽词
|
||||||
|
TransferExcludeWords = "TransferExcludeWords"
|
||||||
|
|
||||||
|
|
||||||
# 处理进度Key字典
|
# 处理进度Key字典
|
||||||
|
Loading…
x
Reference in New Issue
Block a user