debug: Add detailed logging to _predict_filepath for file matching

This commit is contained in:
2026-01-02 17:09:43 +09:00
parent 805464cb25
commit 55e7041009
2 changed files with 24 additions and 11 deletions

View File

@@ -1,5 +1,5 @@
title: "애니 다운로더" title: "애니 다운로더"
version: "0.4.9" version: "0.4.10"
package_name: "anime_downloader" package_name: "anime_downloader"
developer: "projectdx" developer: "projectdx"
description: "anime downloader" description: "anime downloader"

View File

@@ -1285,6 +1285,8 @@ class LogicAniLife(AnimeModuleBase):
if not title: if not title:
return None return None
logger.debug(f"[EarlyCheck] Input title: {title}")
# Parse title pattern: "제목 N기 M화" or "제목 M화" # Parse title pattern: "제목 N기 M화" or "제목 M화"
match = re.compile( match = re.compile(
r"(?P<title>.*?)\s*((?P<season>\d+)기)?\s*((?P<epi_no>\d+)화)" r"(?P<title>.*?)\s*((?P<season>\d+)기)?\s*((?P<epi_no>\d+)화)"
@@ -1295,49 +1297,60 @@ class LogicAniLife(AnimeModuleBase):
season = int(match.group("season")) if match.group("season") else 1 season = int(match.group("season")) if match.group("season") else 1
epi_no = int(match.group("epi_no")) epi_no = int(match.group("epi_no"))
# Sanitize title part only (not the glob pattern)
content_title_clean = AniUtil.change_text_for_use_filename(content_title)
# Use glob pattern for quality: *-AL.mp4 matches any quality # Use glob pattern for quality: *-AL.mp4 matches any quality
filename_pattern = "%s.S%sE%s.*-AL.mp4" % ( filename_pattern = "%s.S%sE%s.*-AL.mp4" % (
content_title, content_title_clean,
"0%s" % season if season < 10 else season, "0%s" % season if season < 10 else season,
"0%s" % epi_no if epi_no < 10 else epi_no, "0%s" % epi_no if epi_no < 10 else epi_no,
) )
logger.debug(f"[EarlyCheck] Parsed: title='{content_title_clean}', S{season}E{epi_no}")
else: else:
# Fallback pattern for non-standard titles # Fallback pattern for non-standard titles
filename_pattern = "%s.*-AL.mp4" % title title_clean = AniUtil.change_text_for_use_filename(title)
filename_pattern = "%s.*-AL.mp4" % title_clean
# Sanitize pattern (but keep glob wildcards) logger.debug(f"[EarlyCheck] No match, fallback pattern")
filename_pattern = AniUtil.change_text_for_use_filename(filename_pattern)
# Get save path # Get save path
savepath = P.ModelSetting.get("anilife_download_path") savepath = P.ModelSetting.get("anilife_download_path")
if not savepath: if not savepath:
logger.debug(f"[EarlyCheck] No savepath configured")
return None return None
# Check auto folder option # Check auto folder option
if P.ModelSetting.get_bool("anilife_auto_make_folder"): if P.ModelSetting.get_bool("anilife_auto_make_folder"):
day = episode_info.get("day", "") day = episode_info.get("day", "")
if "완결" in day: if "완결" in day:
folder_name = "%s %s" % (content_title if match else title, "완결") folder_name = "%s %s" % (content_title_clean if match else AniUtil.change_text_for_use_filename(title), "완결")
else: else:
folder_name = content_title if match else title folder_name = content_title_clean if match else AniUtil.change_text_for_use_filename(title)
folder_name = AniUtil.change_text_for_use_filename(folder_name)
savepath = os.path.join(savepath, folder_name) savepath = os.path.join(savepath, folder_name)
# Use glob to find any matching file # Use glob to find any matching file
full_pattern = os.path.join(savepath, filename_pattern) full_pattern = os.path.join(savepath, filename_pattern)
logger.info(f"[EarlyCheck] Glob pattern: {full_pattern}")
matching_files = glob.glob(full_pattern) matching_files = glob.glob(full_pattern)
logger.info(f"[EarlyCheck] Matching files: {matching_files}")
if matching_files: if matching_files:
# Return first matching file # Return first matching file
logger.debug(f"Found existing file: {matching_files[0]}") logger.info(f"[EarlyCheck] Found existing file: {matching_files[0]}")
return matching_files[0] return matching_files[0]
logger.debug(f"[EarlyCheck] No matching file found")
return None return None
except Exception as e: except Exception as e:
logger.debug(f"_predict_filepath error: {e}") logger.error(f"[EarlyCheck] _predict_filepath error: {e}")
import traceback
logger.error(traceback.format_exc())
return None return None
def is_exist(self, info): def is_exist(self, info):
for e in self.queue.entity_list: for e in self.queue.entity_list:
if e.info["_id"] == info["_id"]: if e.info["_id"] == info["_id"]: