diff --git a/setup.py b/setup.py index b7a809c..4a60a66 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name="suno_songs", - version="0.2.3", + version="0.2.4", author="yihong0618", author_email="zouzou0208@gmail.com", description="High quality image generation by ideogram.ai. Reverse engineered API.", diff --git a/suno/suno.py b/suno/suno.py index fe249c3..69cf713 100644 --- a/suno/suno.py +++ b/suno/suno.py @@ -96,31 +96,30 @@ def _fetch_songs_metadata(self, ids): id1, id2 = ids[:2] url = f"https://studio-api.suno.ai/api/feed/?ids={id1}%2C{id2}" response = self.session.get(url, impersonate=browser_version) - try: - data = response.json() - if type(data) == dict: - print(data) - data = [data] - self.now_data = data - except: - if response.json().get("detail", "") == "Unauthorized": + data = response.json() + if type(data) == dict: + if data.get("detail", "") == "Unauthorized": print("Token expired, renewing...") self.retry_time += 1 - if self.retry_time > 3: + if self.retry_time > 2: song_name, lyric = self._parse_lyrics(self.now_data[0]) self.song_info_dict["song_name"] = song_name self.song_info_dict["lyric"] = lyric self.song_info_dict["song_url"] = ( f"https://audiopipe.suno.ai/?item_id={id1}" ) - print("will sleep 45 and try to download") - time.sleep(45) + print("will sleep 30 and try to download") + time.sleep(30) # Done here return True self._renew() time.sleep(5) + return False + else: + data = [data] + # renew now data + self.now_data = data try: - for d in data: # only get one url for now # and early return