All Projects → insane-devs → spotilink

insane-devs / spotilink

Licence: Apache-2.0 license
Parse Spotify URLs into Lavalink track objects.

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to spotilink

lavalink-music-bot-2021
Advance Discord Lavalink Music Bot With Spotify and Buttons Help Menu || Best Music Quality || Radio Commands
Stars: ✭ 26 (+18.18%)
Mutual labels:  spotify, lavalink
Music-Discord-Bot
A music Discord bot with more than 30+ commands which allows to play music on your server efficiently. Supports Youtube, Spotify, Deezer and Soundcloud links. Skips intros and blanks in the music with Sponsorblock.
Stars: ✭ 57 (+159.09%)
Mutual labels:  spotify, lavalink
noteblock
A open-source music bot based on lavalink.
Stars: ✭ 93 (+322.73%)
Mutual labels:  spotify, lavalink
lavamusic
lavalink music bot base in erela.js and discord.js v13
Stars: ✭ 210 (+854.55%)
Mutual labels:  spotify, lavalink
Jericho-Player
LightWeight Framework for discord.js v13 Music Bots and Radio Bots with fast moderation with commands and no memory leak.
Stars: ✭ 19 (-13.64%)
Mutual labels:  spotify, lavalink
discord-lavalink-music-bot
This is music bot for discord made with erelajs, lavalink, discordjs v13-dev
Stars: ✭ 34 (+54.55%)
Mutual labels:  spotify, lavalink
Spotify-Customizer
Chrome extension to customize Spotify web client (themes, lyrics, ...)
Stars: ✭ 27 (+22.73%)
Mutual labels:  spotify
Jekyll-Spotify
Easily output Spotify Embed Player for jekyll
Stars: ✭ 15 (-31.82%)
Mutual labels:  spotify
gmusic wrapped
A spotify 'year wrapped' like for Google Play Music
Stars: ✭ 44 (+100%)
Mutual labels:  spotify
spotifypiHome
"Install and go" multiroom music playback solution, with support for spotify, airplay and bluetooth.
Stars: ✭ 32 (+45.45%)
Mutual labels:  spotify
spotify-rise
⏰ Spotify alarm clock for Ubuntu Linux
Stars: ✭ 32 (+45.45%)
Mutual labels:  spotify
foo spotify
foobar2000 component for Spotify integration
Stars: ✭ 158 (+618.18%)
Mutual labels:  spotify
spotify.cr
🎧 A Crystal wrapper for the Spotify Web API
Stars: ✭ 35 (+59.09%)
Mutual labels:  spotify
muffon
Music streaming browser
Stars: ✭ 491 (+2131.82%)
Mutual labels:  spotify
laravel-spotify
Laravel-Spotify is a simple wrapper around the Spotify Web API that makes working with its endpoints a breeze!
Stars: ✭ 141 (+540.91%)
Mutual labels:  spotify
paystack-music-api
The bot and API that powers Paystack Music.
Stars: ✭ 70 (+218.18%)
Mutual labels:  spotify
hoergewohnheiten
Save your Spotify plays to a Postgres database and run a Flask app to provide listening stats.
Stars: ✭ 16 (-27.27%)
Mutual labels:  spotify
spotify-release-list
📅 Display list of Spotify releases from artists you follow
Stars: ✭ 142 (+545.45%)
Mutual labels:  spotify
Partify
This is a free open source Spotify-powered app that lets users host parties and have guests connect using their smartphones to submit and vote on songs. The app will only play the highest voted song and can connect to personal playlists.
Stars: ✭ 37 (+68.18%)
Mutual labels:  spotify
Spacebot
An open-source, multipurpose, configurable discord bot that does it all (that's the plan, at least)
Stars: ✭ 41 (+86.36%)
Mutual labels:  lavalink

npm npm All Contributors

spotilink

A simple module to convert Spotify URLs into song titles for Lavalink to parse into track objects. No need to bother renewing your Spotify access token every time, because it will handle and renew your Spotify token for you.

Prerequisites

Installation

// For npm
npm install spotilink

// For yarn
yarn add spotilink

Simple Usage

const { SpotifyParser } = require('spotilink');

const spotifyID = ''; // Your Spotify app client ID
const spotifySecret = ''; // Your Spotify app client secret
const node = {
	host: 'localhost',
	port: 1234,
	password: 'password'
};

const spotilink =  new SpotifyParser(node, spotifyID, spotifySecret);

// Get a song title
const song = await spotilink.getTrack('1Cv1YLb4q0RzL6pybtaMLo'); // { artists: [ "Surfaces" ], name: "Sunday Best" }

// Get all songs from an album
const album = await spotilink.getAlbumTracks('7tcs1X9pzFvcLOPuhCstQJ'); // [ { artists: [ "Kygo", "Valerie Broussard" ], name: "The Truth" }, ... ]

// Get all songs from a playlist
const playlist = await spotilink.getPlaylistTracks('37i9dQZEVXbMDoHDwVN2tF') // [ { arists: [ "Cardi B", "Megan Thee Stallion" ], name: "WAP (feat. Megan Thee Stallion)" }, ... ]

// Fetch song from the Lavalink API
const track = await spotilink.fetchTrack(song) // { track: "", info: {} }
				.catch(() => console.log("No track found."));

// Fetch songs from playlists from the Lavalink API
const tracks = [];
await Promise.all(album.map(async (name) => tracks.push(await spotilink.fetchTrack(name))));
// 'tracks' will now contain Lavalink track objects.
// SpotifyParser#fetchTrack will only return the track object, giving you complete freedom and control on how you handle the Lavalink tracks. :)

The following methods below, if true is passed as the second parameter, will call Spotilink#fetchTrack and return a Lavalink object (an array of them for getAlbumTracks and getPlaylistTracks) instead of song titles and artists.

// Get a song in the form of a Lavalink object.
const lavalinkSong = await spotilink.getTrack('1Cv1YLb4q0RzL6pybtaMLo', true);
// Get all songs from an album in the form of an array of Lavalink objects.
const album = await spotilink.getAlbumTracks('7tcs1X9pzFvcLOPuhCstQJ', true);
// Get all songs from a playlist in the form of an array of Lavalink objects.
const playlist = await spotilink.getPlaylistTracks('37i9dQZEVXbMDoHDwVN2tF', true);

You can use custom functions to manipulate the search results. The default search results are filtered to those auto-generated by YouTube, but you can disable this using the autoGeneratedOnly option. For the three main methods used, you can pass an object containing the functions for filtering and sorting. By default, no filtering and sorting takes place — whichever track that Lavalink may have received first will be returned.

// Disable filtering search results to only those auto-generated by YouTube.
spotilink.getTrack('track ID', , { autoGeneratedOnly: false });

// Prioritize Lavalink tracks with the same duration as the Spotify track.
spotilink.getTrack('track ID', , { prioritizeSameDuration: true });

// Use a custom synchronous function for filtering search results
// The synchronous function being passed must return a boolean type variable
spotilink.getAlbumTracks('album ID', , { customFilter: (lavalinkTrack, spotifyTrack) => lavalinkTrack.info.title === spotifyTrack.name })

// Use a custom synchronous function for sorting search results
// The synchronous function being passed must return a number type variable
// Variables `comparableTrack` and `compareToTrack` are of LavalinkTrack types
spotilink.getPlaylistTracks('playlist ID', , { customSort: (comparableTrack, compareToTrack, spotifyTrack) => comparableTrack.info.title === spotifyTrack.name ? -1 : 1 })

Please note that if you use the option prioritizeSameDuration, the other options mentioned will be unused. The options customFilter and customSort however, may be used together as long as prioritizeSameDuration is set to false.

Contributors

Thanks goes to these wonderful people (emoji key):


TheFloppyBanana

💻 📖 💡 🤔

Dwigoric

💻 🤔

X-49

🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].