mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-07 22:23:48 +08:00
fix #2913
This commit is contained in:
@@ -281,7 +281,7 @@ class FileManagerModule(_ModuleBase):
|
||||
return storage_oper.usage()
|
||||
|
||||
def transfer(self, fileitem: FileItem, meta: MetaBase, mediainfo: MediaInfo,
|
||||
transfer_type: str, target_storage: str = None, target_path: Path = None,
|
||||
transfer_type: str = None, target_storage: str = None, target_path: Path = None,
|
||||
episodes_info: List[TmdbEpisode] = None,
|
||||
scrape: bool = None) -> TransferInfo:
|
||||
"""
|
||||
@@ -329,12 +329,15 @@ class FileManagerModule(_ModuleBase):
|
||||
need_rename = dir_info.renaming
|
||||
# 覆盖模式
|
||||
overwrite_mode = dir_info.overwrite_mode
|
||||
# 是否需要通知
|
||||
need_notify = dir_info.notify
|
||||
# 拼装媒体库一、二级子目录
|
||||
target_path = self.__get_dest_dir(mediainfo=mediainfo, target_dir=dir_info)
|
||||
elif target_path:
|
||||
# 自定义目标路径
|
||||
# 自定义目标路径,仅适用于手动整理的场景
|
||||
need_scrape = scrape or False
|
||||
need_rename = True
|
||||
need_notify = False
|
||||
overwrite_mode = "never"
|
||||
else:
|
||||
# 未找到有效的媒体库目录
|
||||
@@ -355,7 +358,8 @@ class FileManagerModule(_ModuleBase):
|
||||
target_path=target_path,
|
||||
episodes_info=episodes_info,
|
||||
need_scrape=need_scrape,
|
||||
need_rename=need_rename)
|
||||
need_rename=need_rename,
|
||||
need_notify=need_notify)
|
||||
|
||||
def __get_storage_oper(self, _storage: str, _func: str = None) -> Optional[StorageBase]:
|
||||
"""
|
||||
@@ -811,7 +815,8 @@ class FileManagerModule(_ModuleBase):
|
||||
target_path: Path,
|
||||
episodes_info: List[TmdbEpisode] = None,
|
||||
need_scrape: bool = False,
|
||||
need_rename: bool = True
|
||||
need_rename: bool = True,
|
||||
need_notify: bool = True,
|
||||
) -> TransferInfo:
|
||||
"""
|
||||
识别并整理一个文件或者一个目录下的所有文件
|
||||
@@ -825,6 +830,7 @@ class FileManagerModule(_ModuleBase):
|
||||
:param episodes_info: 当前季的全部集信息
|
||||
:param need_scrape: 是否需要刮削
|
||||
:param need_rename: 是否需要重命名
|
||||
:param need_notify: 是否需要通知
|
||||
:return: TransferInfo、错误信息
|
||||
"""
|
||||
|
||||
@@ -854,7 +860,8 @@ class FileManagerModule(_ModuleBase):
|
||||
return TransferInfo(success=False,
|
||||
message=errmsg,
|
||||
fileitem=fileitem,
|
||||
transfer_type=transfer_type)
|
||||
transfer_type=transfer_type,
|
||||
need_notify=need_notify)
|
||||
|
||||
logger.info(f"文件夹 {fileitem.path} 整理成功")
|
||||
# 返回整理后的路径
|
||||
@@ -875,7 +882,8 @@ class FileManagerModule(_ModuleBase):
|
||||
message=f"未识别到文件集数",
|
||||
fileitem=fileitem,
|
||||
fail_list=[fileitem.path],
|
||||
transfer_type=transfer_type)
|
||||
transfer_type=transfer_type,
|
||||
need_notify=need_notify)
|
||||
|
||||
# 文件结束季为空
|
||||
in_meta.end_season = None
|
||||
@@ -938,7 +946,8 @@ class FileManagerModule(_ModuleBase):
|
||||
target_item=target_item,
|
||||
target_diritem=target_diritem,
|
||||
fail_list=[fileitem.path],
|
||||
transfer_type=transfer_type)
|
||||
transfer_type=transfer_type,
|
||||
need_notify=need_notify)
|
||||
case 'never':
|
||||
# 存在不覆盖
|
||||
return TransferInfo(success=False,
|
||||
@@ -947,7 +956,8 @@ class FileManagerModule(_ModuleBase):
|
||||
target_item=target_item,
|
||||
target_diritem=target_diritem,
|
||||
fail_list=[fileitem.path],
|
||||
transfer_type=transfer_type)
|
||||
transfer_type=transfer_type,
|
||||
need_notify=need_notify)
|
||||
case 'latest':
|
||||
# 仅保留最新版本
|
||||
logger.info(f"当前整理覆盖模式设置为仅保留最新版本,将覆盖:{new_file}")
|
||||
@@ -969,7 +979,8 @@ class FileManagerModule(_ModuleBase):
|
||||
message=err_msg,
|
||||
fileitem=fileitem,
|
||||
fail_list=[fileitem.path],
|
||||
transfer_type=transfer_type)
|
||||
transfer_type=transfer_type,
|
||||
need_notify=need_notify)
|
||||
|
||||
logger.info(f"文件 {fileitem.path} 整理成功")
|
||||
return TransferInfo(success=True,
|
||||
@@ -981,7 +992,8 @@ class FileManagerModule(_ModuleBase):
|
||||
file_list=[fileitem.path],
|
||||
file_list_new=[new_item.path],
|
||||
need_scrape=need_scrape,
|
||||
transfer_type=transfer_type)
|
||||
transfer_type=transfer_type,
|
||||
need_notify=need_notify)
|
||||
|
||||
@staticmethod
|
||||
def __get_naming_dict(meta: MetaBase, mediainfo: MediaInfo, file_ext: str = None,
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import Set, Tuple, Optional, Union, List
|
||||
|
||||
@@ -14,7 +13,6 @@ from app.modules.qbittorrent.qbittorrent import Qbittorrent
|
||||
from app.schemas import TransferTorrent, DownloadingTorrent
|
||||
from app.schemas.types import TorrentStatus, ModuleType
|
||||
from app.utils.string import StringUtils
|
||||
from app.utils.system import SystemUtils
|
||||
|
||||
|
||||
class QbittorrentModule(_ModuleBase, _DownloaderBase[Qbittorrent]):
|
||||
@@ -269,29 +267,16 @@ class QbittorrentModule(_ModuleBase, _DownloaderBase[Qbittorrent]):
|
||||
return None
|
||||
return ret_torrents
|
||||
|
||||
def transfer_completed(self, hashs: str, path: Path = None,
|
||||
downloader: str = None, transfer_type: str = None) -> None:
|
||||
def transfer_completed(self, hashs: str, downloader: str = None) -> None:
|
||||
"""
|
||||
转移完成后的处理
|
||||
:param hashs: 种子Hash
|
||||
:param path: 源目录
|
||||
:param downloader: 下载器
|
||||
:param transfer_type: 整理方式
|
||||
"""
|
||||
server: Qbittorrent = self.get_instance(downloader)
|
||||
if not server:
|
||||
return None
|
||||
server.set_torrents_tag(ids=hashs, tags=['已整理'])
|
||||
# 移动模式删除种子
|
||||
if transfer_type and transfer_type in ["move"]:
|
||||
if self.remove_torrents(hashs):
|
||||
logger.info(f"移动模式删除种子成功:{hashs} ")
|
||||
# 删除本地残留文件
|
||||
if path and path.exists():
|
||||
files = SystemUtils.list_files(path, settings.RMT_MEDIAEXT)
|
||||
if not files:
|
||||
logger.warn(f"删除残留文件夹:{path}")
|
||||
shutil.rmtree(path, ignore_errors=True)
|
||||
|
||||
def remove_torrents(self, hashs: Union[str, list], delete_file: bool = True,
|
||||
downloader: str = None) -> Optional[bool]:
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import Set, Tuple, Optional, Union, List
|
||||
|
||||
@@ -14,7 +13,6 @@ from app.modules.transmission.transmission import Transmission
|
||||
from app.schemas import TransferTorrent, DownloadingTorrent
|
||||
from app.schemas.types import TorrentStatus, ModuleType
|
||||
from app.utils.string import StringUtils
|
||||
from app.utils.system import SystemUtils
|
||||
|
||||
|
||||
class TransmissionModule(_ModuleBase, _DownloaderBase[Transmission]):
|
||||
@@ -256,14 +254,11 @@ class TransmissionModule(_ModuleBase, _DownloaderBase[Transmission]):
|
||||
return None
|
||||
return ret_torrents
|
||||
|
||||
def transfer_completed(self, hashs: str, path: Path = None,
|
||||
downloader: str = None, transfer_type: str = None) -> None:
|
||||
def transfer_completed(self, hashs: str, downloader: str = None) -> None:
|
||||
"""
|
||||
转移完成后的处理
|
||||
:param hashs: 种子Hash
|
||||
:param path: 源目录
|
||||
:param downloader: 下载器
|
||||
:param transfer_type: 整理方式
|
||||
"""
|
||||
# 获取下载器
|
||||
server: Transmission = self.get_instance(downloader)
|
||||
@@ -277,16 +272,6 @@ class TransmissionModule(_ModuleBase, _DownloaderBase[Transmission]):
|
||||
else:
|
||||
tags = ['已整理']
|
||||
server.set_torrent_tag(ids=hashs, tags=tags)
|
||||
# 移动模式删除种子
|
||||
if transfer_type and transfer_type in ["move"]:
|
||||
if self.remove_torrents(hashs):
|
||||
logger.info(f"移动模式删除种子成功:{hashs} ")
|
||||
# 删除本地残留文件
|
||||
if path and path.exists():
|
||||
files = SystemUtils.list_files(path, settings.RMT_MEDIAEXT)
|
||||
if not files:
|
||||
logger.warn(f"删除残留文件夹:{path}")
|
||||
shutil.rmtree(path, ignore_errors=True)
|
||||
|
||||
def remove_torrents(self, hashs: Union[str, list], delete_file: bool = True,
|
||||
downloader: str = None) -> Optional[bool]:
|
||||
|
||||
Reference in New Issue
Block a user