1.5.0 • Published 1 year ago
scdl-api v1.5.0
SoundCloud API
📝Note
ID Jika Ada Bug, Silahkan Buat Issues
EN If there are bugs, please create Issues
📈 Highlights
- Private client id & oauth request
- Simple & easy to using
- 100% Safe
- No delay
⚙️Installation
⚙️ In Github
npm i github:RizzyFuzz/scdl-api
⚙️ In Npm
npm i scdl-api
🛠️ Require
const scdl = require("scdl-api");
📄 Get Metadata
await scdl.soundcloud("https://soundcloud.com/prodbyscythe/crucible-w-antikvng").then(console.log);
💾 Downloading a Song With node-id3 Tags
async function downloadSong(url) {
try {
const song = await scdl.soundcloud(url);
const streamUrl = ${song.media.stream_url}
;
const response = await axios.get(streamUrl, { responseType: "arraybuffer" });
const audioBuffer = Buffer.from(response.data);
//Convert audio to 360kbps
const ffmpeg = spawn("ffmpeg", [
"-i", "pipe:0",
"-f", "mp3",
"-ab", "360k",
"-"
]);
const filename = `${song.title}.mp3`;
ffmpeg.stdout.pipe(fs.createWriteStream(filename));
ffmpeg.stdin.write(audioBuffer);
ffmpeg.stdin.end();
ffmpeg.on("close", async (code) => {
if (code === 0) {
const tags = {
title: song.title,
artist: song.artist,
album: song.title,
year: song.created_at,
image: {
mime: "image/jpeg",
type: {
id: 3,
name: "front cover"
},
description: "SoundCloud album cover",
imageBuffer: await axios.get(song.artwork_url, { responseType: "arraybuffer" })
.then((res) => Buffer.from(res.data))
.catch((err) => console.error("Error downloading album art:", err))
}
};
const success = NodeID3.write(tags, filename);
if (success) {
console.log(`Finished writing song "${song.title}" to file "${filename}"!`);
} else {
console.error("Failed to write ID3 tags to file");
}
} else {
console.error(`FFmpeg process exited with code ${code}`);
}
});
} catch (err) { console.error(err); } }
downloadSong("https://soundcloud.com/prodbyscythe/crucible-w-antikvng");
</details>