fix(captions): use getattr for filename check in _post_download_cleanup

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.
This commit is contained in:
TonyBlu 2026-05-25 21:23:06 +08:00
parent 36b397ae93
commit b25a2ad80a

View file

@ -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."
)