From eb8b286b3e90dc2ab9add603b9915d13b91fdcbe Mon Sep 17 00:00:00 2001 From: wengchaoxi Date: Wed, 27 Mar 2024 12:17:33 +0800 Subject: [PATCH 1/2] feat: support auto import of cookie from `.env` --- .env.example | 1 + README.md | 2 +- requirements.txt | 3 ++- suno/suno.py | 3 +++ 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8171b88 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +SUNO_COOKIE='' diff --git a/README.md b/README.md index 5b0acef..908a825 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ About High quality songs generation by https://www.suno.ai/. Reverse engineered - Clone this REPO -> `git clone https://github.com/yihong0618/SunoSongsCreator.git` - XHR find cookie in this url -> https://clerk.suno.ai/v1/client?_clerk_js_version=4.70.5 - Copy the cookie. -- Export SUNO_COOKIE='xxxxx'. +- You can import the cookie using `export SUNO_COOKIE=''` or rename `.env.example` to `.env` and fill in `SUNO_COOKIE`. ## Usage diff --git a/requirements.txt b/requirements.txt index a1a8e72..84313e2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ curl_cffi fake-useragent requests -rich \ No newline at end of file +rich +python-dotenv diff --git a/suno/suno.py b/suno/suno.py index 69cf713..e34ddae 100644 --- a/suno/suno.py +++ b/suno/suno.py @@ -13,6 +13,9 @@ from requests import get as rget from rich import print +from dotenv import load_dotenv, find_dotenv +_ = load_dotenv(find_dotenv()) + ua = UserAgent(browsers=["edge"]) get_session_url = "https://clerk.suno.ai/v1/client?_clerk_js_version=4.70.5" From abe458196733c27ce473ad9ab91472deb67c2075 Mon Sep 17 00:00:00 2001 From: wengchaoxi Date: Wed, 27 Mar 2024 12:48:26 +0800 Subject: [PATCH 2/2] chore: fix typo --- setup.py | 1 + suno/suno.py | 1 + 2 files changed, 2 insertions(+) diff --git a/setup.py b/setup.py index 4a60a66..af20412 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,7 @@ "requests", "fake-useragent", "rich", + "python-dotenv", ], packages=find_packages(), long_description=open("README.md", encoding="utf-8").read(), diff --git a/suno/suno.py b/suno/suno.py index e34ddae..1da04a4 100644 --- a/suno/suno.py +++ b/suno/suno.py @@ -14,6 +14,7 @@ from rich import print from dotenv import load_dotenv, find_dotenv + _ = load_dotenv(find_dotenv()) ua = UserAgent(browsers=["edge"])