Skip to content

Commit

Permalink
feat: Refactor code and update project metadata
Browse files Browse the repository at this point in the history
- Added a new key "song_url_list" to `song_info_dict` in the `SongsGen` class
- Removed the line that clears `song_info_dict["song_url_list"]` in the `_fetch_songs_metadata` method
  • Loading branch information
yihong0618 committed Apr 10, 2024
1 parent 5684769 commit 92534d4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="suno_songs",
version="0.5.0",
version="0.5.1",
author="yihong0618",
author_email="zouzou0208@gmail.com",
description="High quality songs generation by suno.ai. Reverse engineered API.",
Expand Down
3 changes: 2 additions & 1 deletion suno/suno.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(self, cookie: str) -> None:
self.retry_time = 0
# make the song_info_dict global since we can get the lyrics and song name first
self.song_info_dict = {}
self.song_info_dict["song_url_list"] = []
# now data
self.now_data = {}

Expand Down Expand Up @@ -142,7 +143,6 @@ def _parse_lyrics(self, data: dict) -> Tuple[str, str]:
return song_name, lyrics

def _fetch_songs_metadata(self, ids):
self.song_info_dict["song_url_list"] = []
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)
Expand Down Expand Up @@ -173,6 +173,7 @@ def _fetch_songs_metadata(self, ids):
# for support old api
self.song_info_dict["song_url"] = d.get("audio_url")
return True
return False
except Exception as e:
print(e)
# since we only get the music_id is ok
Expand Down

0 comments on commit 92534d4

Please sign in to comment.