1.2.1 • Published 3 years ago

spotify-it v1.2.1

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

😎 🎧 Spotify-it - Spotify Downlader

Features:

  • Easy
  • Fast
  • Simple

How it work?

It extracts the basic data from Spotify API then downloads the stream from YouTube. 😬

  • Don't worry it's really fast! 🤗

Installation:

npm install spotify-it

Example Usage:

const { Spotify } = require('spotify-it')
const fs = require('fs')

// or with TypeScript
// import { Spotify } from 'spotify-it'
// import fs from 'fs'

const spotify = new Spotify({
	id: 'CLIENT_ID_HERE',
	secret: 'CLIENT_SECERT_HERE',
	defaultLimit: 10 // default track limit for playlist & album
}) // secert & id could be found here => https://developer.spotify.com/dashboard

Fetch Track

const TRACK_URL = 'https://open.spotify.com/track/25yup6WYnPoITrfzhkBLmt'

console.log(Spotify.validate(TRACK_URL, 'TRACK')) // true

const track = await spotify.getTrack(TRACK_URL)

console.log([
	`name = ${track.name}`,
	`artists = ${track.artists.join(' - ')}`,
	`duration = ${track.duration}ms`
].join('\n'))


console.log(track.stream()) // Promise<Stream.Readable>

// To Download/Save track in your PC...

const stream = await track.stream()

stream
	.pipe(fs.createWriteStream('song.webm'))
	.on('end', () => console.log('Saved!'))

Fetch Playlist

const PLAYLIST_URL = 'https://open.spotify.com/playlist/0BUga2X2ArqvH8glBDgPZ3'

console.log(Spotify.validate(PLAYLIST_URL, 'PLAYLIST')) // true

const playlist = await spotify.getPlaylist(PLAYLIST_URL)

console.log([
	`name = ${playlist.name}`,
	`owner = ${playlist.owner}`,
	`duration = ${playlist.duration}ms`,
	`tracks = ${playlist.tracks.length}`
].join('\n'))

for (const track of playlist) {
	console.log(track.title)
}

Fetch Album

const ALBUM_URL = 'https://open.spotify.com/album/1XmFMxLijpq25uoJiGjOlW'

console.log(Spotify.validate(ALBUM_URL, 'ALBUM')) // true

const album = await spotify.getAlbum(ALBUM_URL)

console.log([
	`name = ${album.name}`,
	`artists = ${album.artists.join(' - ')}`,
	`duration = ${album.duration}ms`,
	`tracks = ${album.tracks.length}`
].join('\n'))


for (const track of album) {
	console.log(track.title)
}
// or use spotify#fetch() shortcut

spotify.fetch(SPOTIFY_URL) // Promise<Track | Playlist | Album>

More Examples:

Click here!

Join my discord server

Click here!

1.2.0

3 years ago

1.2.1

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago