diff --git a/package.v2.json b/package.v2.json index edc70ac..34cfe65 100644 --- a/package.v2.json +++ b/package.v2.json @@ -429,13 +429,13 @@ "name": "Strm重定向", "description": "重写Strm文件内容。", "labels": "云盘", - "version": "1.1", + "version": "1.2", "icon": "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/softlinkredirect.png", "author": "thsrite", "level": 1, "v2": true, "history": { - "v1.1": "支持解码URL重新写入Strm", + "v1.2": "支持解码URL重新写入Strm", "v1.0": "重写Strm文件内容" } }, diff --git a/plugins.v2/strmredirect/__init__.py b/plugins.v2/strmredirect/__init__.py index d3eb3b2..7b0d89d 100644 --- a/plugins.v2/strmredirect/__init__.py +++ b/plugins.v2/strmredirect/__init__.py @@ -16,7 +16,7 @@ class StrmRedirect(_PluginBase): # 插件图标 plugin_icon = "https://raw.githubusercontent.com/thsrite/MoviePilot-Plugins/main/icons/softlinkredirect.png" # 插件版本 - plugin_version = "1.1" + plugin_version = "1.2" # 插件作者 plugin_author = "thsrite" # 作者主页 @@ -44,7 +44,7 @@ class StrmRedirect(_PluginBase): self._origin_path = config.get("origin_path") self._redirect_path = config.get("redirect_path") - if self._onlyonce and self._strm_path and self._origin_path and self._redirect_path: + if self._onlyonce and self._strm_path and ((self._origin_path and self._redirect_path) or self._unquote): logger.info(f"{self._strm_path} Strm重定向开始 {self._origin_path} - {self._redirect_path}") self.update_strm(self._origin_path, self._redirect_path, self._strm_path) logger.info(f"{self._strm_path} Strm重定向完成") @@ -73,6 +73,10 @@ class StrmRedirect(_PluginBase): unencoded = self.find_unencoded_parts(strm_content) # 解码url unercoded_strm_content = urllib.parse.unquote(strm_content) + if self._unquote: + with open(str(file_path), 'w', encoding='utf-8') as file: + file.write(unercoded_strm_content) + logger.info(f"Unquote Strm: {strm_content} -> {unercoded_strm_content} success") if target_from and target_to: if str(unercoded_strm_content).startswith(target_from): strm_content = unercoded_strm_content.replace(target_from, target_to) @@ -88,13 +92,6 @@ class StrmRedirect(_PluginBase): file.write(strm_content) logger.info( f"Updated Strm: {unercoded_strm_content} -> {strm_content} success") - elif self._unquote: - with open(str(file_path), 'w', encoding='utf-8') as file: - file.write(unercoded_strm_content) - logger.info(f"Unquote Strm: {strm_content} -> {unercoded_strm_content} success") - else: - logger.info(f"No target_from or target_to or unquote, stop update") - return @staticmethod def find_unencoded_parts(input_string: str):