mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-09-05 15:38:19 +08:00
feat: TransferRename 事件增加 source_path 源文件路径参数
在智能重命名事件中传递源文件路径,便于插件在重命名时获取待整理文件的原始路径信息。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
jxxghp
co-authored by
Claude Opus 4.6
parent
388afa8d3c
commit
60ac901c6c
@@ -129,7 +129,8 @@ class TransHandler:
|
|||||||
path=target_path,
|
path=target_path,
|
||||||
template_string=rename_format,
|
template_string=rename_format,
|
||||||
rename_dict=self.get_naming_dict(meta=in_meta,
|
rename_dict=self.get_naming_dict(meta=in_meta,
|
||||||
mediainfo=mediainfo)
|
mediainfo=mediainfo),
|
||||||
|
source_path=fileitem.path
|
||||||
)
|
)
|
||||||
new_path = DirectoryHelper.get_media_root_path(
|
new_path = DirectoryHelper.get_media_root_path(
|
||||||
rename_format, rename_path=new_path
|
rename_format, rename_path=new_path
|
||||||
@@ -218,7 +219,8 @@ class TransHandler:
|
|||||||
mediainfo=mediainfo,
|
mediainfo=mediainfo,
|
||||||
episodes_info=episodes_info,
|
episodes_info=episodes_info,
|
||||||
file_ext=f".{fileitem.extension}"
|
file_ext=f".{fileitem.extension}"
|
||||||
)
|
),
|
||||||
|
source_path=fileitem.path
|
||||||
)
|
)
|
||||||
|
|
||||||
# 针对字幕文件,文件名中补充额外标识信息
|
# 针对字幕文件,文件名中补充额外标识信息
|
||||||
@@ -814,12 +816,14 @@ class TransHandler:
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_rename_path(template_string: str, rename_dict: dict, path: Path = None) -> Path:
|
def get_rename_path(template_string: str, rename_dict: dict,
|
||||||
|
path: Path = None, source_path: str = None) -> Path:
|
||||||
"""
|
"""
|
||||||
生成重命名后的完整路径,支持智能重命名事件
|
生成重命名后的完整路径,支持智能重命名事件
|
||||||
:param template_string: Jinja2 模板字符串
|
:param template_string: Jinja2 模板字符串
|
||||||
:param rename_dict: 渲染上下文,用于替换模板中的变量
|
:param rename_dict: 渲染上下文,用于替换模板中的变量
|
||||||
:param path: 可选的基础路径,如果提供,将在其基础上拼接生成的路径
|
:param path: 可选的基础路径,如果提供,将在其基础上拼接生成的路径
|
||||||
|
:param source_path: 源文件路径,即待整理的文件路径
|
||||||
:return: 生成的完整路径
|
:return: 生成的完整路径
|
||||||
"""
|
"""
|
||||||
# 创建jinja2模板对象
|
# 创建jinja2模板对象
|
||||||
@@ -833,7 +837,8 @@ class TransHandler:
|
|||||||
template_string=template_string,
|
template_string=template_string,
|
||||||
rename_dict=rename_dict,
|
rename_dict=rename_dict,
|
||||||
render_str=render_str,
|
render_str=render_str,
|
||||||
path=path
|
path=path,
|
||||||
|
source_path=source_path
|
||||||
)
|
)
|
||||||
event = eventmanager.send_event(ChainEventType.TransferRename, event_data)
|
event = eventmanager.send_event(ChainEventType.TransferRename, event_data)
|
||||||
# 检查事件返回的结果
|
# 检查事件返回的结果
|
||||||
|
|||||||
@@ -168,6 +168,7 @@ class TransferRenameEventData(ChainEventData):
|
|||||||
rename_dict (dict): 渲染上下文
|
rename_dict (dict): 渲染上下文
|
||||||
render_str (str): 渲染生成的字符串
|
render_str (str): 渲染生成的字符串
|
||||||
path (Optional[Path]): 当前文件的目标路径
|
path (Optional[Path]): 当前文件的目标路径
|
||||||
|
source_path (Optional[str]): 源文件路径,即待整理的文件路径
|
||||||
|
|
||||||
# 输出参数
|
# 输出参数
|
||||||
updated (bool): 是否已更新,默认值为 False
|
updated (bool): 是否已更新,默认值为 False
|
||||||
@@ -179,6 +180,7 @@ class TransferRenameEventData(ChainEventData):
|
|||||||
rename_dict: Dict[str, Any] = Field(..., description="渲染上下文")
|
rename_dict: Dict[str, Any] = Field(..., description="渲染上下文")
|
||||||
path: Optional[Path] = Field(None, description="文件的目标路径")
|
path: Optional[Path] = Field(None, description="文件的目标路径")
|
||||||
render_str: str = Field(..., description="渲染生成的字符串")
|
render_str: str = Field(..., description="渲染生成的字符串")
|
||||||
|
source_path: Optional[str] = Field(None, description="源文件路径,即待整理的文件路径")
|
||||||
|
|
||||||
# 输出参数
|
# 输出参数
|
||||||
updated: bool = Field(default=False, description="是否已更新")
|
updated: bool = Field(default=False, description="是否已更新")
|
||||||
|
|||||||
Reference in New Issue
Block a user