Forked from FGRibreau/suno-download-all-songs.js
Last active
November 14, 2024 14:21
-
-
Save gadelkareem/8d807a82845e045070faded8582c1e96 to your computer and use it in GitHub Desktop.
Download all Suno (app.suno.ai) songs displayed on a page
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// open your javascript console and paste this | |
copy([...$('[role="grid"]')[Object.keys($('[role="grid"]')).filter(x => x.startsWith('__reactProps'))[0]].children[0].props.values[0][1].collection] | |
.filter(x => x.value.clip.clip.audio_url || x.value.clip.clip.video_url) | |
.map(x => { | |
const title = x.value.clip.clip.title.trim() || x.value.clip.clip.id ; | |
const audio = x.value.clip.clip.audio_url ? `${title}.mp3|${x.value.clip.clip.audio_url}` : ''; | |
const video = x.value.clip.clip.video_url ? `${title}.mp4|${x.value.clip.clip.video_url}` : ''; | |
return [audio, video].filter(Boolean).join("\n"); | |
}) | |
.join("\n") | |
) | |
// now you have a list of mp3 urls directly in your clipboard that you can pass to wget or a url downloader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: python suno-downloader.py <path-to-js-output-file> | |
import requests | |
import os | |
import sys | |
def download_file(url, filename): | |
response = requests.get(url, stream=True) | |
response.raise_for_status() | |
with open(filename, 'wb') as file: | |
for chunk in response.iter_content(chunk_size=8192): | |
file.write(chunk) | |
def main(): | |
js_file = sys.argv[1] | |
with open(js_file, 'r') as file: | |
js_output = file.read() | |
# Split the input string into individual file entries | |
file_entries = js_output.split("\n") | |
# Create a directory to store the downloaded files | |
if not os.path.exists('downloads'): | |
os.makedirs('downloads') | |
names = () | |
# Process each file entry | |
for entry in file_entries: | |
try: | |
i = 0 | |
print(f"Processing: {entry}") | |
filename, url = entry.split('|') | |
print(f"Downloading: {filename}") | |
org_name = os.path.splitext(filename)[0] | |
ext = os.path.splitext(filename)[1] | |
# make sure the file name is unique | |
while filename in names: | |
i += 1 | |
name = org_name + "_" + str(i) | |
filename = name + ext | |
names = names + (filename,) | |
download_file(url, os.path.join('downloads', filename)) | |
print(f"Successfully downloaded: {filename}") | |
except Exception as e: | |
print(f"Failed to download {entry}. Error: {str(e)}") | |
print("Download process completed.") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment