NuclearPlayer / extract-sptf-playlist

You know what it's for (extracting spotify and youtube playlist via puppeteer without login)
GNU General Public License v3.0
25 stars 2 forks source link
spotify-playlist youtube-playlist

extract-sptf-playlist

Install

npm install --save extract-sptf-playlist

Example

const { getSpotifyPlaylist, getYoutubePlaylist } = require('extract-sptf-playlist');
const url =
  'https://open.spotify.com/playlist/3TtYojG66KzrYHR58t5kjZ?si=W1mw5t4zQHKFkaUofbw_ig&nd=1';

const playlist = await getSpotifyPlaylist(url);

For Youtube playlist, set option param usePuppeteer to false to use ytpl library instead of puppeteer, check file exampleYoutubeWithYtpl.js for example.

Result format

{
  "name": "ultimate vibezzzzz",
  "numberOfTrack": 105,
  "source": "Youtube",
  "tracks": [
    {
      "index": 2,
      "thumbnail": "https://i.scdn.co/image/ab67616d000048510d5a84e4e47399d2726c330c",
      "title": "20 Min",
      "album": "Luv Is Rage 2 (Deluxe)",
      "duration": "3:40",
      "artist": "Lil Uzi Vert",
      "otherArtists": []
    },
  ]
}

Options

const { getYoutubePlaylist, defaultYoutubeTrackFormatter } = require('extract-sptf-playlist');

getSpotifyPlaylist(url, { trackFormatterFn: defaultYoutubeTrackFormatter });

const customFormatter = (track) => {
  track.title = track.title.toLowerCase();
  return track;
};

getSpotifyPlaylist(url, { trackFormatterFn: customFormatter });