A stable, updated and powerful music library with support for Spotify and YouTube.
To install melodify
, use npm:
npm install @gamestwolife/melodify
import { Melodify, LoadType } from "@gamestwolife/melodify";
const clientId = "your-client-id";
const clientSecret = "your-client-secret";
const apiKey = "your-youtube-api-key";
(async() => {
const melodify = new Melodify({
spotifyClientId: clientId,
spotifyClientSecret: clientSecret
youtubeApiKey: apiKey
});
const search = await melodify.searchProvider.search("Never Gonna Give You Up");
switch (search.loadType) {
case LoadType.SEARCH:
{
const trackName = `${search.data.tracks.items[0].artists.map(artist => artist.name).join(", ")} - ${search.data.tracks.items[0].name}`;
console.log(`[${search.loadType}] Track "${trackName}" downloading...`);
const filePath = await melodify.downloadTrack(trackName);
console.log(filePath);
}
break;
}
})()