From b25a2ad80a0cbaa5e349c8fde42da2152ec22d04 Mon Sep 17 00:00:00 2001 From: TonyBlu Date: Mon, 25 May 2026 21:23:06 +0800 Subject: [PATCH] fix(captions): use getattr for filename check in _post_download_cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit DownloadInfo doesn't have a 'filename' attribute by default — it's only set dynamically in update_status when a 'downloaded' status is received. When captions are silently skipped by yt-dlp (no matching language), the 'downloaded' status is never emitted, so 'filename' doesn't exist on the object at all. Using getattr(download.info, 'filename', None) instead of direct attribute access prevents AttributeError. --- app/ytdl.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/ytdl.py b/app/ytdl.py index 65656f3..257d581 100644 --- a/app/ytdl.py +++ b/app/ytdl.py @@ -1019,7 +1019,7 @@ class DownloadQueue: # happen when the requested language (e.g. "en") is unavailable and # yt-dlp silently skips subtitle extraction without raising an # error. - if getattr(download.info, 'download_type', '') == 'captions' and not download.info.filename: + if getattr(download.info, 'download_type', '') == 'captions' and not getattr(download.info, 'filename', None): subtitle_files = getattr(download.info, 'subtitle_files', []) if not subtitle_files: log.warning( @@ -1034,7 +1034,7 @@ class DownloadQueue: ) # Thumbnail-only downloads that produced no image file should also # be reported as an error for the same reason. - elif getattr(download.info, 'download_type', '') == 'thumbnail' and not download.info.filename: + elif getattr(download.info, 'download_type', '') == 'thumbnail' and not getattr(download.info, 'filename', None): log.warning( f"Thumbnail download for \"{download.info.title}\" produced no file." )