From 06957d318f97b6d565d32c0c1e4a7586cc952ced Mon Sep 17 00:00:00 2001 From: jxxghp Date: Sat, 12 Aug 2023 09:38:31 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E7=AB=99=E7=82=B9=E5=AD=97=E5=B9=95?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E5=AF=BC=E8=87=B4=E5=8D=95=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=BD=AC=E7=A7=BB=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/modules/subtitle/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/modules/subtitle/__init__.py b/app/modules/subtitle/__init__.py index 81f35b6b..4b14799c 100644 --- a/app/modules/subtitle/__init__.py +++ b/app/modules/subtitle/__init__.py @@ -50,18 +50,20 @@ class SubtitleModule(_ModuleBase): logger.info("开始从站点下载字幕:%s" % torrent.page_url) # 获取种子信息 folder_name, _ = TorrentHelper.get_torrent_info(torrent_path) - + # 下载目录,也可能是文件名 download_dir = download_dir / (folder_name or "") # 等待文件或者目录存在 - for _ in range(10): + for _ in range(30): if download_dir.exists(): break time.sleep(1) - # 目录不存在则创建目录 - if not download_dir.exists(): + # 目录仍然不存在,且是目录则创建目录 + if not download_dir.exists() \ + and download_dir.suffix not in settings.RMT_MEDIAEXT: download_dir.mkdir(parents=True, exist_ok=True) # 不是目录说明是单文件种子,直接使用下载目录 - if download_dir.is_file(): + if download_dir.is_file() \ + or download_dir.suffix in settings.RMT_MEDIAEXT: download_dir = download_dir.parent # 读取网站代码 request = RequestUtils(cookies=torrent.site_cookie, ua=torrent.site_ua)