From 565d7fd44c737a08b90ff8e0c27b230c51a9fb1b Mon Sep 17 00:00:00 2001 From: Mavaddat Javid <5055400+mavaddat@users.noreply.github.com> Date: Mon, 24 Feb 2025 12:17:10 -0500 Subject: [PATCH] Except YTMusicUserError in auth.py fixes #110 (#111) Add exceptions thrown by `ytmusicapi` --- ytmusic_deleter/auth.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ytmusic_deleter/auth.py b/ytmusic_deleter/auth.py index 766c9ab..9521b23 100644 --- a/ytmusic_deleter/auth.py +++ b/ytmusic_deleter/auth.py @@ -4,6 +4,7 @@ import ytmusicapi from ytmusicapi import YTMusic +from ytmusicapi.exceptions import YTMusicUserError from . import common as const @@ -23,7 +24,7 @@ def ensure_auth(credential_dir, oauth) -> YTMusic: logging.info(f"Attempting authentication with: {auth_file_path}") yt_auth = YTMusic(auth_file_path) logging.info(f'Authenticated with: {auth_file_path}"') - except JSONDecodeError: + except (JSONDecodeError, YTMusicUserError, FileNotFoundError): logging.info(f"Creating file: {auth_file_name}") if oauth: ytmusicapi.setup_oauth(filepath=auth_file_path, open_browser=True)