mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-08-29 12:06:51 +08:00
refactor: isolate transfer file item construction
This commit is contained in:
+14
-9
@@ -1416,15 +1416,7 @@ class TransferChain(FileFilterMixin, ScrapeBatchMixin, EpisodeFormatMixin, Histo
|
||||
|
||||
# 执行异步整理,匹配源目录
|
||||
self.do_transfer(
|
||||
fileitem=FileItem(
|
||||
storage="local",
|
||||
path=file_path.as_posix()
|
||||
+ ("/" if file_path.is_dir() else ""),
|
||||
type="dir" if not file_path.is_file() else "file",
|
||||
name=file_path.name,
|
||||
size=file_path.stat().st_size,
|
||||
extension=file_path.suffix.lstrip("."),
|
||||
),
|
||||
fileitem=self._build_transfer_fileitem(torrent),
|
||||
mediainfo=mediainfo,
|
||||
mtype=mtype,
|
||||
downloader=torrent.downloader,
|
||||
@@ -1443,6 +1435,19 @@ class TransferChain(FileFilterMixin, ScrapeBatchMixin, EpisodeFormatMixin, Histo
|
||||
|
||||
return True
|
||||
|
||||
@staticmethod
|
||||
def _build_transfer_fileitem(torrent: TorrentInfo) -> FileItem:
|
||||
"""把下载器任务路径转换为整理链使用的本地文件项。"""
|
||||
file_path = torrent.path
|
||||
return FileItem(
|
||||
storage="local",
|
||||
path=file_path.as_posix() + ("/" if file_path.is_dir() else ""),
|
||||
type="dir" if not file_path.is_file() else "file",
|
||||
name=file_path.name,
|
||||
size=file_path.stat().st_size,
|
||||
extension=file_path.suffix.lstrip("."),
|
||||
)
|
||||
|
||||
def __get_trans_fileitems(
|
||||
self,
|
||||
fileitem: FileItem,
|
||||
|
||||
Reference in New Issue
Block a user