From f7f13f8dc7172aaedeed118801e247ca610a53dd Mon Sep 17 00:00:00 2001 From: Rafael Moraes <50295204+glomatico@users.noreply.github.com> Date: Thu, 26 Feb 2026 14:41:19 -0300 Subject: [PATCH] Handle exception items and separate download step --- votify/cli/cli.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/votify/cli/cli.py b/votify/cli/cli.py index ed6e6c3..be45f0d 100644 --- a/votify/cli/cli.py +++ b/votify/cli/cli.py @@ -165,12 +165,8 @@ async def main(config: CliConfig): ) try: item = await download_queue.__anext__() - media_title = item.media.media_metadata["name"] - logger.info(download_queue_progress + f' Downloading "{media_title}"') - - await downloader.download(item) - - await asyncio.sleep(config.wait_interval) + if isinstance(item, BaseException): + raise item except StopAsyncIteration: break except VotifyUrlParseException as e: @@ -183,6 +179,26 @@ async def main(config: CliConfig): logger.warning( download_queue_progress + f' Skipping "{media_title}": {str(e)}' ) + download_index += 1 + continue + except Exception as e: + error_count += 1 + logger.error( + download_queue_progress + f" Error fetching media: {str(e)}", + exc_info=not config.no_exceptions, + ) + download_index += 1 + continue + + try: + media_title = item.media.media_metadata["name"] + logger.info(download_queue_progress + f' Downloading "{media_title}"') + + await downloader.download(item) + + await asyncio.sleep(config.wait_interval) + except StopAsyncIteration: + break except VotifyDownloaderException as e: media_title = ( item.media.media_metadata["name"] if item else "Unknown Title"