q-fi-core 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +109 -0
- package/LICENSE +1 -0
- package/README.md +186 -0
- package/dist/api/api.d.ts +78 -0
- package/dist/api/api.js +182 -0
- package/dist/api/cache.d.ts +3 -0
- package/dist/api/cache.js +12 -0
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +18 -0
- package/dist/api/request.d.ts +23 -0
- package/dist/api/request.js +88 -0
- package/dist/converter/deezer.d.ts +3 -0
- package/dist/converter/deezer.js +45 -0
- package/dist/converter/index.d.ts +5 -0
- package/dist/converter/index.js +34 -0
- package/dist/converter/parse.d.ts +18 -0
- package/dist/converter/parse.js +176 -0
- package/dist/converter/spotify.d.ts +40 -0
- package/dist/converter/spotify.js +154 -0
- package/dist/converter/tidal.d.ts +146 -0
- package/dist/converter/tidal.js +199 -0
- package/dist/converter/youtube.d.ts +6 -0
- package/dist/converter/youtube.js +102 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +24 -0
- package/dist/lib/decrypt.d.ts +9 -0
- package/dist/lib/decrypt.js +63 -0
- package/dist/lib/fast-lru.d.ts +63 -0
- package/dist/lib/fast-lru.js +121 -0
- package/dist/lib/get-url.d.ts +16 -0
- package/dist/lib/get-url.js +154 -0
- package/dist/lib/http.d.ts +66 -0
- package/dist/lib/http.js +235 -0
- package/dist/lib/metaflac-js.d.ts +124 -0
- package/dist/lib/metaflac-js.js +343 -0
- package/dist/lib/request.d.ts +18 -0
- package/dist/lib/request.js +86 -0
- package/dist/metadata-writer/abumCover.d.ts +10 -0
- package/dist/metadata-writer/abumCover.js +37 -0
- package/dist/metadata-writer/flacmetata.d.ts +3 -0
- package/dist/metadata-writer/flacmetata.js +80 -0
- package/dist/metadata-writer/getTrackLyrics.d.ts +2 -0
- package/dist/metadata-writer/getTrackLyrics.js +26 -0
- package/dist/metadata-writer/id3.d.ts +3 -0
- package/dist/metadata-writer/id3.js +119 -0
- package/dist/metadata-writer/index.d.ts +9 -0
- package/dist/metadata-writer/index.js +44 -0
- package/dist/metadata-writer/musixmatchLyrics.d.ts +1 -0
- package/dist/metadata-writer/musixmatchLyrics.js +39 -0
- package/dist/metadata-writer/useragents.d.ts +1 -0
- package/dist/metadata-writer/useragents.js +86 -0
- package/dist/types/album.d.ts +123 -0
- package/dist/types/album.js +2 -0
- package/dist/types/artist.d.ts +36 -0
- package/dist/types/artist.js +2 -0
- package/dist/types/channel.d.ts +33 -0
- package/dist/types/channel.js +2 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.js +26 -0
- package/dist/types/playlist-channel.d.ts +81 -0
- package/dist/types/playlist-channel.js +2 -0
- package/dist/types/playlist.d.ts +49 -0
- package/dist/types/playlist.js +2 -0
- package/dist/types/profile.d.ts +29 -0
- package/dist/types/profile.js +2 -0
- package/dist/types/radio.d.ts +7 -0
- package/dist/types/radio.js +2 -0
- package/dist/types/search.d.ts +79 -0
- package/dist/types/search.js +2 -0
- package/dist/types/show.d.ts +61 -0
- package/dist/types/show.js +2 -0
- package/dist/types/tracks.d.ts +144 -0
- package/dist/types/tracks.js +2 -0
- package/dist/types/user.d.ts +16 -0
- package/dist/types/user.js +2 -0
- package/package.json +69 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +3 -0
- package/types/package.json +4 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 2.3.1 - 2026-08-30
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- Renamed the package from `@soulwax/d-fi-core` to the unscoped **`q-fi-core`** ("q" = quality). No API changes. Update imports from `@soulwax/d-fi-core` → `q-fi-core` and `@soulwax/d-fi-core/types` → `q-fi-core/types`.
|
|
8
|
+
|
|
9
|
+
## 2.3.0 - 2026-05-28
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Completed the Tier 3 performance rollup for the core release line.
|
|
14
|
+
- Reused HTTP connections, removed the common media URL HEAD probe, optimized decrypt buffer handling, and avoided redundant metadata writer buffer wrapping.
|
|
15
|
+
|
|
16
|
+
## 2.2.5 - 2026-05-28
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
|
|
20
|
+
- Avoided redundant output buffer wrapping in FLAC and MP3 metadata writers.
|
|
21
|
+
|
|
22
|
+
## 2.2.4 - 2026-05-28
|
|
23
|
+
|
|
24
|
+
### Changed
|
|
25
|
+
|
|
26
|
+
- Reworked encrypted audio decryption to copy buffers directly instead of round-tripping chunks through binary strings.
|
|
27
|
+
|
|
28
|
+
## 2.2.3 - 2026-05-28
|
|
29
|
+
|
|
30
|
+
### Changed
|
|
31
|
+
|
|
32
|
+
- Skipped the extra HEAD size probe for media-server download URLs and reused track metadata for the reported size.
|
|
33
|
+
|
|
34
|
+
## 2.2.2 - 2026-05-28
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
|
|
38
|
+
- Reused HTTP and HTTPS connections with shared keep-alive agents in the internal transport.
|
|
39
|
+
|
|
40
|
+
## 2.2.1 - 2026-05-28
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
|
|
44
|
+
- Cleanup.
|
|
45
|
+
|
|
46
|
+
## 2.2.0 - 2026-04-01
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
|
|
50
|
+
- Promoted the transport migration to the next minor publish line for `q-fi-core`, keeping the scoped package metadata and published `types/` subpath aligned for npm consumers.
|
|
51
|
+
- Reused Spotify anonymous tokens until expiry so Spotify URL parsing does not refetch a token on every request during a single process lifetime.
|
|
52
|
+
- Documented direct type imports from `q-fi-core/types` in the README for downstream TypeScript consumers.
|
|
53
|
+
|
|
54
|
+
### Fixed
|
|
55
|
+
|
|
56
|
+
- Stabilized live AVA coverage by explicitly skipping auth-gated and upstream-unavailable fixtures instead of failing the full publish verification run.
|
|
57
|
+
- Excluded shared test helpers from AVA discovery so release validation exits cleanly with the real test status.
|
|
58
|
+
|
|
59
|
+
## 2.1.0 - 2026-04-01
|
|
60
|
+
|
|
61
|
+
### Changed
|
|
62
|
+
|
|
63
|
+
- Removed the `axios` dependency in favor of an internal Node HTTP client with explicit JSON, text, binary, timeout, and redirect handling.
|
|
64
|
+
- Kept Deezer, Tidal, Spotify, YouTube, artwork, and Musixmatch requests on the same public library surface while making the transport layer dependency-light for publish.
|
|
65
|
+
- Updated the README download example and integration tests to use buffer-safe native Node networking instead of axios.
|
|
66
|
+
- Added a published `types/` subpath so consumers can resolve shared declarations from `q-fi-core/types`.
|
|
67
|
+
|
|
68
|
+
### Fixed
|
|
69
|
+
|
|
70
|
+
- Preserved binary downloads for encrypted audio, artwork, and test fixtures without relying on axios `arraybuffer` semantics.
|
|
71
|
+
- Preserved Deezer gateway retry behavior for auth refresh, gateway token refresh, and rate-limit backoff after the transport migration.
|
|
72
|
+
|
|
73
|
+
## 2.0.2 - 2026-03-26
|
|
74
|
+
|
|
75
|
+
### Changed
|
|
76
|
+
|
|
77
|
+
- Added an explicit npm package page link to the README for `q-fi-core`.
|
|
78
|
+
- Made the release lint scripts use the nested package's own ESLint config and plugin resolution.
|
|
79
|
+
|
|
80
|
+
### Fixed
|
|
81
|
+
|
|
82
|
+
- Published a fresh patch release so the scoped package page reflects the current package metadata and README content.
|
|
83
|
+
|
|
84
|
+
## 2.0.1 - 2026-03-26
|
|
85
|
+
|
|
86
|
+
### Changed
|
|
87
|
+
|
|
88
|
+
- Updated the npm license metadata to use a valid `SEE LICENSE IN LICENSE` expression.
|
|
89
|
+
|
|
90
|
+
### Fixed
|
|
91
|
+
|
|
92
|
+
- Corrected the README download example to use `trackData.trackUrl`.
|
|
93
|
+
- Aligned the README copyright and license note with the repository's current LICENSE file.
|
|
94
|
+
- Updated package ownership metadata to identify Christian Kling as the main developer.
|
|
95
|
+
|
|
96
|
+
## 2.0.0 - 2026-03-26
|
|
97
|
+
|
|
98
|
+
### Changed
|
|
99
|
+
|
|
100
|
+
- Renamed the npm package to `q-fi-core`.
|
|
101
|
+
- Updated package metadata to use the GitHub repository at `https://github.com/soulwax/q-fi-core`.
|
|
102
|
+
- Limited published npm package contents to runtime artifacts and release metadata.
|
|
103
|
+
- Moved the publish build hook to `prepublishOnly` so registry publishing no longer depends on install-time build behavior.
|
|
104
|
+
|
|
105
|
+
### Fixed
|
|
106
|
+
|
|
107
|
+
- Updated README and docs examples to use the scoped package name for install and import statements.
|
|
108
|
+
- Replaced the README FAQ link with a repository-local path so it follows the current default branch automatically.
|
|
109
|
+
- Allowed publish-time linting to work on Windows checkouts without normalizing the entire repository to LF first.
|
package/LICENSE
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Copyright Christian Kling 2024
|
package/README.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
# q-fi-core
|
|
2
|
+
|
|
3
|
+
q-fi (the **q** is for **quality**; formerly `d-fi`) is a streaming music downloader. This core module is designed to be used on future version of hexmusic, dabox server cluster and other services.
|
|
4
|
+
The source repository lives at <https://github.com/soulwax/q-fi-core>, and the npm package is published as `q-fi-core`.
|
|
5
|
+
The npm package page is <https://www.npmjs.com/package/q-fi-core>.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i q-fi-core
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add q-fi-core
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pnpm add q-fi-core
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Type declarations are also published under the `q-fi-core/types` subpath for consumers that want to import the shared library types directly.
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Here's a simple example to download tracks.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import fs from 'fs';
|
|
29
|
+
import {get} from 'https';
|
|
30
|
+
import * as api from 'q-fi-core';
|
|
31
|
+
|
|
32
|
+
const downloadBuffer = (url: string) =>
|
|
33
|
+
new Promise<Buffer>((resolve, reject) => {
|
|
34
|
+
get(url, (response) => {
|
|
35
|
+
const chunks: Buffer[] = [];
|
|
36
|
+
response.on('data', (chunk) => chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk)));
|
|
37
|
+
response.on('end', () => resolve(Buffer.concat(chunks)));
|
|
38
|
+
response.on('error', reject);
|
|
39
|
+
}).on('error', reject);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Init api with arl from cookie
|
|
43
|
+
await api.initDeezerApi(arl_cookie);
|
|
44
|
+
|
|
45
|
+
// Verify user
|
|
46
|
+
try {
|
|
47
|
+
const user = await api.getUser();
|
|
48
|
+
// Successfully logged in
|
|
49
|
+
console.log('Logged in as ' + user.BLOG_NAME);
|
|
50
|
+
} catch (err) {
|
|
51
|
+
// Invalid arl cookie set
|
|
52
|
+
console.error(err.message);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// GET Track Object
|
|
56
|
+
const track = await api.getTrackInfo(song_id);
|
|
57
|
+
|
|
58
|
+
// Parse download URL for 128kbps
|
|
59
|
+
const trackData = await api.getTrackDownloadUrl(track, 1);
|
|
60
|
+
|
|
61
|
+
// Download track
|
|
62
|
+
const data = await downloadBuffer(trackData.trackUrl);
|
|
63
|
+
|
|
64
|
+
// Decrypt track if needed
|
|
65
|
+
const outFile = trackData.isEncrypted ? api.decryptDownload(data, track.SNG_ID) : data;
|
|
66
|
+
|
|
67
|
+
// Add id3 metadata
|
|
68
|
+
const trackWithMetadata = await api.addTrackTags(outFile, track, 500);
|
|
69
|
+
|
|
70
|
+
// Save file to disk
|
|
71
|
+
fs.writeFileSync(track.SNG_TITLE + '.mp3', trackWithMetadata);
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### [Read FAQ](docs/faq.md)
|
|
75
|
+
|
|
76
|
+
## Methods
|
|
77
|
+
|
|
78
|
+
All method returns `Object` or throws `Error`. Make sure to catch error on your side.
|
|
79
|
+
|
|
80
|
+
### `.initDeezerApi(arl_cookie);`
|
|
81
|
+
|
|
82
|
+
> It is recommended that you first init the app with this method using your arl cookie.
|
|
83
|
+
|
|
84
|
+
| Parameters | Required | Type |
|
|
85
|
+
| ------------ | :------: | -------: |
|
|
86
|
+
| `arl_cookie` | Yes | `string` |
|
|
87
|
+
|
|
88
|
+
### `.getTrackInfo(track_id);`
|
|
89
|
+
|
|
90
|
+
| Parameters | Required | Type |
|
|
91
|
+
| ---------- | :------: | -------: |
|
|
92
|
+
| `track_id` | Yes | `string` |
|
|
93
|
+
|
|
94
|
+
### `.getLyrics(track_id);`
|
|
95
|
+
|
|
96
|
+
| Parameters | Required | Type |
|
|
97
|
+
| ---------- | :------: | -------: |
|
|
98
|
+
| `track_id` | Yes | `string` |
|
|
99
|
+
|
|
100
|
+
### `.getAlbumInfo(album_id);`
|
|
101
|
+
|
|
102
|
+
| Parameters | Required | Type |
|
|
103
|
+
| ---------- | :------: | -------: |
|
|
104
|
+
| `album_id` | Yes | `string` |
|
|
105
|
+
|
|
106
|
+
### `.getAlbumTracks(album_id);`
|
|
107
|
+
|
|
108
|
+
| Parameters | Required | Type |
|
|
109
|
+
| ---------- | :------: | -------: |
|
|
110
|
+
| `album_id` | Yes | `string` |
|
|
111
|
+
|
|
112
|
+
### `.getPlaylistInfo(playlist_id);`
|
|
113
|
+
|
|
114
|
+
| Parameters | Required | Type |
|
|
115
|
+
| ------------- | :------: | -------: |
|
|
116
|
+
| `playlist_id` | Yes | `string` |
|
|
117
|
+
|
|
118
|
+
### `.getPlaylistTracks(playlist_id);`
|
|
119
|
+
|
|
120
|
+
| Parameters | Required | Type |
|
|
121
|
+
| ------------- | :------: | -------: |
|
|
122
|
+
| `playlist_id` | Yes | `string` |
|
|
123
|
+
|
|
124
|
+
### `.getArtistInfo(artist_id);`
|
|
125
|
+
|
|
126
|
+
| Parameters | Required | Type |
|
|
127
|
+
| ----------- | :------: | -------: |
|
|
128
|
+
| `artist_id` | Yes | `string` |
|
|
129
|
+
|
|
130
|
+
### `.getDiscography(artist_id, limit);`
|
|
131
|
+
|
|
132
|
+
| Parameters | Required | Type | Default | Description |
|
|
133
|
+
| ----------- | :------: | -------: | ------: | ----------------------: |
|
|
134
|
+
| `artist_id` | Yes | `string` | - | artist id |
|
|
135
|
+
| `limit` | No | `number` | 500 | maximum tracks to fetch |
|
|
136
|
+
|
|
137
|
+
### `.getProfile(user_id);`
|
|
138
|
+
|
|
139
|
+
| Parameters | Required | Type |
|
|
140
|
+
| ---------- | :------: | -------: |
|
|
141
|
+
| `user_id` | Yes | `string` |
|
|
142
|
+
|
|
143
|
+
### `.searchAlternative(artist_name, song_name);`
|
|
144
|
+
|
|
145
|
+
| Parameters | Required | Type |
|
|
146
|
+
| ------------- | :------: | -------: |
|
|
147
|
+
| `artist_name` | Yes | `string` |
|
|
148
|
+
| `song_name` | Yes | `string` |
|
|
149
|
+
|
|
150
|
+
### `.searchMusic(query, types, limit);`
|
|
151
|
+
|
|
152
|
+
| Parameters | Required | Type | Default | Description |
|
|
153
|
+
| ---------- | :------: | -------: | --------: | ------------------------------: |
|
|
154
|
+
| `query` | Yes | `string` | - | search query |
|
|
155
|
+
| `types` | No | `array` | ['TRACK'] | array of search types |
|
|
156
|
+
| `limit` | No | `number` | 15 | maximum item to fetch per types |
|
|
157
|
+
|
|
158
|
+
### `.getTrackDownloadUrl(track, quality);`
|
|
159
|
+
|
|
160
|
+
| Parameters | Required | Type | Description |
|
|
161
|
+
| ---------- | :------: | ----------: | ---------------------------------: |
|
|
162
|
+
| `track` | Yes | `string` | track object |
|
|
163
|
+
| `quality` | Yes | `1, 3 or 9` | 1 = 128kbps, 3 = 320kbps, 9 = flac |
|
|
164
|
+
|
|
165
|
+
### `.decryptDownload(data, song_id);`
|
|
166
|
+
|
|
167
|
+
| Parameters | Required | Type | Description |
|
|
168
|
+
| ---------- | :------: | -------: | ---------------------: |
|
|
169
|
+
| `data` | Yes | `buffer` | downloaded song buffer |
|
|
170
|
+
| `song_id` | Yes | `string` | track id |
|
|
171
|
+
|
|
172
|
+
### `.addTrackTags(data, track,coverSize)`
|
|
173
|
+
|
|
174
|
+
| Parameters | Required | Type | Description |
|
|
175
|
+
| ----------- | :------: | --------: | ---------------------: |
|
|
176
|
+
| `data` | Yes | `buffer` | downloaded song buffer |
|
|
177
|
+
| `track` | Yes | `string` | track object |
|
|
178
|
+
| `coverSize` | No | `56-1800` | cover art size |
|
|
179
|
+
|
|
180
|
+
###
|
|
181
|
+
|
|
182
|
+
> We are not responsible for any misuse of this library by any third party. Please make sure to respect the artists and the music industry when using this library.
|
|
183
|
+
|
|
184
|
+
> Made with :heart: by the Bluesix Team. If you want to contribute, please read the [contributing guidelines](.github/CONTRIBUTING.md) first.
|
|
185
|
+
|
|
186
|
+
Copyright © 2026 Christian Kling, Saskia Falkenhagen, Jens Arnolds
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { albumType, trackType, lyricsType, albumTracksType, showType, playlistInfo, playlistTracksType, playlistChannelType, channelSearchType, artistInfoType, discographyType, profileType, searchType, trackTypePublicApi, albumTypePublicApi, userType } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* @param {String} sng_id song id
|
|
4
|
+
*/
|
|
5
|
+
export declare const getTrackInfoPublicApi: (sng_id: string) => Promise<trackTypePublicApi>;
|
|
6
|
+
/**
|
|
7
|
+
* @param {String} alb_id album id
|
|
8
|
+
*/
|
|
9
|
+
export declare const getAlbumInfoPublicApi: (alb_id: string) => Promise<albumTypePublicApi>;
|
|
10
|
+
/**
|
|
11
|
+
* @param {String} sng_id song id
|
|
12
|
+
*/
|
|
13
|
+
export declare const getTrackInfo: (sng_id: string) => Promise<trackType>;
|
|
14
|
+
/**
|
|
15
|
+
* @param {String} sng_id song id
|
|
16
|
+
*/
|
|
17
|
+
export declare const getLyrics: (sng_id: string) => Promise<lyricsType>;
|
|
18
|
+
/**
|
|
19
|
+
* @param {String} alb_id album id
|
|
20
|
+
*/
|
|
21
|
+
export declare const getAlbumInfo: (alb_id: string) => Promise<albumType>;
|
|
22
|
+
/**
|
|
23
|
+
* @param {String} alb_id user id
|
|
24
|
+
*/
|
|
25
|
+
export declare const getAlbumTracks: (alb_id: string) => Promise<albumTracksType>;
|
|
26
|
+
/**
|
|
27
|
+
* @param {String} playlist_id playlist id
|
|
28
|
+
*/
|
|
29
|
+
export declare const getPlaylistInfo: (playlist_id: string) => Promise<playlistInfo>;
|
|
30
|
+
/**
|
|
31
|
+
* @param {String} playlist_id playlist id
|
|
32
|
+
*/
|
|
33
|
+
export declare const getPlaylistTracks: (playlist_id: string) => Promise<playlistTracksType>;
|
|
34
|
+
/**
|
|
35
|
+
* @param {String} art_id artist id
|
|
36
|
+
*/
|
|
37
|
+
export declare const getArtistInfo: (art_id: string) => Promise<artistInfoType>;
|
|
38
|
+
/**
|
|
39
|
+
* @param {String} art_id artist id
|
|
40
|
+
* @param {String} nb number of total song to fetch
|
|
41
|
+
*/
|
|
42
|
+
export declare const getDiscography: (art_id: string, nb?: number) => Promise<discographyType>;
|
|
43
|
+
/**
|
|
44
|
+
* @param {String} user_id user id
|
|
45
|
+
*/
|
|
46
|
+
export declare const getProfile: (user_id: string) => Promise<profileType>;
|
|
47
|
+
/**
|
|
48
|
+
* @param {String} artist artist name
|
|
49
|
+
* @param {String} song song name
|
|
50
|
+
* @param {String} nb number of items to fetch
|
|
51
|
+
*/
|
|
52
|
+
export declare const searchAlternative: (artist: string, song: string, nb?: number) => Promise<searchType>;
|
|
53
|
+
type searchTypesProp = 'ALBUM' | 'ARTIST' | 'TRACK' | 'PLAYLIST' | 'RADIO' | 'SHOW' | 'USER' | 'LIVESTREAM' | 'CHANNEL';
|
|
54
|
+
/**
|
|
55
|
+
* @param {String} query search query
|
|
56
|
+
* @param {Array} types search types
|
|
57
|
+
* @param {Number} nb number of items to fetch
|
|
58
|
+
*/
|
|
59
|
+
export declare const searchMusic: (query: string, types?: searchTypesProp[], nb?: number) => Promise<searchType>;
|
|
60
|
+
/**
|
|
61
|
+
* Get details about current user
|
|
62
|
+
*/
|
|
63
|
+
export declare const getUser: () => Promise<userType>;
|
|
64
|
+
/**
|
|
65
|
+
* Get list of channles
|
|
66
|
+
*/
|
|
67
|
+
export declare const getChannelList: () => Promise<channelSearchType>;
|
|
68
|
+
/**
|
|
69
|
+
* @param {String} SHOW_ID show id
|
|
70
|
+
* @param {Number} NB number of items to fetch
|
|
71
|
+
* @param {Number} START start index
|
|
72
|
+
*/
|
|
73
|
+
export declare const getShowInfo: (SHOW_ID: string, NB?: number, START?: number) => Promise<showType>;
|
|
74
|
+
/**
|
|
75
|
+
* Get details about a playlist channel
|
|
76
|
+
*/
|
|
77
|
+
export declare const getPlaylistChannel: (page: string) => Promise<playlistChannelType>;
|
|
78
|
+
export {};
|
package/dist/api/api.js
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getPlaylistChannel = exports.getShowInfo = exports.getChannelList = exports.getUser = exports.searchMusic = exports.searchAlternative = exports.getProfile = exports.getDiscography = exports.getArtistInfo = exports.getPlaylistTracks = exports.getPlaylistInfo = exports.getAlbumTracks = exports.getAlbumInfo = exports.getLyrics = exports.getTrackInfo = exports.getAlbumInfoPublicApi = exports.getTrackInfoPublicApi = void 0;
|
|
4
|
+
const request_1 = require("./request");
|
|
5
|
+
/**
|
|
6
|
+
* @param {String} sng_id song id
|
|
7
|
+
*/
|
|
8
|
+
const getTrackInfoPublicApi = (sng_id) => (0, request_1.requestPublicApi)('/track/' + sng_id);
|
|
9
|
+
exports.getTrackInfoPublicApi = getTrackInfoPublicApi;
|
|
10
|
+
/**
|
|
11
|
+
* @param {String} alb_id album id
|
|
12
|
+
*/
|
|
13
|
+
const getAlbumInfoPublicApi = (alb_id) => (0, request_1.requestPublicApi)('/album/' + alb_id);
|
|
14
|
+
exports.getAlbumInfoPublicApi = getAlbumInfoPublicApi;
|
|
15
|
+
/**
|
|
16
|
+
* @param {String} sng_id song id
|
|
17
|
+
*/
|
|
18
|
+
const getTrackInfo = (sng_id) => (0, request_1.request)({ sng_id }, 'song.getData');
|
|
19
|
+
exports.getTrackInfo = getTrackInfo;
|
|
20
|
+
/**
|
|
21
|
+
* @param {String} sng_id song id
|
|
22
|
+
*/
|
|
23
|
+
const getLyrics = (sng_id) => (0, request_1.request)({ sng_id }, 'song.getLyrics');
|
|
24
|
+
exports.getLyrics = getLyrics;
|
|
25
|
+
/**
|
|
26
|
+
* @param {String} alb_id album id
|
|
27
|
+
*/
|
|
28
|
+
const getAlbumInfo = (alb_id) => (0, request_1.request)({ alb_id }, 'album.getData');
|
|
29
|
+
exports.getAlbumInfo = getAlbumInfo;
|
|
30
|
+
/**
|
|
31
|
+
* @param {String} alb_id user id
|
|
32
|
+
*/
|
|
33
|
+
const getAlbumTracks = async (alb_id) => (0, request_1.request)({ alb_id, lang: 'us', nb: -1 }, 'song.getListByAlbum');
|
|
34
|
+
exports.getAlbumTracks = getAlbumTracks;
|
|
35
|
+
/**
|
|
36
|
+
* @param {String} playlist_id playlist id
|
|
37
|
+
*/
|
|
38
|
+
const getPlaylistInfo = (playlist_id) => (0, request_1.request)({ playlist_id, lang: 'en' }, 'playlist.getData');
|
|
39
|
+
exports.getPlaylistInfo = getPlaylistInfo;
|
|
40
|
+
/**
|
|
41
|
+
* @param {String} playlist_id playlist id
|
|
42
|
+
*/
|
|
43
|
+
const getPlaylistTracks = async (playlist_id) => {
|
|
44
|
+
const playlistTracks = await (0, request_1.request)({ playlist_id, lang: 'en', nb: -1, start: 0, tab: 0, tags: true, header: true }, 'playlist.getSongs');
|
|
45
|
+
playlistTracks.data = playlistTracks.data.map((track, index) => {
|
|
46
|
+
track.TRACK_POSITION = index + 1;
|
|
47
|
+
return track;
|
|
48
|
+
});
|
|
49
|
+
return playlistTracks;
|
|
50
|
+
};
|
|
51
|
+
exports.getPlaylistTracks = getPlaylistTracks;
|
|
52
|
+
/**
|
|
53
|
+
* @param {String} art_id artist id
|
|
54
|
+
*/
|
|
55
|
+
const getArtistInfo = (art_id) => (0, request_1.request)({ art_id, filter_role_id: [0], lang: 'en', tab: 0, nb: -1, start: 0 }, 'artist.getData');
|
|
56
|
+
exports.getArtistInfo = getArtistInfo;
|
|
57
|
+
/**
|
|
58
|
+
* @param {String} art_id artist id
|
|
59
|
+
* @param {String} nb number of total song to fetch
|
|
60
|
+
*/
|
|
61
|
+
const getDiscography = (art_id, nb = 500) => (0, request_1.request)({ art_id, filter_role_id: [0], lang: 'en', nb, nb_songs: -1, start: 0 }, 'album.getDiscography');
|
|
62
|
+
exports.getDiscography = getDiscography;
|
|
63
|
+
/**
|
|
64
|
+
* @param {String} user_id user id
|
|
65
|
+
*/
|
|
66
|
+
const getProfile = (user_id) => (0, request_1.request)({ user_id, tab: 'loved', nb: -1 }, 'mobile.pageUser');
|
|
67
|
+
exports.getProfile = getProfile;
|
|
68
|
+
/**
|
|
69
|
+
* @param {String} artist artist name
|
|
70
|
+
* @param {String} song song name
|
|
71
|
+
* @param {String} nb number of items to fetch
|
|
72
|
+
*/
|
|
73
|
+
const searchAlternative = (artist, song, nb = 10) => (0, request_1.request)({
|
|
74
|
+
query: `artist:'${artist}' track:'${song}'`,
|
|
75
|
+
types: ['TRACK'],
|
|
76
|
+
nb,
|
|
77
|
+
}, 'mobile_suggest');
|
|
78
|
+
exports.searchAlternative = searchAlternative;
|
|
79
|
+
/**
|
|
80
|
+
* @param {String} query search query
|
|
81
|
+
* @param {Array} types search types
|
|
82
|
+
* @param {Number} nb number of items to fetch
|
|
83
|
+
*/
|
|
84
|
+
const searchMusic = (query, types = ['TRACK'], nb = 15) => (0, request_1.requestLight)({ query, start: 0, nb, suggest: true, artist_suggest: true, top_tracks: true }, 'deezer.pageSearch');
|
|
85
|
+
exports.searchMusic = searchMusic;
|
|
86
|
+
/**
|
|
87
|
+
* Get details about current user
|
|
88
|
+
*/
|
|
89
|
+
const getUser = async () => (0, request_1.requestGet)('user_getInfo');
|
|
90
|
+
exports.getUser = getUser;
|
|
91
|
+
/**
|
|
92
|
+
* Get list of channles
|
|
93
|
+
*/
|
|
94
|
+
const getChannelList = async () => (0, request_1.request)({}, 'search_getChannels');
|
|
95
|
+
exports.getChannelList = getChannelList;
|
|
96
|
+
/**
|
|
97
|
+
* @param {String} SHOW_ID show id
|
|
98
|
+
* @param {Number} NB number of items to fetch
|
|
99
|
+
* @param {Number} START start index
|
|
100
|
+
*/
|
|
101
|
+
const getShowInfo = (SHOW_ID, NB = 1000, START = 0) => (0, request_1.request)({
|
|
102
|
+
SHOW_ID,
|
|
103
|
+
NB,
|
|
104
|
+
START,
|
|
105
|
+
}, 'mobile.pageShow');
|
|
106
|
+
exports.getShowInfo = getShowInfo;
|
|
107
|
+
/**
|
|
108
|
+
* Get details about a playlist channel
|
|
109
|
+
*/
|
|
110
|
+
const getPlaylistChannel = async (page) => {
|
|
111
|
+
const gateway_input = {
|
|
112
|
+
page,
|
|
113
|
+
version: '2.3',
|
|
114
|
+
support: {
|
|
115
|
+
'long-card-horizontal-grid': ['album', 'playlist', 'radio', 'show'],
|
|
116
|
+
ads: [],
|
|
117
|
+
message: [],
|
|
118
|
+
highlight: ['generic', 'album', 'artist', 'playlist', 'radio', 'app'],
|
|
119
|
+
'deeplink-list': ['generic', 'deeplink'],
|
|
120
|
+
grid: [
|
|
121
|
+
'generic',
|
|
122
|
+
'album',
|
|
123
|
+
'artist',
|
|
124
|
+
'playlist',
|
|
125
|
+
'radio',
|
|
126
|
+
'channel',
|
|
127
|
+
'show',
|
|
128
|
+
'page',
|
|
129
|
+
'smarttracklist',
|
|
130
|
+
'flow',
|
|
131
|
+
'video-link',
|
|
132
|
+
],
|
|
133
|
+
slideshow: ['album', 'artist', 'playlist', 'radio', 'show', 'channel', 'video-link', 'external-link'],
|
|
134
|
+
'large-card': ['generic', 'album', 'artist', 'playlist', 'radio', 'show', 'external-link', 'video-link'],
|
|
135
|
+
'item-highlight': ['radio', 'app'],
|
|
136
|
+
'small-horizontal-grid': ['album', 'artist', 'playlist', 'radio', 'channel', 'show'],
|
|
137
|
+
'grid-preview-two': [
|
|
138
|
+
'generic',
|
|
139
|
+
'album',
|
|
140
|
+
'artist',
|
|
141
|
+
'playlist',
|
|
142
|
+
'radio',
|
|
143
|
+
'channel',
|
|
144
|
+
'show',
|
|
145
|
+
'page',
|
|
146
|
+
'smarttracklist',
|
|
147
|
+
'flow',
|
|
148
|
+
'video-link',
|
|
149
|
+
],
|
|
150
|
+
list: ['generic', 'album', 'artist', 'playlist', 'radio', 'show', 'video-link', 'channel', 'episode'],
|
|
151
|
+
'grid-preview-one': [
|
|
152
|
+
'generic',
|
|
153
|
+
'album',
|
|
154
|
+
'artist',
|
|
155
|
+
'playlist',
|
|
156
|
+
'radio',
|
|
157
|
+
'channel',
|
|
158
|
+
'show',
|
|
159
|
+
'page',
|
|
160
|
+
'smarttracklist',
|
|
161
|
+
'flow',
|
|
162
|
+
'video-link',
|
|
163
|
+
],
|
|
164
|
+
'horizontal-grid': [
|
|
165
|
+
'generic',
|
|
166
|
+
'album',
|
|
167
|
+
'artist',
|
|
168
|
+
'playlist',
|
|
169
|
+
'radio',
|
|
170
|
+
'channel',
|
|
171
|
+
'show',
|
|
172
|
+
'video-link',
|
|
173
|
+
'smarttracklist',
|
|
174
|
+
'flow',
|
|
175
|
+
],
|
|
176
|
+
},
|
|
177
|
+
lang: 'en',
|
|
178
|
+
timezone_offset: '6',
|
|
179
|
+
};
|
|
180
|
+
return await (0, request_1.requestGet)('app_page_get', { gateway_input }, page);
|
|
181
|
+
};
|
|
182
|
+
exports.getPlaylistChannel = getPlaylistChannel;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const fast_lru_1 = __importDefault(require("../lib/fast-lru"));
|
|
7
|
+
// Expire cache in 60 minutes
|
|
8
|
+
const lru = new fast_lru_1.default({
|
|
9
|
+
maxSize: 1000,
|
|
10
|
+
ttl: 60 * 60000,
|
|
11
|
+
});
|
|
12
|
+
exports.default = lru;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./api"), exports);
|
|
18
|
+
__exportStar(require("./request"), exports);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make POST requests to deezer api
|
|
3
|
+
* @param {Object} body post body
|
|
4
|
+
* @param {String} method request method
|
|
5
|
+
*/
|
|
6
|
+
export declare const request: (body: object, method: string) => Promise<any>;
|
|
7
|
+
/**
|
|
8
|
+
* Make POST requests to deezer api
|
|
9
|
+
* @param {Object} body post body
|
|
10
|
+
* @param {String} method request method
|
|
11
|
+
*/
|
|
12
|
+
export declare const requestLight: (body: object, method: string) => Promise<any>;
|
|
13
|
+
/**
|
|
14
|
+
* Make GET requests to deezer public api
|
|
15
|
+
* @param {String} method request method
|
|
16
|
+
* @param {Object} params request parameters
|
|
17
|
+
*/
|
|
18
|
+
export declare const requestGet: (method: string, params?: Record<string, any>, key?: string) => Promise<any>;
|
|
19
|
+
/**
|
|
20
|
+
* Make GET requests to deezer public api
|
|
21
|
+
* @param {String} slug endpoint
|
|
22
|
+
*/
|
|
23
|
+
export declare const requestPublicApi: (slug: string) => Promise<any>;
|