mirror of
https://github.com/THIS-IS-NOT-A-BACKUP/zspotify.git
synced 2024-12-01 20:13:56 +01:00
added switch to not send too much requests
This commit is contained in:
parent
1120592f0f
commit
0d553243d2
@ -43,17 +43,23 @@ def get_song_info(song_id) -> Tuple[List[str], List[str], str, str, Any, Any, An
|
|||||||
try:
|
try:
|
||||||
artists = []
|
artists = []
|
||||||
genres = []
|
genres = []
|
||||||
|
genreRetrieved = False
|
||||||
for data in info[TRACKS][0][ARTISTS]:
|
for data in info[TRACKS][0][ARTISTS]:
|
||||||
artists.append(data[NAME])
|
artists.append(data[NAME])
|
||||||
# query artist genres via href, which will be the api url
|
|
||||||
(raw, artistInfo) = ZSpotify.invoke_url(f'{data["href"]}')
|
if not genreRetrieved:
|
||||||
if ZSpotify.CONFIG.get_allGenres() and len(artistInfo[GENRES]) > 0:
|
# query artist genres via href, which will be the api url
|
||||||
for genre in artistInfo[GENRES]:
|
(raw, artistInfo) = ZSpotify.invoke_url(f'{data["href"]}')
|
||||||
genres.append(genre)
|
if ZSpotify.CONFIG.get_allGenres() and len(artistInfo[GENRES]) > 0:
|
||||||
elif len(artistInfo[GENRES]) > 0:
|
genreRetrieved = False
|
||||||
genres.append(artistInfo[GENRES][0])
|
for genre in artistInfo[GENRES]:
|
||||||
else:
|
genres.append(genre)
|
||||||
genres.append('')
|
elif len(artistInfo[GENRES]) > 0:
|
||||||
|
genres.append(artistInfo[GENRES][0])
|
||||||
|
genreRetrieved = True
|
||||||
|
else:
|
||||||
|
genres.append('')
|
||||||
|
genreRetrieved = True
|
||||||
album_name = info[TRACKS][0][ALBUM][NAME]
|
album_name = info[TRACKS][0][ALBUM][NAME]
|
||||||
name = info[TRACKS][0][NAME]
|
name = info[TRACKS][0][NAME]
|
||||||
image_url = info[TRACKS][0][ALBUM][IMAGES][0][URL]
|
image_url = info[TRACKS][0][ALBUM][IMAGES][0][URL]
|
||||||
|
Loading…
Reference in New Issue
Block a user