Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nechlophomeriaa/spotifydl

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nechlophomeriaa/spotifydl - npm Package Compare versions

Comparing version 1.0.25 to 1.0.26

4

dist/cjs/src/spotify.js

@@ -9,4 +9,4 @@ const { isUrl, tags2, tags, convertMs } = require("../function/index.js")

consumer: {
key: "9e1c5e192a8141c59b7e91f2848e6a9c",
secret: "78e2ece45fa446c98517d2cbb3271486"
key: "270eef8d162d4444a63e3a67227396ac",
secret: "4d198cd0de064e158e5e9d9028325fd3"
}

@@ -13,0 +13,0 @@ })

@@ -9,4 +9,4 @@ import { isUrl, tags2, tags, convertMs } from "../function/index.js"

consumer: {
key: "9e1c5e192a8141c59b7e91f2848e6a9c",
secret: "78e2ece45fa446c98517d2cbb3271486"
key: "270eef8d162d4444a63e3a67227396ac",
secret: "4d198cd0de064e158e5e9d9028325fd3"
}

@@ -46,61 +46,36 @@ })

async function downloads(url) {
if (!isUrl(url)) throw new Error("Please input Url");
if (!isUrl(url)) throw new Error("Please input Url")
if (url.includes("spotify.link")) {
const originalUrl = await getOriginalUrl(url);
const track = await axios.get(
`https://api.spotifydown.com/metadata/track/${
originalUrl.split("track/")[1].split("?")[0]
}`,
options
);
const { data } = await axios.get(
`https://api.spotifydown.com/download/${track.data.id}`,
options
);
const audioUrl = await fetch(data.link).then((res) => res.buffer());
const imgUrl = await fetch(data.metadata.cover).then((res) => res.buffer());
const writeTags = tags2(
data.metadata.title,
data.metadata.artists,
data.metadata.releaseDate,
data.metadata.album,
imgUrl
);
const audioBuffer = await nodeID3.write(writeTags, audioUrl);
const originalUrl = await getOriginalUrl(url)
const track = await axios.get(`https://api.spotifydown.com/metadata/track/${originalUrl.split("track/")[1].split("?")[0]}`, options)
const { data } = await axios.get(`https://api.spotifydown.com/download/${track.data.id}`, options)
const audioUrl = await fetch(data.link).then((res) => res.buffer())
const imgUrl = await fetch(data.metadata.cover).then((res) => res.buffer())
const writeTags = tags2(data.metadata.title, data.metadata.artists, data.metadata.releaseDate, data.metadata.album, imgUrl)
const audioBuffer = await nodeID3.write(writeTags, audioUrl)
const result = {
success: data.success,
metadata: data.metadata,
audioBuffer: audioBuffer,
};
return result;
audioBuffer: audioBuffer
}
return result
} else if (url.includes("open.spotify.com")) {
const { data } = await axios.get(
`https://api.spotifydown.com/download/${
url.split("track/")[1].split("?")[0]
}`,
options
);
const audioUrl = await fetch(data.link).then((res) => res.buffer());
const imgUrl = await fetch(data.metadata.cover).then((res) => res.buffer());
const writeTags = tags2(
data.metadata.title,
data.metadata.artists,
data.metadata.releaseDate,
data.metadata.album,
imgUrl
);
const audioBuffer = await nodeID3.write(writeTags, audioUrl);
const { data } = await axios.get(`https://api.spotifydown.com/download/${url.split("track/")[1].split("?")[0]}`, options)
const audioUrl = await fetch(data.link).then((res) => res.buffer())
const imgUrl = await fetch(data.metadata.cover).then((res) => res.buffer())
const writeTags = tags2(data.metadata.title, data.metadata.artists, data.metadata.releaseDate, data.metadata.album, imgUrl)
const audioBuffer = await nodeID3.write(writeTags, audioUrl)
const result = {
success: data.success,
metadata: data.metadata,
audioBuffer: audioBuffer,
};
return result;
audioBuffer: audioBuffer
}
return result
} else {
const result = {
status: false,
message: "Please input valid spotify url",
};
console.log(result);
return result;
message: "Please input valid spotify url"
}
console.log(result)
return result
}

@@ -176,78 +151,48 @@ }

async function downloadAlbum(url) {
let result = { type: null, metadata: {}, trackList: [] };
if (!isUrl(url)) throw new Error("Input Url");
let result = { type: null, metadata: {}, trackList: [] }
if (!isUrl(url)) throw new Error("Input Url")
try {
if (url.includes("spotify.link")) {
const getOrigin = await getOriginalUrl(url);
if (!getOrigin.includes("album/") && !getOrigin.includes("playlist/"))
throw new Error("Invalid album/playlist url");
const getOrigin = await getOriginalUrl(url)
if (!getOrigin.includes("album/") && !getOrigin.includes("playlist/")) throw new Error("Invalid album/playlist url")
if (getOrigin.includes("album/")) {
var inputData = "album/";
var inputData = "album/"
} else {
var inputData = "playlist/";
var inputData = "playlist/"
}
const metaData = await axios.get(
`https://api.spotifydown.com/metadata/${inputData}${
getOrigin.split(inputData)[1].split("?")[0]
}`,
options
);
result.type = inputData.split("/")[0];
result.metadata = metaData.data;
const { data } = await axios.get(
`https://api.spotifydown.com/trackList/${inputData}${
getOrigin.split(inputData)[1].split("?")[0]
}`,
options
);
console.log(`Downloading audio...`);
console.log(
"Please wait for a moment, this process will take for a couple minutes"
);
const metaData = await axios.get(`https://api.spotifydown.com/metadata/${inputData}${getOrigin.split(inputData)[1].split("?")[0]}`, options)
result.type = inputData.split("/")[0]
result.metadata = metaData.data
const { data } = await axios.get(`https://api.spotifydown.com/trackList/${inputData}${getOrigin.split(inputData)[1].split("?")[0]}`, options)
console.log(`Downloading audio...`)
console.log("Please wait for a moment, this process will take for a couple minutes")
for (let i = 0; i < data.trackList.length; i++) {
const downloading = await downloads(
`https://open.spotify.com/track/${data.trackList[i].id}`
);
result.trackList.push(downloading);
const downloading = await downloads(`https://open.spotify.com/track/${data.trackList[i].id}`)
result.trackList.push(downloading)
}
return result;
return result
} else if (url.includes("open.spotify.com")) {
if (!url.includes("album/") && !url.includes("playlist/"))
throw new Error("Invalid album/playlist url");
if (!url.includes("album/") && !url.includes("playlist/")) throw new Error("Invalid album/playlist url")
if (url.includes("album/")) {
var inputData = "album/";
var inputData = "album/"
} else {
var inputData = "playlist/";
var inputData = "playlist/"
}
const metaData = await axios.get(
`https://api.spotifydown.com/metadata/${inputData}${
url.split(inputData)[1].split("?")[0]
}`,
options
);
result.type = inputData.split("/")[0];
result.metadata = metaData.data;
const { data } = await axios.get(
`https://api.spotifydown.com/trackList/${inputData}${
url.split(inputData)[1].split("?")[0]
}`,
options
);
console.log("Downloading audio...");
console.log(
"Please wait for a moment, this process will take for a couple minutes"
);
const metaData = await axios.get(`https://api.spotifydown.com/metadata/${inputData}${url.split(inputData)[1].split("?")[0]}`, options)
result.type = inputData.split("/")[0]
result.metadata = metaData.data
const { data } = await axios.get(`https://api.spotifydown.com/trackList/${inputData}${url.split(inputData)[1].split("?")[0]}`, options)
console.log("Downloading audio...")
console.log("Please wait for a moment, this process will take for a couple minutes")
for (let i = 0; i < data.trackList.length; i++) {
const downloading = await downloads(
`https://open.spotify.com/track/${data.trackList[i].id}`
);
result.trackList.push(downloading);
const downloading = await downloads(`https://open.spotify.com/track/${data.trackList[i].id}`)
result.trackList.push(downloading)
}
return result;
return result
} else {
throw new Error("Invalid Url!");
throw new Error("Invalid Url!")
}
} catch (err) {
console.log(err);
return String(err);
console.log(err)
return String(err)
}

@@ -336,22 +281,17 @@ }

async function downloadTrack(song) {
let result = {};
let result = {}
if (isUrl(song)) {
try {
if (song.includes("spotify.link")) {
const getOrigin = await getOriginalUrl(song);
const getOrigin = await getOriginalUrl(song)
if (!getOrigin.includes("track/")) {
(result.status = false),
(result.message = "Download track not support for Album/Playlist");
console.log(result);
return result;
;(result.status = false), (result.message = "Download track not support for Album/Playlist")
console.log(result)
return result
}
var tracks = await spotify.getTrack(
getOrigin.split("track/")[1].split("?")[0]
);
var tracks = await spotify.getTrack(getOrigin.split("track/")[1].split("?")[0])
} else {
var tracks = await spotify.getTrack(
song.split("track/")[1].split("?")[0]
);
var tracks = await spotify.getTrack(song.split("track/")[1].split("?")[0])
}
const downloadData = await downloads(song);
const downloadData = await downloads(song)
result = {

@@ -370,22 +310,20 @@ status: true,

tracks: tracks.album.total_tracks,
releasedDate: tracks.album.release_date,
releasedDate: tracks.album.release_date
},
imageUrl: tracks.album.images[0].url,
audioBuffer: downloadData.audioBuffer,
};
return result;
audioBuffer: downloadData.audioBuffer
}
return result
} catch (err) {
result = {
status: false,
message: "Unknown error occurred!\n\n" + String(err),
};
console.log(err);
return result;
message: "Unknown error occurred!\n\n" + String(err)
}
console.log(err)
return result
}
} else {
try {
const searchTrack = await search(song, 1);
const downloadData = await downloads(
searchTrack.items[0].external_urls.spotify
);
const searchTrack = await search(song, 1)
const downloadData = await downloads(searchTrack.items[0].external_urls.spotify)
result = {

@@ -404,15 +342,15 @@ status: true,

tracks: searchTrack.items[0].album.total_tracks,
releasedDate: searchTrack.items[0].album.release_date,
releasedDate: searchTrack.items[0].album.release_date
},
imageUrl: downloadData.metadata.cover,
audioBuffer: downloadData.audioBuffer,
};
return result;
audioBuffer: downloadData.audioBuffer
}
return result
} catch (err) {
result = {
status: false,
message: "Unknown error occurred!\n\n" + String(err),
};
console.log(result);
return result;
message: "Unknown error occurred!\n\n" + String(err)
}
console.log(result)
return result
}

@@ -419,0 +357,0 @@ }

@@ -12,3 +12,3 @@ {

"description": "Simple Scraper Spotify Track/Album/Playlist Downloader with Metadata",
"version": "1.0.25",
"version": "1.0.26",
"main": "./dist/cjs/index.js",

@@ -15,0 +15,0 @@ "module": "./dist/esm/src/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc