From f6cbfadb700ae460b82b0b8a5ca72654e30bfbb5 Mon Sep 17 00:00:00 2001 From: Akimio521 Date: Fri, 21 Jun 2024 12:29:29 +0800 Subject: [PATCH] =?UTF-8?q?update(autofilm.py):=E4=BC=98=E5=8C=96=E4=B8=8B?= =?UTF-8?q?=E8=BD=BD=E6=96=87=E4=BB=B6=E9=80=BB=E8=BE=91=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- autofilm.py | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/autofilm.py b/autofilm.py index 8cb0c2b..0d70f7e 100644 --- a/autofilm.py +++ b/autofilm.py @@ -79,7 +79,7 @@ def run(self) -> None: alist_server_password: str = alist_server.get("password") alist_server_base_path: Optional[str] = alist_server.get("base_path") alist_server_token: Optional[str] = alist_server.get("token") - + alist_server_url = alist_server_url.rstrip("/") if alist_server_base_path == None or alist_server_base_path == "": alist_server_base_path = "/" @@ -179,25 +179,18 @@ async def _file_process( logging.debug( f"{file_output_path.name}创建成功,文件本地目录:{file_output_path.parent}" ) - elif alist_path_cls.name.lower().endswith(self.img_ext) and self.img: - file_output_path.parent.mkdir(parents=True, exist_ok=True) - async with session.get(file_download_url) as resp: - if resp.status == 200: - with file_output_path.open(mode="wb") as f: - f.write(await resp.read()) - logging.debug( - f"{file_output_path.name}下载成功,文件本地目录:{file_output_path.parent}" - ) - elif alist_path_cls.name.lower().endswith(self.subtitle_ext) and self.subtitle: - file_output_path.parent.mkdir(parents=True, exist_ok=True) - async with session.get(file_download_url) as resp: - if resp.status == 200: - with file_output_path.open(mode="wb") as f: - f.write(await resp.read()) - logging.debug( - f"{file_output_path.name}下载成功,文件本地目录:{file_output_path.parent}" - ) - elif alist_path_cls.name.lower().endswith("nfo") and self.nfo: + return + + if alist_path_cls.name.lower().endswith(self.img_ext) and not self.img: + return + elif ( + alist_path_cls.name.lower().endswith(self.subtitle_ext) + and not self.subtitle + ): + return + elif alist_path_cls.name.lower().endswith("nfo") and not self.nfo: + return + else: file_output_path.parent.mkdir(parents=True, exist_ok=True) async with session.get(file_download_url) as resp: if resp.status == 200: