From 753336beeedb24ae514cd0fd4047ab82f4d330ed Mon Sep 17 00:00:00 2001 From: Rafael Moraes <50295204+glomatico@users.noreply.github.com> Date: Thu, 26 Feb 2026 20:33:10 -0300 Subject: [PATCH] Precompute media_title and move sleep to finally --- votify/cli/cli.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/votify/cli/cli.py b/votify/cli/cli.py index 99ed73c..7c0832a 100644 --- a/votify/cli/cli.py +++ b/votify/cli/cli.py @@ -197,17 +197,13 @@ async def main(config: CliConfig): download_index += 1 continue + media_title = item.media.media_metadata["name"] if item else "Unknown Title" + 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 Exception as e: - media_title = ( - item.media.media_metadata["name"] if item else "Unknown Title" - ) if isinstance(e, VotifyDownloaderException): logger.warning( download_queue_progress + f' Skipping "{media_title}": {str(e)}' @@ -220,5 +216,6 @@ async def main(config: CliConfig): ) finally: download_index += 1 + asyncio.sleep(config.wait_interval) logger.info(f"Finished with {error_count} error(s)")