Created
July 15, 2024 03:00
-
-
Save ZTRdiamond/0f80d1a14e2a4024821316cf651161ef to your computer and use it in GitHub Desktop.
Free spotify downloader that you can use for your projects, this code only support for track url and not playlist or etc.
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
| import { parse as urlParser } from "spotify-uri"; | |
| import axios from "axios"; | |
| async function spotifydl(url) { | |
| try { | |
| if(!url) return { status: false, message: "undefined reading url!" }; | |
| return await new Promise(async(resolve, reject) => { | |
| const trackId = (urlParser(url)).id; | |
| if(!trackId) return reject("invalid spotify track url!"); | |
| axios.get(`https://api.spotifydown.com/download/` + trackId, { | |
| headers: { | |
| authority: "api.spotifydown.com", | |
| origin: "https://spotifydown.com", | |
| referer: "https://spotifydown.com" | |
| } | |
| }).then(res => { | |
| const data = res.data; | |
| if(!data.success) reject("failed fetching track metadata"); | |
| delete data.metadata.cache | |
| delete data.metadata.success | |
| resolve({ | |
| status: true, | |
| data: { | |
| ...data.metadata, | |
| url: data.link | |
| } | |
| }) | |
| }).catch(reject); | |
| }) | |
| } catch (e) { | |
| return { status: false, message: e }; | |
| } | |
| } | |
| spotifydl("https://open.spotify.com/track/0ZEYRVISCaqz5yamWZWzaA") | |
| .then(console.log) | |
| .catch(console.log) | |
| /** Response | |
| { | |
| status: true, | |
| data: { | |
| id: '0ZEYRVISCaqz5yamWZWzaA', | |
| artists: 'Budi Doremi', | |
| title: 'Melukis Senja', | |
| album: 'Melukis Senja', | |
| cover: 'https://i.scdn.co/image/ab67616d0000b27337f883f98514a0852046e2f0', | |
| isrc: 'IDA642001567', | |
| releaseDate: '2020-06-24', | |
| url: 'https://cdn4.meow.gs/api/stream?t=3qQ4b_1pSokc2rPaZuqC8&e=1720892352560&h=EWQSSQczjgx69os1ruAjWz5e1BKpCFxzFwWUwSN_EQ4&s=ngz8l4svE46fPxJTu-8I13sBKSgexq19gngxZcNkskE&i=g3PKEPgSJdrI1En9xJC0xg' | |
| } | |
| } | |
| */ |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Source: https://whatsapp.com/channel/0029VagFeoY9cDDa9ulpwM0T