npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

spotify-to-yt

v1.1.1

Published

Simple package to get information from Spotify and convert it to YouTube, you can use it in your music module so that your bot can easily play Spotify tracks and playlists, as well as URL's validation systems.

Downloads

27

Readme

spotify-to-yt

Simple package to get information from Spotify and convert it to YouTube, you can use it in your music module so that your bot can easily play Spotify tracks and playlists, as well as URL's validation systems.

Features

  • Very easy to use system
  • Multiple functions to use
  • Works with ALL current music modules

Why spotify-to-yt?

spotify-to-yt is the only package with such useful and very easy to use methods. I made this package because I saw people trying to create music robots with Spotify, but they couldn't do it because they had no experience in it, so here I bring you a very good solution. Simple and easy to use. Works from NodeJS v12 onwards!

Changelogs

v1.0.8 - v1.0.9 - v1.1.0

  • We go back to JavaScript, some errors do not allow it to work correctly.

v1.0.7

  • Package export errors have been fixed.

v1.0.6

  • The package has been changed to TypeScript, it still works with JavaScript correctly.

v1.0.5

  • Fixed a bug in the trackSearch method that returned undefined.
  • Fixed errors in README.md

v1.0.4

  • Added info result by requiring most results.

v1.0.3

  • Added method trackSearch, to search for tracks on Spotify

v1.0.2

  • Errors in README.md

v1.0.1

  • Errors in README.md

📂 | Install

npm install spotify-to-yt@latest

📜 | Setup:

const spotifyToYT = require("spotify-to-yt")

📥 | Methods

trackGet

spotifyToYT.trackGet("<URL of Spotify track or Spotify Name Song>")

Returns a YouTube URL to play music with the "play" property of your preferred music npm.

📌 | How to use:

  1. URL of Spotify track or Spotify Name Song: URL of the Spotify track or the song name of the same

✍ | Example with Distube Module:

const Discord = require("discord.js") //Define Discord
const client = new Discord.Client() //Define client
const Distube = require("distube") //Define Distube
client.distube = new Distube(client, { searchSongs: 10 }) //Define Distube Client
const spotifyToYT = require("spotify-to-yt") //Define package
const settings = {
    prefix: "!", //Define bot prefix
    token: "Discord Bot Token" //Define bot token
}


client.on('message', async message => { //Create message event
    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g) //Define args
    const command = args.shift().toLowerCase() //Define command
   
    if (command === "play") { //Create new command
        const track = args.join(" ") //Define URL
        const result = await spotifyToYT.trackGet(track) //Obtain Spotify Track Info and YouTube link URL
        client.distube.play(message, result.url).catch(e => console.error(e)) //Play music with message parameter and result constant
    }
})

client.login(settings.token) //Login bot

playListGet

spotifyToYT.playListGet("<URL of Spotify Playlist>")

Returns an Array of YouTube music URL's to play a playlist with your preferred music npm.

📌 | How to use:

  1. URL of Spotify Playlist: Spotify playlist URL

✍ | Example with Distube Module:

const Discord = require("discord.js") //Define Discord
const client = new Discord.Client() //Define client
const Distube = require("distube") //Define Distube
client.distube = new Distube(client, { searchSongs: 10 }) //Define Distube Client
const spotifyToYT = require("spotify-to-yt") //Define package
const settings = {
    prefix: "!", //Define bot prefix
    token: "Discord Bot Token" //Define bot token
}

client.on('message', async message => { //Create message event
    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g) //Define args
    const command = args.shift().toLowerCase() //Define command
   
    if (command === "playlist") { //Create new command
        const playlist = args.join(" ") //Define URL
        const result = await spotifyToYT.playListGet(playlist) //Obtain YouTube link of Spotify
       client.distube.playCustomPlaylist(message, result.songs, { name: result.info.name, thumbnail: result.info.images[0].url, url: result.info.externals_url.spotify }).catch(e => console.error(e)) //Play playlist with message parameter, and get YouTube links of Spotify in Array
    }
})

client.login(settings.token) //Login bot

isTrackOrPlaylist

spotifyToYT.isTrackOrPlaylist("<URL of Spotify Playlist or URL of Spotify Track>")

Returns a String, if it is a playlist or a track

📌 | How to use:

  1. URL of Spotify Playlist or URL of Spotify Track: URL of Spotify playlist or Spotify track

✍ | Example:

const Discord = require("discord.js") //Define Discord
const client = new Discord.Client() //Define client
const spotifyToYT = require("spotify-to-yt") //Define package
const settings = {
    prefix: "!", //Define bot prefix
    token: "Discord Bot Token" //Define bot token
}

client.on('message', async message => { //Create message event
    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g) //Define args
    const command = args.shift().toLowerCase() //Define command
   
    if (command === "track-or-playlist") { //Create new command
        const url = args.join(" ") //Define URL
        const result = await spotifyToYT.isTrackOrPlaylist(url) //Obtain YouTube link of Spotify
        message.channel.send("The link is: **" + result + "**") //Send message
    }
})

client.login(settings.token) //Login bot

validateURL

spotifyToYT.validateURL("<URL>")

Validate a URL from Spotify and return a Boolean as the result

📌 | How to use:

  1. URL: URL to validate

✍ | Example:

const Discord = require("discord.js") //Define Discord
const client = new Discord.Client() //Define client
const spotifyToYT = require("spotify-to-yt") //Define package
const settings = {
    prefix: "!", //Define bot prefix
    token: "Discord Bot Token" //Define bot token
}

client.on('message', async message => { //Create message event
    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g) //Define args
    const command = args.shift().toLowerCase() //Define command
   
    if (command === "validate-url") { //Create new command
        const validate = await spotifyToYT.validateURL(args.join(" ")) //Validate Spotify URL
        const result = validate ? "Valid link" : "Invalid Link" //Make a conditional, where if it returns true, the first parameter is executed, otherwise the second is executed
        message.channel.send("This link is: **" + result + "**") //Send message
    }
})

client.login(settings.token) //Login bot

trackSearch

spotifyToYT.trackSearch("<Term to Search>")

Search track on Spotify and return URL

📌 | How to use:

  1. Term to Search: Term to search on Spotify

✍ | Example:

const Discord = require("discord.js") //Define Discord
const client = new Discord.Client() //Define client
const spotifyToYT = require("spotify-to-yt") //Define package
const settings = {
    prefix: "!", //Define bot prefix
    token: "Discord Bot Token", //Define bot token
    clientID: "Client Spotify App ID", //Define Spotify Client ID, obtain of 'https://developer.spotify.com/dashboard/'
    secretKey: "Secret Key Spotify App" //Define Secret Key, obtain of 'https://developer.spotify.com/dashboard/'
}
spotifyToYT.setCredentials(settings.clientID, settings.secretKey) //Set credentials for method 'trackSearch'

client.on('message', async message => { //Create message event
    const args = message.content.slice(settings.prefix.length).trim().split(/ +/g) //Define args
    const command = args.shift().toLowerCase() //Define command
   
    if (command === "spotify-search") { //Create new command
        const result = await spotifyToYT.trackSearch(args.join(" ")).catch(e => message.channel.send("No results")) //Declare result, with trackSearch property, and catch for errors
        message.channel.send(result.url) //Send message with URL of Spotify
    }
})

client.login(settings.token) //Login bot

❓ | Do you need more help?

If you have problems with the package, but I don't think you have them, this package is very easy to use, but just in case, here is my Discord server, for support.

https://discord.gg/R8NKJHxuyh

🔧 | Creator

Yeral_Andre | Yeral_Andre#0001