@nechlophomeriaa/spotifydl
Advanced tools
Comparing version 1.0.9 to 1.0.10
@@ -5,2 +5,16 @@ function isUrl(url) { | ||
function tags2(title, artist, year, album, image) { | ||
const result = { | ||
title: title, | ||
artist: artist, | ||
year: year, | ||
album: album, | ||
image: { | ||
description: "Front Cover", | ||
imageBuffer: image | ||
} | ||
} | ||
return result | ||
} | ||
function tags(title, artist, year, album, image, track) { | ||
@@ -31,2 +45,2 @@ const result = { | ||
module.exports = { isUrl, tags, convertMs } | ||
module.exports = { isUrl, tags, convertMs, tags2 } |
183
index.js
@@ -1,182 +0,3 @@ | ||
const { isUrl, tags, convertMs } = require("./function") | ||
const axios = require("axios") | ||
const cheerio = require("cheerio") | ||
const fetch = require("node-fetch") | ||
const spot = require("spotify-finder") | ||
const spotify = new spot({ | ||
consumer: { | ||
key: "9e1c5e192a8141c59b7e91f2848e6a9c", | ||
secret: "78e2ece45fa446c98517d2cbb3271486" | ||
} | ||
}) | ||
const options = { | ||
headers: { | ||
Origin: "https://spotifydown.com", | ||
Referer: "https://spotifydown.com/" | ||
} | ||
} | ||
const { search, downloadTrack, downloadAlbum } = require("./src") | ||
async function getOriginalUrl(url) { | ||
const data = await fetch(url) | ||
return data.url | ||
} | ||
async function downloads(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) | ||
return data | ||
} else if (url.includes("open.spotify.com")) { | ||
const { data } = await axios.get(`https://api.spotifydown.com/download/${url.split("track/")[1].split("?")[0]}`, options) | ||
return data | ||
} else { | ||
const result = { | ||
status: false, | ||
message: "Please input valid spotify url" | ||
} | ||
console.log(result) | ||
return result | ||
} | ||
} | ||
async function search(query, limit) { | ||
if (isUrl(query)) throw new Error("Search function not support for url") | ||
const limits = limit ? limit : 1 | ||
const data = await spotify.search({ q: query, type: "track", limit: limits }) | ||
return data.tracks | ||
} | ||
async function downloadAlbum(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") | ||
if (getOrigin.includes("album/")) { | ||
var inputData = "album/" | ||
} else { | ||
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") | ||
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) | ||
} | ||
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/")) { | ||
var inputData = "album/" | ||
} else { | ||
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") | ||
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) | ||
} | ||
return result | ||
} else { | ||
throw new Error("Invalid Url!") | ||
} | ||
} catch (err) { | ||
console.log(err) | ||
return String(err) | ||
} | ||
} | ||
async function downloadTrack(song) { | ||
let result = {} | ||
if (isUrl(song)) { | ||
try { | ||
if (song.includes("spotify.link")) { | ||
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 | ||
} | ||
var tracks = await spotify.getTrack(getOrigin.split("track/")[1].split("?")[0]) | ||
} else { | ||
var tracks = await spotify.getTrack(song.split("track/")[1].split("?")[0]) | ||
} | ||
const downloadData = await downloads(song) | ||
result = { | ||
status: true, | ||
title: tracks.name, | ||
artists: tracks.artists.map((art) => art.name).join(", "), | ||
duration: convertMs(tracks.duration_ms), | ||
explicit: tracks.explicit, | ||
popularity: tracks.popularity, | ||
url: tracks.external_urls.spotify, | ||
album: { | ||
name: tracks.album.name, | ||
type: tracks.album.album_type, | ||
tracks: tracks.album.total_tracks, | ||
releasedDate: tracks.album.release_date | ||
}, | ||
imageUrl: tracks.album.images[0].url, | ||
audioUrl: downloadData.link | ||
} | ||
return result | ||
} catch (err) { | ||
result = { | ||
status: false, | ||
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) | ||
result = { | ||
status: true, | ||
title: searchTrack.items[0].name, | ||
artists: searchTrack.items[0].artists.map((art) => art.name).join(", "), | ||
duration: convertMs(searchTrack.items[0].duration_ms), | ||
explicit: searchTrack.items[0].explicit, | ||
popularity: searchTrack.items[0].popularity, | ||
url: searchTrack.items[0].external_urls.spotify, | ||
album: { | ||
name: searchTrack.items[0].album.name, | ||
type: searchTrack.items[0].album.album_type, | ||
tracks: searchTrack.items[0].album.total_tracks, | ||
releasedDate: searchTrack.items[0].album.release_date | ||
}, | ||
imageUrl: downloadData.metadata.cover, | ||
audioUrl: downloadData.link | ||
} | ||
return result | ||
} catch (err) { | ||
result = { | ||
status: false, | ||
message: "Unknown error occurred!\n\n" + String(err) | ||
} | ||
console.log(result) | ||
return result | ||
} | ||
} | ||
} | ||
module.exports = { | ||
downloadAlbum, | ||
getOriginalUrl, | ||
search, | ||
downloadTrack, | ||
downloads | ||
} | ||
module.exports = { search, downloadTrack, downloadAlbum } |
@@ -6,2 +6,4 @@ { | ||
"node-fetch": "2.6.6", | ||
"node-id3": "^0.2.6", | ||
"prettier": "^3.0.3", | ||
"spotify-finder": "^2.1.1" | ||
@@ -11,3 +13,3 @@ }, | ||
"description": "Simple Scraper Spotify Track/Album/Playlist Downloader with Metadata", | ||
"version": "1.0.9", | ||
"version": "1.0.10", | ||
"main": "index.js", | ||
@@ -14,0 +16,0 @@ "scripts": { |
@@ -12,3 +12,3 @@ <p>Simple Scraper Spotify Downloader from <a href ="https://spotifydown.com/id">SpotifyDown</a></p> | ||
```js | ||
const { search, downloadTrack, downloadAlbum, downloads, getOriginalUrl } = require("@nechlophomeriaa/spotifydl") | ||
const { search, downloadTrack, downloadAlbum } = require("@nechlophomeriaa/spotifydl") | ||
``` | ||
@@ -50,16 +50,16 @@ | ||
status: true, | ||
title: 'Acid Wash Ocean', | ||
artists: 'Dreamgirl', | ||
duration: '00:02:13', | ||
title: 'Someone To Spend Time With', | ||
artists: 'Los Retros', | ||
duration: '00:02:53', | ||
explicit: false, | ||
popularity: 37, | ||
url: 'https://open.spotify.com/track/2D5QfU6vhWVCN5xKv5ZniT', | ||
popularity: 73, | ||
url: 'https://open.spotify.com/track/6SE4JAo7T8C7XkFka5bbga', | ||
album: { | ||
name: 'Illuminaughty', | ||
name: 'Someone To Spend Time With', | ||
type: 'single', | ||
tracks: 6, | ||
releasedDate: '2015-02-14' | ||
tracks: 1, | ||
releasedDate: '2019-02-12' | ||
}, | ||
imageUrl: 'https://i.scdn.co/image/ab67616d0000b27377cbc6b59d5190717afa04aa', | ||
audioUrl: 'https://cdn---02---dl.ytapis.com/dl?hash=HDXr7hj8l0my%2BWkfR4ao6ujYcd7N61%2FATvLi368BTyZGUrsIPbz5tSKzhhi5rOVmqflg8ZGn5NsdCJKvvp9pksqGbizGN5xBwKWtuVu%2F2VMlgX5Bq1r93h%2BROgeVDishuDj9eRjDDOrJmO3yNUxadiZNEQyKLjO4rPI5%2FeonTvAn19aYB2o%2FpvmzviG%2FWz%2F9' | ||
imageUrl: 'https://i.scdn.co/image/ab67616d0000b273a1f060b534d1d9c859acc73f', | ||
audioBuffer: <Buffer 49 44 33 03 00 00 03 28 70 58 54 49 54 32 00 00 00 37 00 00 01 ff fe 53 00 6f 00 6d 00 65 00 6f 00 6e 00 65 00 20 00 54 00 6f 00 20 00 53 00 70 00 65 ... 13922160 more bytes> | ||
} | ||
@@ -84,10 +84,10 @@ | ||
{ | ||
type: 'playlist', | ||
type: 'album', | ||
metadata: { | ||
cache: true, | ||
success: true, | ||
artists: 'Thoriq Azzikra', | ||
title: 'alternative indie', | ||
cover: 'https://i.scdn.co/image/ab67706c0000bebb5f0b754337dfe9506a18401c', | ||
releaseDate: null | ||
artists: 'Bubble Tea and Cigarettes', | ||
title: "There's Nothing But Pleasure", | ||
cover: 'https://i.scdn.co/image/ab67616d0000b273c7dd8b1a8ff4ee3f89676686', | ||
releaseDate: '2022-09-02' | ||
}, | ||
@@ -98,3 +98,3 @@ trackList: [ | ||
metadata: [Object], | ||
link: 'https://dll2.yt2api.com/dl?hash=a3%2FcckOmcwfknwenf%2Fqt%2By%2BtN405OR2FLtUUiZ%2FWVpqUXFdCSAm61EJuUiVl9urm8HTrORoLlrjXnxmDOYgs7k13OxKunm%2BhcSP7SY%2BCN2ChZVI7Xc3XRUrj%2FNgsz6cVe6Nc2tR7qlHXYjL%2F0zFDwIbKjrZv3VdllcLdGjzsa6iJqBuKh%2FuL8CCfC1BNrRwYITXq9BMET9U02dL%2Fsa%2B%2F7A%3D%3D' | ||
audioBuffer: <Buffer 49 44 33 03 00 00 03 7e 20 3e 54 49 54 32 00 00 00 3b 00 00 01 ff fe 54 00 68 00 65 00 72 00 65 00 27 00 73 00 20 00 4e 00 6f 00 74 00 68 00 69 00 6e ... 16719638 more bytes> | ||
}, | ||
@@ -104,3 +104,3 @@ { | ||
metadata: [Object], | ||
link: 'https://dl--04--cdn.ytapis.com/dl?hash=JaBY%2BP%2FA4B8ZK0t%2B64ciKQ9eStFzQneyXchmqat5c5REDukuzT34x12peIS4lw5lVd0as6E52rd0HnaNOfKInrDh1mKhIbtP07Z5FNdTIg34VPF%2FsrVlsxIDYEJDJjRdhgAd84MKD85bMtIR94P74rqPus7%2FyvbHEs4eegph7ELk9hjzbuB8GCsys4drrSgo' | ||
audioBuffer: <Buffer 49 44 33 03 00 00 06 3e 43 72 54 49 54 32 00 00 00 6f 00 00 01 ff fe 47 00 6f 00 20 00 44 00 6f 00 77 00 6e 00 73 00 74 00 61 00 69 00 72 00 73 00 20 ... 27214410 more bytes> | ||
}, | ||
@@ -110,3 +110,3 @@ { | ||
metadata: [Object], | ||
link: 'https://dl--06--cdn.ytapis.com/dl?hash=aX7MietFI1%2Fy6%2FFmrdGDfsyYRV2EagEdRfCAHOaAFpGC0GlPXFDwJXICepk1EcF51Qd9DXfjsHFecjjHL%2FcPbNoYg%2BWwUbI%2BbNsCHF%2Fy0RFgPBImnxJj63ZH%2FxgJrIkrHgS1SG%2FIZhmlHbvwW9%2BEWNMS5xE%2BzEc4bmMXAoElJ7Ca0FuBWY2LZRII4js05w717Vhrzx9CMOThEWx%2B0%2FZI5GAlRDgsiVyKWsCuwFTzIDM%3D' | ||
audioBuffer: <Buffer 49 44 33 03 00 00 06 49 5b 5e 54 49 54 32 00 00 00 1b 00 00 01 ff fe 53 00 61 00 6e 00 74 00 61 00 20 00 4d 00 6f 00 6e 00 69 00 63 00 61 00 54 50 45 ... 27581046 more bytes> | ||
}, | ||
@@ -116,3 +116,3 @@ { | ||
metadata: [Object], | ||
link: 'https://dll1.yt2api.com/dl?hash=QdOq8HKI5A8GxPCoqM5gi2MoXx8XIQVraiR8B6JQMvPm%2FPo%2FgXomXX3fAk3fWWdO79JNUY16szGThkchWf6ijOnkmJ9TKN0dLooBp8%2FMpzHg1UFNa5LyIMGOrHzCR9RExnGiH%2FidE1CsAqW2ZibDMwLvUMC060B1yPeJeWkpsSj3yQCdCQbfiLOjyuWHk1qK6r3V6nYikE8IUWgMjcYzzg%3D%3D' | ||
audioBuffer: <Buffer 49 44 33 03 00 00 03 68 67 22 54 49 54 32 00 00 00 1f 00 00 01 ff fe 43 00 69 00 67 00 61 00 72 00 65 00 74 00 74 00 65 00 20 00 42 00 75 00 74 00 74 ... 16016890 more bytes> | ||
}, | ||
@@ -122,3 +122,18 @@ { | ||
metadata: [Object], | ||
link: 'https://dl--03--cdn.ytapis.com/dl?hash=tZiJprp4eW55vbhyznedtd5mx4iyDOe7Qqpq4kQZp%2BGP6fJifIHKa9stqSYv7z9Pe2x6XlaER6wm8CTz594Zf0Bpr6e7vPKgzKhiaDK2pgTG9NaE18A%2Fd31R6uN9pVfhzFC4vPEqfflwLqO5koj9CFWazqDXv%2FMNpw9%2FOGnWQx02JmqWOtMo6lcVIKNI7Hcr' | ||
audioBuffer: <Buffer 49 44 33 03 00 00 05 40 2f 4c 54 49 54 32 00 00 00 09 00 00 01 ff fe 4c 00 69 00 7a 00 54 50 45 31 00 00 00 35 00 00 01 ff fe 42 00 75 00 62 00 62 00 ... 23080548 more bytes> | ||
}, | ||
{ | ||
success: true, | ||
metadata: [Object], | ||
audioBuffer: <Buffer 49 44 33 03 00 00 03 3b 6e 7c 54 49 54 32 00 00 00 39 00 00 01 ff fe 48 00 65 00 20 00 41 00 73 00 6b 00 65 00 64 00 20 00 4d 00 65 00 20 00 74 00 6f ... 14544276 more bytes> | ||
}, | ||
{ | ||
success: true, | ||
metadata: [Object], | ||
audioBuffer: <Buffer 49 44 33 03 00 00 05 7b 5d 0e 54 49 54 32 00 00 00 0b 00 00 01 ff fe 4c 00 65 00 61 00 70 00 54 50 45 31 00 00 00 35 00 00 01 ff fe 42 00 75 00 62 00 ... 25025510 more bytes> | ||
}, | ||
{ | ||
success: true, | ||
metadata: [Object], | ||
audioBuffer: <Buffer 49 44 33 03 00 00 06 41 14 70 54 49 54 32 00 00 00 2d 00 00 01 ff fe 35 00 41 00 4d 00 20 00 45 00 6d 00 70 00 61 00 6e 00 61 00 64 00 61 00 20 00 77 ... 27300744 more bytes> | ||
} | ||
@@ -125,0 +140,0 @@ ] |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23134
10
247
140
6
6
+ Addednode-id3@^0.2.6
+ Addedprettier@^3.0.3
+ Addediconv-lite@0.6.2(transitive)
+ Addednode-id3@0.2.6(transitive)
+ Addedprettier@3.4.2(transitive)