From c55203474bc8dd513ef06582e75e744ceaaf6c21 Mon Sep 17 00:00:00 2001 From: Variet Agent Date: Wed, 18 Mar 2026 21:14:38 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20NC=20=EA=B2=80=EC=83=89=20PROPFIND=20?= =?UTF-8?q?=ED=8F=B4=EB=B0=B1=20+=20=EC=9E=90=EB=A7=89=20=EC=A4=91?= =?UTF-8?q?=EB=B3=B5=20=EC=8A=A4=ED=82=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - nc_files.py: WebDAV SEARCH 501 시 PROPFIND depth=99 + 로컬 필터 폴백 - subtitle_downloader.py: download_file에 기존 파일 존재 체크 추가 (이미 있으면 스킵) --- tools/nc_files.py | 17 +++++++++++++++++ tools/subtitle_downloader.py | 7 +++++++ 2 files changed, 24 insertions(+) diff --git a/tools/nc_files.py b/tools/nc_files.py index d71c0b8..03c1398 100644 --- a/tools/nc_files.py +++ b/tools/nc_files.py @@ -102,7 +102,24 @@ class NCFilesClient: Returns: 매칭된 NCFile 리스트 """ + # 1차: WebDAV SEARCH 시도 results = await self.nc.webdav_search(query) + + # 2차: SEARCH 실패 시 (501 등) PROPFIND로 전체 목록 → 로컬 필터 + if not results: + logger.info(f"WebDAV SEARCH 미지원, PROPFIND 폴백 사용: '{query}'") + try: + dav_path = f"files/{self.nc.username}/" + all_files = await self.nc.webdav_propfind(dav_path, depth=99) + query_lower = query.lower().lstrip(".") + results = [ + f for f in all_files[1:] # 첫 번째는 루트 + if query_lower in f.get("name", "").lower() + or query_lower in f.get("content_type", "").lower() + ] + except Exception as e: + logger.warning(f"PROPFIND 폴백 실패: {e}") + files = [self._to_ncfile(r) for r in results] # 디렉토리보다 파일 우선, 최신순 files.sort(key=lambda f: (f.is_dir, f.name)) diff --git a/tools/subtitle_downloader.py b/tools/subtitle_downloader.py index e39aa35..385978d 100644 --- a/tools/subtitle_downloader.py +++ b/tools/subtitle_downloader.py @@ -252,6 +252,13 @@ class SubtitleDownloader: target_dir = Path(save_dir) if save_dir else self.download_dir target_dir.mkdir(parents=True, exist_ok=True) + # 이미 같은 파일명이 존재하면 스킵 + existing = target_dir / sub.filename + if existing.exists() and existing.stat().st_size > 0: + logger.info(f"자막 이미 존재, 스킵: {existing}") + sub.local_path = str(existing) + return str(existing) + headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36", }