diff --git a/spotify_to_ytmusic/spotify.py b/spotify_to_ytmusic/spotify.py index 100705b..9377da7 100644 --- a/spotify_to_ytmusic/spotify.py +++ b/spotify_to_ytmusic/spotify.py @@ -1,4 +1,5 @@ import html +import string from urllib.parse import urlparse import spotipy @@ -11,8 +12,18 @@ class Spotify: def __init__(self): settings = Settings() conf = settings["spotify"] + client_id = conf["client_id"] + + assert set(client_id).issubset( + string.hexdigits + ), f"Spotify client_id not set or invalid: {client_id}" + client_secret = conf["client_secret"] + assert set(client_secret).issubset( + string.hexdigits + ), f"Spotify client_secret not set or invalid: {client_secret}" + client_credentials_manager = SpotifyClientCredentials( - client_id=conf["client_id"], client_secret=conf["client_secret"] + client_id=client_id, client_secret=client_secret ) self.api = spotipy.Spotify(client_credentials_manager=client_credentials_manager) diff --git a/spotify_to_ytmusic/ytmusic.py b/spotify_to_ytmusic/ytmusic.py index ebe579d..ccd6d5c 100644 --- a/spotify_to_ytmusic/ytmusic.py +++ b/spotify_to_ytmusic/ytmusic.py @@ -13,7 +13,9 @@ class YTMusicTransfer: def __init__(self): settings = Settings() - self.api = YTMusic(settings["youtube"]["headers"], settings["youtube"]["user_id"]) + headers = settings["youtube"]["headers"] + assert headers.startswith("{"), "ytmusicapi headers not set or invalid" + self.api = YTMusic(headers, settings["youtube"]["user_id"]) def create_playlist(self, name, info, privacy="PRIVATE", tracks=None): return self.api.create_playlist(name, info, privacy, video_ids=tracks)