Skip to content

Commit

Permalink
Except YTMusicUserError in auth.py fixes #110 (#111)
Browse files Browse the repository at this point in the history
Add exceptions thrown by `ytmusicapi`
  • Loading branch information
mavaddat authored Feb 24, 2025
1 parent c86fc1c commit 565d7fd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ytmusic_deleter/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import ytmusicapi
from ytmusicapi import YTMusic
from ytmusicapi.exceptions import YTMusicUserError

from . import common as const

Expand All @@ -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)
Expand Down

0 comments on commit 565d7fd

Please sign in to comment.