test for format error

This commit is contained in:
Antonio J. Delgado 2025-06-20 23:51:56 +02:00
parent 795a9d892d
commit c5ede0c21f

View file

@ -324,6 +324,31 @@ class GetYoutubeVideos:
}
)
except yt_dlp.utils.DownloadError as error:
if 'Requested format is not available' in f"{error}":
ydl_opts['format'] = 'bestvideo+bestaudio[ext=m4a]/best'
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",
self.selected_proxy,