mirror of
https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
synced 2025-07-21 23:52:42 +00:00
Added Artist String Id in regex_input_for_urls
This commit is contained in:
parent
2325e98ccc
commit
822b696dc4
19
zspotify.py
19
zspotify.py
@ -141,7 +141,7 @@ def client():
|
|||||||
else:
|
else:
|
||||||
search_text = input("Enter search or URL: ")
|
search_text = input("Enter search or URL: ")
|
||||||
|
|
||||||
track_id_str, album_id_str, playlist_id_str, episode_id_str = regex_input_for_urls(
|
track_id_str, album_id_str, playlist_id_str, episode_id_str, artist_id_str = regex_input_for_urls(
|
||||||
search_text)
|
search_text)
|
||||||
|
|
||||||
if track_id_str is not None:
|
if track_id_str is not None:
|
||||||
@ -191,6 +191,13 @@ def regex_input_for_urls(search_input):
|
|||||||
search_input,
|
search_input,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
artist_uri_search = re.search(
|
||||||
|
r"^spotify:artist:(?P<ArtistID>[0-9a-zA-Z]{22})$", search_input)
|
||||||
|
artist_url_search = re.search(
|
||||||
|
r"^(https?://)?open\.spotify\.com/artist/(?P<ArtistID>[0-9a-zA-Z]{22})(\?si=.+?)?$",
|
||||||
|
search_input,
|
||||||
|
)
|
||||||
|
|
||||||
if track_uri_search is not None or track_url_search is not None:
|
if track_uri_search is not None or track_url_search is not None:
|
||||||
track_id_str = (track_uri_search
|
track_id_str = (track_uri_search
|
||||||
if track_uri_search is not None else
|
if track_uri_search is not None else
|
||||||
@ -219,7 +226,14 @@ def regex_input_for_urls(search_input):
|
|||||||
else:
|
else:
|
||||||
episode_id_str = None
|
episode_id_str = None
|
||||||
|
|
||||||
return track_id_str, album_id_str, playlist_id_str, episode_id_str
|
if artist_uri_search is not None or artist_url_search is not None:
|
||||||
|
artist_id_str = (artist_uri_search
|
||||||
|
if artist_uri_search is not None else
|
||||||
|
artist_url_search).group("ArtistID")
|
||||||
|
else:
|
||||||
|
artist_id_str = None
|
||||||
|
|
||||||
|
return track_id_str, album_id_str, playlist_id_str, episode_id_str, artist_id_str
|
||||||
|
|
||||||
|
|
||||||
def get_episode_info(episode_id_str):
|
def get_episode_info(episode_id_str):
|
||||||
@ -494,7 +508,6 @@ def get_album_name(access_token, album_id):
|
|||||||
f'https://api.spotify.com/v1/albums/{album_id}', headers=headers).json()
|
f'https://api.spotify.com/v1/albums/{album_id}', headers=headers).json()
|
||||||
return resp['artists'][0]['name'], sanitize_data(resp['name'])
|
return resp['artists'][0]['name'], sanitize_data(resp['name'])
|
||||||
|
|
||||||
|
|
||||||
# Extra functions directly related to our saved tracks
|
# Extra functions directly related to our saved tracks
|
||||||
def get_saved_tracks(access_token):
|
def get_saved_tracks(access_token):
|
||||||
""" Returns user's saved tracks """
|
""" Returns user's saved tracks """
|
||||||
|
Loading…
x
Reference in New Issue
Block a user