项目作者: EmmanuelBeziat

项目描述 :
🔉 JS tool to parse audio services (Spotify, Deezer, YouTube) url to get a song ID
高级语言: JavaScript
项目地址: git://github.com/EmmanuelBeziat/get-audio-id.git
创建时间: 2019-02-16T02:42:00Z
项目社区:https://github.com/EmmanuelBeziat/get-audio-id

开源协议:MIT License

下载


🔉 get-audio-id

JS tool to parse music streaming services url (Spotify, Deezer, Youtube, …) to get a song ID.

Important Note: This work is a fork-ish of get-video-id from @radiovisual, but meant to use audio services (Spotify, Deezer, etc.). Credits for the work should go to him.

Purpose

This module will extract the Spotify, Deezer, including embed strings.

Wait, why would I want to do that?

That’s a good question, thanks for asking.

Let’s say you want your users to easily share their favorites songs. You can either share them a long list of tutorials to correctly embed players from multiple services, and hope that they don’t mess up (they will). Or, you can just as them for any kind of url/share protocol from any service, and then just treat the data to render the correct player with the desired song.

That’s what this little tool is used for.

Install

  1. $ npm install --save get-audio-id

Usage

Just call the class with a spotify/deezer url (or embed string) as a parameter. Its metadata (id and service) will be extracted.

  1. import GetAudioId from 'get-audio-id'
  2. const audio = new GetAudioId('spotify:track:5uunXHE4kIW6uS4HWAXaOQ')
  3. audio.getId()
  4. // => {id: '5uunXHE4kIW6uS4HWAXaOQ', service: 'spotify' }

You can throw it a few types of url/strings:

  1. 'spotify:track:5uunXHE4kIW6uS4HWAXaOQ',
  2. 'https://open.spotify.com/track/5uunXHE4kIW6uS4HWAXaOQ',
  3. 'https://open.spotify.com/track/5uunXHE4kIW6uS4HWAXaOQ?si=6DD5tNAsRWieSursZHRm0A',
  4. '<iframe src="https://open.spotify.com/embed/track/5uunXHE4kIW6uS4HWAXaOQ" width="300" height="380" frameborder="0" allowtransparency="true" allow="encrypted-media"></iframe>',
  5. 'https://www.deezer.com/en/track/126338363',
  6. 'https://www.youtube.com/watch?v=iVvXB-Vwnco',
  7. 'https://www.youtube.com/watch?v=iVvXB-Vwnco&feature=youtu.be&t=172',
  8. 'https://youtu.be/iVvXB-Vwnco',
  9. 'https://youtu.be/iVvXB-Vwnco?t=106',
  10. '<iframe width="560" height="315" src="https://www.youtube.com/embed/iVvXB-Vwnco" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'

Need more services?

If you need this tool to be enhanced with more string formats, more services, etc., you can either open a Ticket and ask me, or submit a pull request of your work (just please follow the same coding guidelines).

License

MIT