add check and fix result

This commit is contained in:
Antonio J. Delgado 2025-08-10 12:13:12 +03:00
parent 01c5e8bbd6
commit c89ed8ef72

View file

@ -378,8 +378,8 @@ class GetYoutubeVideos:
if self.selected_proxy != '':
ydl_opts['proxy'] = self.selected_proxy
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
result = 'starting'
while result != 'downloaded' and result != 'error':
download_result = 'starting'
while 'downloaded' not in download_result and 'error' not in download_result:
self._log.debug(
f"Download status: {result}"
)
@ -396,7 +396,7 @@ class GetYoutubeVideos:
'video_info': video_info,
}
)
result = 'downloaded'
download_result = 'downloaded'
self.summary['downloaded_videos_titles'].append(
video_info.get('title', '?')
)
@ -407,7 +407,7 @@ class GetYoutubeVideos:
"Requested format is not available, trying best format."
)
ydl_opts['format'] = 'bestvideo+bestaudio[ext=m4a]/best'
result = 'retrying (format error)'
download_result = 'retrying (format error)'
elif 'Unable to download video subtitles for' in f"{error}":
regex = r"Unable to download video subtitles for '([a-z]*)'"
subtitle_match = re.search(
@ -419,11 +419,18 @@ class GetYoutubeVideos:
f"Error finding subtitle that failed in error string. Regex: r\"{regex}\". Error string: \"{error}\""
)
else:
self._log.warning(
f"The language '{subtitle_match.group(1)}' is not available, removing from list: {', '.join(ydl_opts['subtitleslangs'])}"
)
ydl_opts['subtitleslangs'].remove(subtitle_match.group(1))
result = 'retrying (subtitles error)'
language = subtitle_match.group(1)
if language in ydl_opts['subtitleslangs']:
self._log.warning(
f"The language '{language}' is not available, removing from list: {', '.join(ydl_opts['subtitleslangs'])}"
)
ydl_opts['subtitleslangs'].remove(language)
download_result = 'retrying (subtitles error)'
else:
self._log.error(
f"The language '{language}' is not available, but is not present in list: {', '.join(ydl_opts['subtitleslangs'])}"
)
download_result = 'error'
else:
self._log.error(
"Error getting video with proxy '%s'. %s",
@ -431,7 +438,7 @@ class GetYoutubeVideos:
error
)
self.summary['videos_with_error'] += 1
result = error
download_result = error
continue
else:
self._log.debug(