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

url-song-utilities

v1.0.2

Published

A module to get information on multiple music services !

Downloads

9

Readme

A module to get information about music titles and even be able to download them !

🏓 Installation

npm i url-song-utilities

✨ Utilisation

Available methods :

#Search a music
<module>.searchSong('<song>')

#Find the type of an url
<module>.sourceUrl('<URL>')

#Search for music lyrics
<module>.getLyrics('<song>')

#Download a music with a YouTube url
<module>.download('<URL>')

#Changing the url of a YouTube video
<module>.toPlayableLink('<YouTube URL>')

Examples :

  • For the following examples we will define player as follows :
const player = require('url-song-utilities');
  • Search a music
//The bot will try to get information about the music
await player.searchSong('PETIT BISCUIT - Sunset Lover').then(song => {
    //It returns the information to the console
    console.log(song);
}).catch(err => {
    //If the module did not find the music it returns a error
    console.log('No music found !');
})
  • Find the type of an url (we will use a YouTube URL for the example)
//The bot will try to find the source of the provided url (YouTube or Spotify)
await player.sourceUrl('https://youtu.be/k2qgadSvNyU').then(data => {
    //If the module returns 'undefined', the source is not found
    if (!data) return console.log('Cannot determine the source !');
    //If the module finds the source
    console.log(data);
})
  • Search for music lyrics
//The bot will try to find the lyrics of the music
await player.getLyrics('Luis Fonsi - Despacito').then(lyrics => {
    //If the module returns 'undefined' it means that the module did not find any lyrics
    if (!lyrics) return console.log('I did not find any lyrics !');
    //If the module finds lyrics
    console.log(lyrics);
})
  • Download a music with a URL
//The bot will need the fs module function to save the file
const { createWriteStream } = require("fs");
//The bot will search for the music
await player.download('https://youtu.be/nceqQyqIa5o').then(stream => {
    //The bot will record the music under './song.mp3'
    //You can use other formats such as (mp3, mp4...)
    stream.pipe(createWriteStream('song.mp3'));
})
  • Changing the url of a YouTube video
//The bot will try to transform the music
await player.toPlayableLink('https://youtu.be/ZMqhjKRUGsY').then(url => {
    //If the module returns 'undefined', it means that the module did not find the music
    if (!url) return console.log('No music found !');
    //If the module succeeded in generating a link
    console.log(url);
})
  • Result of a search (example : TROLLZ - 6ix9ine with Nicki Minaj)
{
  title: 'TROLLZ - 6ix9ine with Nicki Minaj (Official Lyric Video)',
  id: '-wts5viH28E',
  url: 'https://www.youtube.com/watch?v=-wts5viH28E',
  channel: {
    name: 'Tekashi 6ix9ine',
    url: 'https://www.youtube.com/channel/UCF6jRAgCbSanHolKt0Vt6Qw'
  },
  thumbnail: 'https://i.ytimg.com/vi/-wts5viH28E/hqdefault.jpg?sqp=-oaymwEjCNACELwBSFryq4qpAxUIARUAAAAAGAElAADIQj0AgKJDeAE=&rs=AOn4CLDDvxmF9oWa7wca5PXqcYcDvJi-_w',
  duration: 204,
  source: 'YouTube'
}

🎉 Bonus

  • Download event
//The bot will need the fs module function to save the file
const { createWriteStream } = require("fs");
//The bot will search for the music
await player.download('https://youtu.be/nceqQyqIa5o').then(stream => {
    //The bot will record the music under './song.mp3'
    //You can use other formats such as (mp3, mp4...)
    stream.pipe(createWriteStream('song.mp3')).on('finish', () => {
        //When the file will be downloaded the bot will send back a message
        console.log('Music downloaded !');
    })
})
  • Search and download
//The bot will need the fs module function to save the file
const { createWriteStream } = require("fs");
//The bot will search for the music (on Spotify for example)
await player.searchSong('https://open.spotify.com/track/22LAwLoDA5b4AaGSkg6bKW').then(async song => {
    await player.download(song.url).then(stream => {
        //The bot will download the file with the name it has found
        stream.pipe(createWriteStream(song.title + '.mp3'));
    })
}).catch(err => {
    //If the module did not find the music it returns a error
    return console.log('No music found !');
})
  • Changing the url of a YouTube video (example : EJS)

Why use the toPlayableLink() function ? This function transforms a YouTube link into a Google Drive link, which can be read in sites such as (HTML, EJS...). Without using this function it will be impossible to play the requested video directly with the YouTube link.

<!-- const player = require('url-song-utilities'); -->
<!-- var data = await player.searchSong('HUGEL feat. Amber Van Day - Mamma Mia (Official Video)'); -->
<!-- var stream = await player.toPlayableLink(data.url); -->

<figure>
    <figcaption>You are currently listening to : <%= data.title %></figcaption>
    <audio controls src="<%= stream %>">
        Your browser does not support the <code>audio</code> element.
    </audio>
</figure>

👤 Developers

This project was designed by Zerio & Simon.

🤝 Contributing

Contributions, issues and feature requests are welcome !Feel free to check issues page.

📝 License

Copyright © 2020 Zerio & Simon.

Give a ⭐️ (on the Github project) if this project helped you !