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

d-fi-core

v1.3.5

Published

Core module for d-fi

Downloads

190

Readme

d-fi-core Test

d-fi is a streaming music downloader. This core module is designed to be used on future version of d-fi.

Installation

$ yarn add d-fi-core

Usage

Here's a simple example to download tracks.

import axios from 'axios';
import fs from 'fs';
import * as api from 'd-fi-core';

// Init api with arl from cookie
await api.initDeezerApi(arl_cookie);

// Verify user
try {
  const user = await api.getUser();
  // Successfully logged in
  console.log('Logged in as ' + user.BLOG_NAME);
} catch (err) {
  // Invalid arl cookie set
  console.error(err.message);
}

// GET Track Object
const track = await api.getTrackInfo(song_id);

// Parse download URL for 128kbps
const trackData = await api.getTrackDownloadUrl(track, 1);

// Download track
const {data} = await axios.get(trackdata.trackUrl, {responseType: 'arraybuffer'});

// Decrypt track if needed
const outFile = trackData.isEncrypted ? api.decryptDownload(data, track.SNG_ID) : data;

// Add id3 metadata
const trackWithMetadata = await api.addTrackTags(outFile, track, 500);

// Save file to disk
fs.writeFileSync(track.SNG_TITLE + '.mp3', trackWithMetadata);

Read FAQ

Methods

All method returns Object or throws Error. Make sure to catch error on your side.

.initDeezerApi(arl_cookie);

It is recommended that you first init the app with this method using your arl cookie.

| Parameters | Required | Type | | ------------ | :------: | -------: | | arl_cookie | Yes | string |

.getTrackInfo(track_id);

| Parameters | Required | Type | | ---------- | :------: | -------: | | track_id | Yes | string |

.getLyrics(track_id);

| Parameters | Required | Type | | ---------- | :------: | -------: | | track_id | Yes | string |

.getAlbumInfo(album_id);

| Parameters | Required | Type | | ---------- | :------: | -------: | | album_id | Yes | string |

.getAlbumTracks(album_id);

| Parameters | Required | Type | | ---------- | :------: | -------: | | album_id | Yes | string |

.getPlaylistInfo(playlist_id);

| Parameters | Required | Type | | ------------- | :------: | -------: | | playlist_id | Yes | string |

.getPlaylistTracks(playlist_id);

| Parameters | Required | Type | | ------------- | :------: | -------: | | playlist_id | Yes | string |

.getArtistInfo(artist_id);

| Parameters | Required | Type | | ----------- | :------: | -------: | | artist_id | Yes | string |

.getDiscography(artist_id, limit);

| Parameters | Required | Type | Default | Description | | ----------- | :------: | -------: | ------: | ----------------------: | | artist_id | Yes | string | - | artist id | | limit | No | number | 500 | maximum tracks to fetch |

.getProfile(user_id);

| Parameters | Required | Type | | ---------- | :------: | -------: | | user_id | Yes | string |

.searchAlternative(artist_name, song_name);

| Parameters | Required | Type | | ------------- | :------: | -------: | | artist_name | Yes | string | | song_name | Yes | string |

.searchMusic(query, types, limit);

| Parameters | Required | Type | Default | Description | | ---------- | :------: | -------: | --------: | ------------------------------: | | query | Yes | string | - | search query | | types | No | array | ['TRACK'] | array of search types | | limit | No | number | 15 | maximum item to fetch per types |

.getTrackDownloadUrl(track, quality);

| Parameters | Required | Type | Description | | ---------- | :------: | ----------: | ---------------------------------: | | track | Yes | string | track object | | quality | Yes | 1, 3 or 9 | 1 = 128kbps, 3 = 320kbps, 9 = flac |

.decryptDownload(data, song_id);

| Parameters | Required | Type | Description | | ---------- | :------: | -------: | ---------------------: | | data | Yes | buffer | downloaded song buffer | | song_id | Yes | string | track id |

.addTrackTags(data, track,coverSize)

| Parameters | Required | Type | Description | | ----------- | :------: | --------: | ---------------------: | | data | Yes | buffer | downloaded song buffer | | track | Yes | string | track object | | coverSize | No | 56-1800 | cover art size |

Donations

If you want to show your appreciation, you can donate me on ko-fi or buy me a coffee. Thanks!

Made with :heart: & :coffee: by Sayem