update readme

This commit is contained in:
Sayem Chowdhury 2021-02-23 21:15:00 +06:00
parent 18b39bf59f
commit 4e21c62402

View File

@ -17,20 +17,20 @@ import axios from 'axios';
import fs from 'fs'; import fs from 'fs';
import * as api from 'd-fi-core'; import * as api from 'd-fi-core';
// Init api with arl // Init api with arl from cookie
await api.initDeezerApi(arl_from_cookie); await api.initDeezerApi(arl_cookie);
// GET Track Object // GET Track Object
const track = await api.getTrackInfo(SNG_ID); const track = await api.getTrackInfo(song_id);
// Parse download URL for 128kbps // Parse download URL for 128kbps
const url = getTrackDownloadUrl(track, 1); const url = api.getTrackDownloadUrl(track, 1);
// Download encrypted track // Download encrypted track
const {data} = await axios.get(url, {responseType: 'arraybuffer'}); const {data} = await axios.get(url, {responseType: 'arraybuffer'});
// Decrypt track // Decrypt track
const decryptedTrack = decryptDownload(data, track.SNG_ID); const decryptedTrack = api.decryptDownload(data, track.SNG_ID);
// Add id3 metadata // Add id3 metadata
const trackWithMetadata = await api.addTrackTags(decryptedTrack, track, false, 500); const trackWithMetadata = await api.addTrackTags(decryptedTrack, track, false, 500);
@ -123,6 +123,20 @@ All method returns `Object` or throws `Error`. Make sure to catch error on your
| `types` | No | `array` | ['TRACK'] | array of search types | | `types` | No | `array` | ['TRACK'] | array of search types |
| `limit` | No | `number` | 15 | maximum item to fetch per 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 |
### Donations ### Donations
If you want to show your appreciation, you can donate me on [ko-fi](https://ko-fi.com/Z8Z5KDA6) or [buy me a coffee](https://www.buymeacoffee.com/sayem). Thanks! If you want to show your appreciation, you can donate me on [ko-fi](https://ko-fi.com/Z8Z5KDA6) or [buy me a coffee](https://www.buymeacoffee.com/sayem). Thanks!