pop out missing subtitle

This commit is contained in:
Antonio J. Delgado 2025-08-10 11:48:29 +03:00
parent 2d10853225
commit 50a252d3b7

View file

@ -419,6 +419,39 @@ class GetYoutubeVideos:
)
self.summary['videos_with_error'] += 1
break
elif 'Unable to download video subtitles for' in f"{error}":
subtitle_match = re.match(
r"Unable to download video subtitles for '([a-z]*)' ",
f"{error}"
)
if not subtitle_match:
self._log.error(
f"Error finding subtitle that failed in error string"
)
else:
ydl_opts['subtitleslangs'].pop(subtitle_match.group(1))
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
try:
uri=f"https://www.youtube.com/watch?v={video_id}"
return_code = ydl.download(uri)
self._process_download(
{
"return_code": return_code,
'info_dict': {
'id': video_id,
},
'filename': video_info.get('title', '?'),
'video_info': video_info,
}
)
except yt_dlp.utils.DownloadError as sub_error:
self._log.error(
"Error getting video with proxy '%s'. %s",
self.selected_proxy,
sub_error
)
self.summary['videos_with_error'] += 1
break
else:
self._log.error(
"Error getting video with proxy '%s'. %s",