Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

d-fi-core

Package Overview
Dependencies
Maintainers
2
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d-fi-core

Core module for d-fi

  • 1.3.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

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.

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

ParametersRequiredType
arl_cookieYesstring

.getTrackInfo(track_id);

ParametersRequiredType
track_idYesstring

.getLyrics(track_id);

ParametersRequiredType
track_idYesstring

.getAlbumInfo(album_id);

ParametersRequiredType
album_idYesstring

.getAlbumTracks(album_id);

ParametersRequiredType
album_idYesstring

.getPlaylistInfo(playlist_id);

ParametersRequiredType
playlist_idYesstring

.getPlaylistTracks(playlist_id);

ParametersRequiredType
playlist_idYesstring

.getArtistInfo(artist_id);

ParametersRequiredType
artist_idYesstring

.getDiscography(artist_id, limit);

ParametersRequiredTypeDefaultDescription
artist_idYesstring-artist id
limitNonumber500maximum tracks to fetch

.getProfile(user_id);

ParametersRequiredType
user_idYesstring

.searchAlternative(artist_name, song_name);

ParametersRequiredType
artist_nameYesstring
song_nameYesstring

.searchMusic(query, types, limit);

ParametersRequiredTypeDefaultDescription
queryYesstring-search query
typesNoarray['TRACK']array of search types
limitNonumber15maximum item to fetch per types

.getTrackDownloadUrl(track, quality);

ParametersRequiredTypeDescription
trackYesstringtrack object
qualityYes1, 3 or 91 = 128kbps, 3 = 320kbps, 9 = flac

.decryptDownload(data, song_id);

ParametersRequiredTypeDescription
dataYesbufferdownloaded song buffer
song_idYesstringtrack id

.addTrackTags(data, track,coverSize)

ParametersRequiredTypeDescription
dataYesbufferdownloaded song buffer
trackYesstringtrack object
coverSizeNo56-1800cover 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

FAQs

Package last updated on 12 Apr 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc