From 1351efd08a89fdb9cec91a51cf39ee82d425c4b1 Mon Sep 17 00:00:00 2001 From: Jonas_Jones <91549607+J-onasJones@users.noreply.github.com> Date: Wed, 1 Nov 2023 21:40:32 +0100 Subject: [PATCH] Added artist link support --- discographymaker.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/discographymaker.py b/discographymaker.py index 332ac44..23c7ee1 100644 --- a/discographymaker.py +++ b/discographymaker.py @@ -19,7 +19,7 @@ def remove_duplicates(input_list: list) -> list: def getDiscographyArtist(sp: spotipy.Spotify, first = False): while True: if first: - user_artist_input = input("Input your first Artist (name or spotify ID). Enter other's when prompted next:\n") + user_artist_input = input("Input your first Artist (name, spotify ID or artist link). Enter other's when prompted next:\n") else: print("======================") user_artist_input = input("Input your next Artist (name or Spotify ID). Leave empty if all have been inputed\n") @@ -30,6 +30,11 @@ def getDiscographyArtist(sp: spotipy.Spotify, first = False): if len(user_artist_input) == 22: if input("Did you Enter an ID? [ENTER for Yes, No for treating your Input as a name]: ") == "": return user_artist_input + if len(user_artist_input) >= 54: + withoutlink = user_artist_input.replace("https://open.spotify.com/artist/", "") + if len(withoutlink) + 32 == len(user_artist_input): + print(withoutlink[0:22]) + return withoutlink[0:22] search_results = sp.search(q=user_artist_input, type='artist', limit=1) if search_results['artists']['items'][0]['name'] != user_artist_input: correct_input = input(" The Artist doesn't exist on Spotify. Did you mean \"" + search_results['artists']['items'][0]['name'] + "\" [ENTER for Yes, No for retry]: ")