A simple package to download music tracks from spotify šŸŽµ

Overview

Spotifydl-Core

Never gonna give up, never gonna let you down

A simple package to download music tracks from spotify šŸŽµ

Installation

> npm i spotifydl-core

Intialization

You need to intialize the Spotify Class before acessing the methods inside it.

const Spotify = require('spotifydl-core').default
//import Spotify from 'spotifydl-core'

const credentials = {
    clientId: 'your-client-id',
    clientSecret: 'your-client-secret'
}
const spotify = new Spotify(credentials)

Methods

NOTE: Only some methods are shown here. Checkout the docs depth

Get Track ā­ļø

await spotify.getTrack(track_url) 

// For Example: track_url = 'https://open.spotify.com/track/1Ub6VfiTXgyV8HnsfzrZzC?si=4412ef4ebd8141ab'

// Input: url of the track, Type: string

Download Track/Song ā¬‡ļø

await spotify.downloadTrack(track_url, file_name)

// For Example: track_url = 'https://open.spotify.com/track/1Ub6VfiTXgyV8HnsfzrZzC?si=4412ef4ebd8141ab' & file_name = 'song.mp3'

// Input: url of the track and name of the filename, Both Type: string

// It'll return buffer (promise) if you don't provide any filename

Get Artist šŸ‘©ā€šŸŽ¤ šŸ§‘ā€šŸŽ¤

await spotify.getArtist(artist_url)

// For Example: artist_url = 'https://open.spotify.com/artist/3B9O5mYYw89fFXkwKh7jCS'

// Input: url of the artist, Type: string

Get Album šŸ’½

await spotify.getAlbum(album_url)

// For Example: album_url = 'https://open.spotify.com/album/3u3WsbVPLT0fXiClx9GYD9?si=pfGAdL3VRiid0M3Ln_0DNg'

// Input: url of the album, Type: string

Get Playlist šŸŽ§

await spotify.getPlylist(playlist_url)

// Input: url of the playlist, Type: string

Download an Entire playlist

await spotify.downloadPlaylist(playlist_url)

//It'll return an array containing the Buffer of the songs in the playlist

Usage Example

const fs = require('fs-extra') 
// Initialization and Authentication 
const Spotify = require('spotifydl-core').default // Import the library 
const spotify = new Spotify({ // Authentication
    clientId: 'acc6302297e040aeb6e4ac1fbdfd62c3', // <-- add your own clientId 
    clientSecret: '0e8439a1280a43aba9a5bc0a16f3f009', // <-- add your own clientSecret 
})
/* To learn more about clientId and Secret  , 
visit https://developer.spotify.com/documentation/general/guides/app-settings/ 
*/

// Declaring the respective url in 'links' object 
const links = {
    artist: 'https://open.spotify.com/artist/7ky9g1jEjCsjNjZbYuflUJ?si=2To3fmc-T9KuyyrQ-Qp5KQ', // Url of the artist you want to gather info about
    album: 'https://open.spotify.com/album/3u3WsbVPLT0fXiClx9GYD9?si=pfGAdL3VRiid0M3Ln_0DNg', // Url of the album you want to gather info about
    song: 'https://open.spotify.com/track/1Ub6VfiTXgyV8HnsfzrZzC?si=4412ef4ebd8141ab' // Url of the song you want to gather info about or download
};

// Engine 
(async () => {
    const data = await spotify.getTrack(links.song) // Waiting for the data šŸ„±
    console.log('Downloading: ', data.name, 'by:', data.artists.join(' ')) // Keep an eye on the progress
    const song = await spotify.downloadTrack(links.song) // Downloading goes brr brr 
    fs.writeFileSync('song.mp3', song) // Let's write the buffer to the woofer (i mean file, hehehe) 
})()

//spotify.verifyCredentials().then(() => Promise.all([spotify.getTrack(links.song), spotify.getAlbum(links.album), spotify.getArtistAlbums(links.artist)]).then(console.log))

šŸ™‡ā€ Special Thanks to them

You might also like...

Radio player for audio tracks in a tezos wallet.

Hicathon 2021 | WG7 7.2 - Galleries and collections Minimal galleries for exhibitions The Team: Name Role Discord Username Twitter Username Wallet Tea

Jul 11, 2022

A Spicetify extension to announce song details, time and local weather in-between tracks.

Spicetify Announcer A Spicetify extension to announce song details, time and local weather in-between tracks. Spicetify Announcer uses Amazon Polly se

Apr 25, 2022

Music-Player - Music player application built with HTML, CSS and vanilla JavaScript

Music-Player - Music player application built with HTML, CSS and vanilla JavaScript

Music-Player Music player application built with HTML, CSS and vanilla JavaScrip

Feb 10, 2022

A mobile app for playing music on Resonate, an open source music streaming co-op.

stream2own Play fair. Website | Twitter | Contributing | Developer Guide šŸŽµ Resonate Stream App A mobile app for playing music on Resonate, an open so

Dec 28, 2022

A decentralized Music Ownership System developed on Truffle Suite and React Bootstrap to allow Music artists to upload their content to the blockchain, that can be streamed by users

A decentralized Music Ownership System developed on Truffle Suite and React Bootstrap to allow Music artists to upload their content to the blockchain, that can be streamed by users

A decentralized Music Ownership System developed on Truffle Suite and React Bootstrap to allow Music artists to upload their content to the blockchain, that can be streamed by users.

Sep 5, 2022

A Simple Music Bot Made Using Discord-Player Package - (Beta)

A Simple Music Bot Made Using Discord-Player Package - (Beta)

Our Music Bot A Highly Powerful Music Bot Without Lavalink Which Is Gonna Have Setup, A Specific Text Channel For Bot Command Feature, And DJ System S

Dec 14, 2022

Simple Spotify client for nodejs exposing few useful methods

spotify-mini Simple Spotify client for nodejs exposing useful methods I have been using a rough version of this lib in my portfolio from a long time.

Jan 2, 2023

SpotifyUiClone - A Ui Clone of Spotify, only studing purporses

Spotify Ui Clone An Kinda Clone of the Spotify Ui for studing purposes Summary This is a project made in React Js, so the idea is to make an ui for an

Jan 7, 2022

A review aggregator web application that allows users to review albums by leveraging the Spotify Web API.

A review aggregator web application that allows users to review albums by leveraging the Spotify Web API.

Reviewify Summary Reviewify is a review aggregator platform that leverages the Spotify Web API. It allows users to: Login with their Spotify accounts

Oct 7, 2022
Comments
  • Bump axios from 0.21.1 to 0.21.2

    Bump axios from 0.21.1 to 0.21.2

    Bumps axios from 0.21.1 to 0.21.2.

    Release notes

    Sourced from axios's releases.

    v0.21.2

    0.21.2 (September 4, 2021)

    Fixes and Functionality:

    • Updating axios requests to be delayed by pre-emptive promise creation (#2702)
    • Adding "synchronous" and "runWhen" options to interceptors api (#2702)
    • Updating of transformResponse (#3377)
    • Adding ability to omit User-Agent header (#3703)
    • Adding multiple JSON improvements (#3688, #3763)
    • Fixing quadratic runtime and extra memory usage when setting a maxContentLength (#3738)
    • Adding parseInt to config.timeout (#3781)
    • Adding custom return type support to interceptor (#3783)
    • Adding security fix for ReDoS vulnerability (#3980)

    Internal and Tests:

    • Updating build dev dependancies (#3401)
    • Fixing builds running on Travis CI (#3538)
    • Updating follow rediect version (#3694, #3771)
    • Updating karma sauce launcher to fix failing sauce tests (#3712, #3717)
    • Updating content-type header for application/json to not contain charset field, according do RFC 8259 (#2154)
    • Fixing tests by bumping karma-sauce-launcher version (#3813)
    • Changing testing process from Travis CI to GitHub Actions (#3938)

    Documentation:

    • Updating documentation around the use of AUTH_TOKEN with multiple domain endpoints (#3539)
    • Remove duplication of item in changelog (#3523)
    • Fixing gramatical errors (#2642)
    • Fixing spelling error (#3567)
    • Moving gitpod metion (#2637)
    • Adding new axios documentation website link (#3681, #3707)
    • Updating documentation around dispatching requests (#3772)
    • Adding documentation for the type guard isAxiosError (#3767)
    • Adding explanation of cancel token (#3803)
    • Updating CI status badge (#3953)
    • Fixing errors with JSON documentation (#3936)
    • Fixing README typo under Request Config (#3825)
    • Adding axios-multi-api to the ecosystem file (#3817)
    • Adding SECURITY.md to properly disclose security vulnerabilities (#3981)

    Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:

    ... (truncated)

    Changelog

    Sourced from axios's changelog.

    0.21.2 (September 4, 2021)

    Fixes and Functionality:

    • Updating axios requests to be delayed by pre-emptive promise creation (#2702)
    • Adding "synchronous" and "runWhen" options to interceptors api (#2702)
    • Updating of transformResponse (#3377)
    • Adding ability to omit User-Agent header (#3703)
    • Adding multiple JSON improvements (#3688, #3763)
    • Fixing quadratic runtime and extra memory usage when setting a maxContentLength (#3738)
    • Adding parseInt to config.timeout (#3781)
    • Adding custom return type support to interceptor (#3783)
    • Adding security fix for ReDoS vulnerability (#3980)

    Internal and Tests:

    • Updating build dev dependancies (#3401)
    • Fixing builds running on Travis CI (#3538)
    • Updating follow rediect version (#3694, #3771)
    • Updating karma sauce launcher to fix failing sauce tests (#3712, #3717)
    • Updating content-type header for application/json to not contain charset field, according do RFC 8259 (#2154)
    • Fixing tests by bumping karma-sauce-launcher version (#3813)
    • Changing testing process from Travis CI to GitHub Actions (#3938)

    Documentation:

    • Updating documentation around the use of AUTH_TOKEN with multiple domain endpoints (#3539)
    • Remove duplication of item in changelog (#3523)
    • Fixing gramatical errors (#2642)
    • Fixing spelling error (#3567)
    • Moving gitpod metion (#2637)
    • Adding new axios documentation website link (#3681, #3707)
    • Updating documentation around dispatching requests (#3772)
    • Adding documentation for the type guard isAxiosError (#3767)
    • Adding explanation of cancel token (#3803)
    • Updating CI status badge (#3953)
    • Fixing errors with JSON documentation (#3936)
    • Fixing README typo under Request Config (#3825)
    • Adding axios-multi-api to the ecosystem file (#3817)
    • Adding SECURITY.md to properly disclose security vulnerabilities (#3981)

    Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub:

    ... (truncated)

    Commits
    Maintainer changes

    This version was pushed to npm by jasonsaayman, a new releaser for axios since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump path-parse from 1.0.6 to 1.0.7

    Bump path-parse from 1.0.6 to 1.0.7

    Bumps path-parse from 1.0.6 to 1.0.7.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • It doesn't work on certain playlists, but works on other (the same API/user)

    It doesn't work on certain playlists, but works on other (the same API/user)

    Hi, Thanks for the tool, but I have this playlist that is public and returns following error when using downloadPlaylist(https://open.spotify.com/playlist/0G2k0WxH9Vvt6s7z7YAmjL?si=ddc8473ca3c645c2):

    TypeError: Cannot read properties of undefined (reading 'map')
        at SpotifyFetcher.<anonymous> (D:\MuzykTworzenie\spotifyDownload\node_modules\spotifydl-core\dist\lib\API.js:144:89)
        at Object.next (D:\MuzykTworzenie\spotifyDownload\node_modules\spotifydl-core\dist\lib\API.js:14:53)
        at fulfilled (D:\MuzykTworzenie\spotifyDownload\node_modules\spotifydl-core\dist\lib\API.js:5:58)
        at processTicksAndRejections (node:internal/process/task_queues:96:5)
    

    Other playlists worked fine for example for the same machine/API keys/user: downloadPlaylist(https://open.spotify.com/playlist/6uLG1eyIndx3mwURQIYV7F?si=b4431402a23d4374&nd=1)

    opened by ChrystianSchutz 0
  •  WebapiRegularError: An error occurred while communicating with Spotify's Web API.

    WebapiRegularError: An error occurred while communicating with Spotify's Web API.

    Details: non existing id. at _toError (C:\Users\sordi\urepirso\node_modules\spotify-web-api-node\src\http-manager.js:39:12) at C:\Users\sordi\urepirso\node_modules\spotify-web-api-node\src\http-manager.js:71:25 at Request.callback (C:\Users\sordi\urepirso\node_modules\superagent\lib\node\index.js:905:3) at C:\Users\sordi\urepirso\node_modules\superagent\lib\node\index.js:1127:20 at IncomingMessage. (C:\Users\sordi\urepirso\node_modules\superagent\lib\node\parsers\json.js:22:7) at Stream.emit (node:events:513:28) at Unzip. (C:\Users\sordi\urepirso\node_modules\superagent\lib\node\unzip.js:53:12) at Unzip.emit (node:events:513:28) at endReadableNT (node:internal/streams/readable:1358:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) { body: { error: { status: 404, message: 'non existing id' } }, headers: { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'private, max-age=0', 'x-robots-tag': 'noindex, nofollow', 'access-control-allow-origin': '*', 'access-control-allow-headers': 'Accept, App-Platform, Authorization, Content-Type, Origin, Retry-After, Spotify-App-Version, X-Cloud-Trace-Context, client-token, content-access-token', 'access-control-allow-methods': 'GET, POST, OPTIONS, PUT, DELETE, PATCH', 'access-control-allow-credentials': 'true', 'access-control-max-age': '604800', 'content-encoding': 'gzip', 'strict-transport-security': 'max-age=31536000', 'x-content-type-options': 'nosniff', date: 'Sun, 25 Sep 2022 04:00:44 GMT', server: 'envoy', via: 'HTTP/2 edgeproxy, 1.1 google', 'alt-svc': 'h3=":443"; ma=2592000,h3-29=":443"; ma=2592000', connection: 'close', 'transfer-encoding': 'chunked' }, statusCode: 404 }

    opened by Sordinni 0
Owner
Alen Yohannan
Well, in that case...
Alen Yohannan
Spotify 2.0 com NextJS 12 - MIddleware, TailwindCSS, Spotify API, NextAuth, Recoil

Spotify Clone A spotify clone made with NextJS 12, TailwindCSS, NextAuth, Spotify API, Recoil Lessons Learned Setting up NextJS with Tailwind. NextAut

zF4ke 3 Mar 14, 2022
Spotify clone using Next.js, Spotify API, Tailwind, NextAuth, Recoil

Next.js + Tailwind CSS Example This example shows how to use Tailwind CSS (v2.2) with Next.js. It follows the steps outlined in the official Tailwind

Abdelwahab Hussein 2 Dec 25, 2021
spotify.ts is an wrapper built around Spotify's Web API

spotify.ts About spotify.ts is an wrapper built around Spotify's Web API. Features Fast Object Oriented Typescript, ESM, CJS support Easy to Use Insta

null 6 Nov 17, 2022
A NodeJS package for voice channel interactions on Revolt. This package lets you join voice channels, play music and more!

Revoice.js - A Voice Module for Revolt This package is still in developement and lacks many features. You still are able to play sound to a voice chan

ShadowLp174 13 Dec 25, 2022
Web Application that represents a music player using the spotify API, React, JS, CSS, HTML, nodeJS, Firebase, material-ui, JSON and other technologies. Made by Yohan Hmaiti

Web Application that represents a music player using the spotify API, React, JS, CSS, HTML, nodeJS, Firebase, material-ui, JSON and other technologies. Made by Yohan Hmaiti

Yohan Hmaiti 2 Jan 8, 2022
Add some fire to your Spotify music playlists šŸ”„šŸŽ§

Spotifire ?? Add some fire to your Spotify music playlists ?? Built With Next.js React Tailwind CSS (v3.0) NextAuth Recoil Spotify Web API Preview Vis

Niloy Sikdar 15 Jun 19, 2022
šŸŽ¼ - MusicBridge Recieves MIDI messages and converts them to AppleScript commands to control Apple Music and Spotify for macOS.

MusicBridge MusicBridge Recieves MIDI messages and converts them to AppleScript commands to control Apple Music and Spotify for macOS. Installation Si

null 3 Dec 20, 2022
Scraper for TikTok. Download videos, music, fetch users info and more.

tiktok-scraper A fast light-weight scraper for tiktok to fetch and download video posts, video music, user info and more. Installation npm i tiktok-sc

null 41 Jan 1, 2023
Iā€™m a very useful music bot that can make you play a music with a simple command! I have a lot of good commands that you can have a better experience playing your favorites songs!

Iā€™m a very useful music bot that can make you play a music with a simple command! I have a lot of good commands that you can have a better experience playing your favorites songs!

Hugo Kishi 2 Aug 16, 2022
ā–¶ļø Streams a list of tracks from Youtube, Soundcloud, Vimeo...

PlayemJS PlayemJS is a front-end JavaScript component that manages a audio/video track queue and plays those tracks sequentially. It can currently pla

Adrien Joly 90 Nov 27, 2022