discord-player-deezer 2.5.0-beta.1 → 2.6.0

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/readme.md CHANGED
@@ -1,35 +1,35 @@
1
- # Discord Player Deezer
2
-
3
- Discord Player Deezer is a Deezer platform plugin for discord-player
4
-
5
- # Installation
6
-
7
- ```bash
8
- $ npm install discord-player-deezer
9
- ```
10
-
11
- # Register the extractor
12
-
13
- ```ts
14
- import { DeezerExtractor } from "discord-player-deezer"
15
- import { Player } from "discord-player"
16
-
17
- const player = new Player(...)
18
-
19
- await player.extractors.register(DeezerExtractor, {})
20
- ```
21
-
22
- # Extracting Streams
23
-
24
- As Deezer sends DMCA to repositories containing the hard-coded decryption key, it is not provided. You can find this key in the code of related projects (deezer downloaders) and your client-side JavaScript code.
25
-
26
- ```ts
27
- import { DeezerExtractor } from "discord-player-deezer"
28
- import { Player } from "discord-player"
29
-
30
- const player = new Player(...)
31
-
32
- await player.extractors.register(DeezerExtractor, {
33
- decryptionKey: "master-decryption-key"
34
- })
1
+ # Discord Player Deezer
2
+
3
+ Discord Player Deezer is a Deezer platform plugin for discord-player
4
+
5
+ # Installation
6
+
7
+ ```bash
8
+ $ npm install discord-player-deezer
9
+ ```
10
+
11
+ # Register the extractor
12
+
13
+ ```ts
14
+ import { DeezerExtractor } from "discord-player-deezer"
15
+ import { Player } from "discord-player"
16
+
17
+ const player = new Player(...)
18
+
19
+ await player.extractors.register(DeezerExtractor, {})
20
+ ```
21
+
22
+ # Extracting Streams
23
+
24
+ As Deezer sends DMCA to repositories containing the hard-coded decryption key, it is not provided. You can find this key in the code of related projects (deezer downloaders) and your client-side JavaScript code.
25
+
26
+ ```ts
27
+ import { DeezerExtractor } from "discord-player-deezer"
28
+ import { Player } from "discord-player"
29
+
30
+ const player = new Player(...)
31
+
32
+ await player.extractors.register(DeezerExtractor, {
33
+ decryptionKey: "master-decryption-key"
34
+ })
35
35
  ```
@@ -1,12 +1,12 @@
1
- export class BaseDecryptor {
2
- key: Buffer
3
- iv: Buffer
4
- constructor(decryptionKey: Buffer, iv: Buffer) {
5
- this.key = decryptionKey
6
- this.iv = iv
7
- }
8
-
9
- async decrypt(chunk: Buffer): Promise<Buffer> {
10
- throw new Error("Not implemented")
11
- }
1
+ export class BaseDecryptor {
2
+ key: Buffer
3
+ iv: Buffer
4
+ constructor(decryptionKey: Buffer, iv: Buffer) {
5
+ this.key = decryptionKey
6
+ this.iv = iv
7
+ }
8
+
9
+ async decrypt(chunk: Buffer): Promise<Buffer> {
10
+ throw new Error("Not implemented")
11
+ }
12
12
  }
@@ -1,18 +1,18 @@
1
- import Blowfish, { MODE, PADDING, TYPE } from "blowfish-node";
2
- import { BaseDecryptor } from "./BaseDecryptor";
3
-
4
- export class JSDecryptor extends BaseDecryptor {
5
- bfDecryptor: Blowfish
6
-
7
- constructor(...args: ConstructorParameters<typeof BaseDecryptor>) {
8
- super(...args)
9
- this.bfDecryptor = new Blowfish(new Uint8Array(this.key), MODE.CBC, PADDING.NULL)
10
- this.bfDecryptor.setIv(new Uint8Array(this.iv))
11
- }
12
-
13
- async decrypt(chunk: Buffer): Promise<Buffer> {
14
- const chunkUint = new Uint8Array(chunk)
15
- const decoded = this.bfDecryptor.decode(chunkUint, TYPE.UINT8_ARRAY)
16
- return Buffer.from(decoded)
17
- }
1
+ import Blowfish, { MODE, PADDING, TYPE } from "blowfish-node";
2
+ import { BaseDecryptor } from "./BaseDecryptor";
3
+
4
+ export class JSDecryptor extends BaseDecryptor {
5
+ bfDecryptor: Blowfish
6
+
7
+ constructor(...args: ConstructorParameters<typeof BaseDecryptor>) {
8
+ super(...args)
9
+ this.bfDecryptor = new Blowfish(new Uint8Array(this.key), MODE.CBC, PADDING.NULL)
10
+ this.bfDecryptor.setIv(new Uint8Array(this.iv))
11
+ }
12
+
13
+ async decrypt(chunk: Buffer): Promise<Buffer> {
14
+ const chunkUint = new Uint8Array(chunk)
15
+ const decoded = this.bfDecryptor.decode(chunkUint, TYPE.UINT8_ARRAY)
16
+ return Buffer.from(decoded)
17
+ }
18
18
  }
@@ -1,17 +1,17 @@
1
- import { getCrypto } from "../utils/util";
2
- import { BaseDecryptor } from "./BaseDecryptor";
3
- import type { CipherGCMTypes, CipherKey, BinaryLike, Decipher } from "node:crypto"
4
-
5
- export class NodeDecryptor extends BaseDecryptor {
6
- constructor(...args: ConstructorParameters<typeof BaseDecryptor>) {
7
- super(...args);
8
- (async () => {
9
- if(!(await getCrypto()).getCiphers().includes("bf-cbc")) throw new Error("Cannot find bf-cbc")
10
- })()
11
- }
12
- async decrypt(chunk: Buffer): Promise<Buffer> {
13
- const crypto = await getCrypto()
14
- const decipher = crypto.createDecipheriv("bf-cbc" as unknown as CipherGCMTypes, this.key as unknown as CipherKey, this.iv as unknown as BinaryLike).setAutoPadding(false) as unknown as Decipher
15
- return Buffer.concat([decipher.update(chunk as unknown as NodeJS.ArrayBufferView) as unknown as Uint8Array, decipher.final() as unknown as Uint8Array])
16
- }
1
+ import { getCrypto } from "../utils/util";
2
+ import { BaseDecryptor } from "./BaseDecryptor";
3
+ import type { CipherGCMTypes, CipherKey, BinaryLike, Decipher } from "node:crypto"
4
+
5
+ export class NodeDecryptor extends BaseDecryptor {
6
+ constructor(...args: ConstructorParameters<typeof BaseDecryptor>) {
7
+ super(...args);
8
+ (async () => {
9
+ if(!(await getCrypto()).getCiphers().includes("bf-cbc")) throw new Error("Cannot find bf-cbc")
10
+ })()
11
+ }
12
+ async decrypt(chunk: Buffer): Promise<Buffer> {
13
+ const crypto = await getCrypto()
14
+ const decipher = crypto.createDecipheriv("bf-cbc" as unknown as CipherGCMTypes, this.key as unknown as CipherKey, this.iv as unknown as BinaryLike).setAutoPadding(false) as unknown as Decipher
15
+ return Buffer.concat([decipher.update(chunk as unknown as NodeJS.ArrayBufferView) as unknown as Uint8Array, decipher.final() as unknown as Uint8Array])
16
+ }
17
17
  }
@@ -1,3 +1,3 @@
1
- export * from "./BaseDecryptor"
2
- export * from "./JSDecryptor"
1
+ export * from "./BaseDecryptor"
2
+ export * from "./JSDecryptor"
3
3
  export * from "./NodeDecryptor"
@@ -1,197 +1,259 @@
1
- import { BaseExtractor, ExtractorSearchContext, ExtractorStreamable, Track, Playlist, Util as DPUtil, ExtractorInfo, SearchQueryType } from "discord-player"
2
- import { Playlist as DeezerPlaylist, Track as DeezerTrack, getData } from "@mithron/deezer-music-metadata";
3
- import { buildTrackFromSearch, deezerRegex, getCrypto, isUrl, search, searchOneTrack, streamTrack, validate } from "./utils/util";
4
- import { setTimeout } from "node:timers/promises"
5
- import { BaseDecryptor } from "./Crypto/BaseDecryptor";
6
-
7
- /**
8
- * -------------------------------NOTICE-------------------------------------
9
- * STREAMING CODE IS MAINLY TAKEN FROM https://github.com/PerformanC/NodeLink
10
- * WHICH HAS THE "BSD 2-Clause "Simplified" License"
11
- *
12
- * PLEASE SHOW THE ORIGINAL AUTHOR SUPPORT BY STARING HIS GITHUB REPO
13
- * --------------------------------------------------------------------------
14
- */
15
-
16
- export type DeezerExtractorOptions = {
17
- decryptionKey?: string; // needed for decrypting deezer songs
18
- createStream?: (track: Track, ext: DeezerExtractor) => Promise<ExtractorStreamable>;
19
- searchLimit?: number;
20
- reloadUserInterval?: number;
21
- priority?: number;
22
- arl: string;
23
- decryptor?: typeof BaseDecryptor
24
- }
25
-
26
- export type DeezerUserInfo = {
27
- cookie: string;
28
- licenseToken: string;
29
- csrfToken: string;
30
- mediaUrl: string;
31
- }
32
-
33
- export const Warnings = {
34
- MissingDecryption: "Decryption Key missing! This is needed for extracting streams."
35
- } as const
36
- export type Warnings = (typeof Warnings)[keyof typeof Warnings]
37
-
38
- function parseCookie(obj: Record<string, string>) {
39
- let str = ""
40
- for(const key of Object.keys(obj)) {
41
- str += ` ${key}=${obj[key]};`
42
- }
43
-
44
- return str.trim()
45
- }
46
-
47
- async function fetchDeezerUser(ext: DeezerExtractor): Promise<DeezerUserInfo> {
48
- // extract deezer username
49
- // dynamically load crypto because some might not want streaming
50
- const crypto = await getCrypto()
51
- const randomToken = crypto.randomBytes(16).toString("hex")
52
- const deezerUsrDataUrl = `https://www.deezer.com/ajax/gw-light.php?method=deezer.getUserData&input=3&api_version=1.0&api_token=${randomToken}`
53
-
54
- const usrDataRes = await ext.fetch(deezerUsrDataUrl)
55
- const usrData = await usrDataRes.json()
56
-
57
- const licenseToken = usrData.results.USER.OPTIONS.license_token
58
- if(typeof licenseToken !== "string") throw new Error("Unable to get licenseToken")
59
-
60
- const csrfToken = usrData.results.checkForm
61
- if(typeof csrfToken !== "string") throw new Error("Unable to get csrf token which is required for decryption")
62
-
63
- return {
64
- cookie: usrDataRes.headers.get("set-cookie")!,
65
- licenseToken,
66
- csrfToken,
67
- mediaUrl: usrData.results.URL_MEDIA || "https://media.deezer.com",
68
- }
69
- }
70
-
71
- export class DeezerExtractor extends BaseExtractor<DeezerExtractorOptions> {
72
- static readonly identifier: string = "com.retrouser955.discord-player.deezr-ext"
73
- userInfo!: DeezerUserInfo
74
- /* tslint:disable-next-line */
75
- __interval?: ReturnType<typeof setInterval>
76
-
77
- async fetch(input: Parameters<typeof fetch>[0], options?: Parameters<typeof fetch>[1]) {
78
- if(!options) options = {}
79
- options.headers = {
80
- Cookie: parseCookie({ arl: this.options.arl }),
81
- 'User-Agent': "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0",
82
- 'DNT': '1',
83
- "Origin": "https://www.deezer.com",
84
- 'Connection': 'keep-alive',
85
- 'Referer': 'https://www.deezer.com/login',
86
- ...options?.headers,
87
- }
88
- return fetch(input, options)
89
- }
90
-
91
- async activate(): Promise<void> {
92
- this.protocols = ["deezer"]
93
- if(!this.options.decryptionKey) process.emitWarning(Warnings.MissingDecryption)
94
- else {
95
- this.userInfo = await fetchDeezerUser(this)
96
-
97
- this.context.player.debug('USER INFO EXT: ' + JSON.stringify(this.userInfo))
98
- }
99
-
100
- if(this.options.priority) {
101
- this.priority = this.options.priority;
102
- }
103
-
104
- this.__interval = setInterval(async () => {
105
- try {
106
- this.userInfo = await fetchDeezerUser(this)
107
- } catch {
108
- this.context.player.debug("[DEEZER_EXTRACTOR_ERR]: Unable to fetch user information from Deezer. Retrying in 3 seconds ...")
109
- await setTimeout(3000/* 3 seconds */)
110
- try {
111
- this.userInfo = await fetchDeezerUser(this)
112
- } catch (err) {
113
- this.context.player.debug("[DEEZER_EXTRACTOR_ERR]: Retry failed. Using old user ...")
114
- }
115
- }
116
- }, this.options.reloadUserInterval || 8.64e+7/* one day */).unref()
117
- }
118
-
119
- async deactivate() {
120
- if(this.__interval) clearInterval(this.__interval)
121
- this.protocols = []
122
- }
123
-
124
- async validate(query: string, type: SearchQueryType & "deezer"): Promise<boolean> {
125
- return validate(query) || type === "deezer" || !isUrl(query)
126
- }
127
-
128
- buildPlaylistData(data: DeezerPlaylist, handleContext: ExtractorSearchContext) {
129
- const raw: string[] = data.url.split("/")
130
- const identifier: string = raw[raw.length - 1].split("?")[0]
131
-
132
- return new Playlist(this.context.player, {
133
- title: data.name,
134
- thumbnail: data.thumbnail[0].url,
135
- author: {
136
- name: data.artist.name,
137
- url: data.artist.url
138
- },
139
- type: data.type,
140
- tracks: data.tracks.map((v) => this.buildTrack(v, handleContext)),
141
- description: "",
142
- source: "arbitrary",
143
- id: identifier,
144
- url: data.url
145
- })
146
- }
147
-
148
- async handle(query: string, context: ExtractorSearchContext): Promise<ExtractorInfo> {
149
- if(!isUrl(query)) {
150
- const rawSearch = await search(query)
151
- const tracks = buildTrackFromSearch(rawSearch, this.context.player, context.requestedBy)
152
- return this.createResponse(null, tracks)
153
- }
154
-
155
- if (deezerRegex.share.test(query)) {
156
- const redirect = await this.fetch(query);
157
- query = redirect.url; // follow the redirect of deezer page links
158
- }
159
- const metadata = await getData(query)
160
-
161
- if(metadata?.type === "song") return this.createResponse(null, [this.buildTrack(metadata, context)])
162
- if(metadata?.type === "playlist" || metadata?.type === "album") {
163
- const playlist = this.buildPlaylistData(metadata, context)
164
-
165
- return this.createResponse(playlist, playlist.tracks)
166
- }
167
-
168
- throw new Error("Unable to get data from Deezer")
169
- }
170
-
171
- buildTrack(track: DeezerTrack, { requestedBy }: ExtractorSearchContext) {
172
- return new Track(this.context.player, {
173
- title: track.name,
174
- author: track.author.map((v) => v.name).join(", "),
175
- url: track.url,
176
- source: "arbitrary",
177
- thumbnail: track.thumbnail[0].url,
178
- duration: DPUtil.buildTimeCode(DPUtil.parseMS(track.duration)),
179
- requestedBy
180
- })
181
- }
182
-
183
- async bridge(track: Track): Promise<ExtractorStreamable | null> {
184
- const deezerTrack = await searchOneTrack(`${track.author} ${track.source === "youtube" ? track.cleanTitle : track.title}`)
185
-
186
- if(!deezerTrack) return null
187
- const dpTrack = buildTrackFromSearch(deezerTrack, this.context.player, track.requestedBy)
188
-
189
- const stream = this.stream(dpTrack[0])
190
-
191
- return stream
192
- }
193
-
194
- stream(info: Track): Promise<ExtractorStreamable> {
195
- return streamTrack(info, this)
196
- }
197
- }
1
+ import {
2
+ Playlist as DeezerPlaylist,
3
+ Track as DeezerTrack,
4
+ getData,
5
+ } from "@mithron/deezer-music-metadata";
6
+ import {
7
+ BaseExtractor,
8
+ Util as DPUtil,
9
+ ExtractorInfo,
10
+ ExtractorSearchContext,
11
+ ExtractorStreamable,
12
+ Playlist,
13
+ SearchQueryType,
14
+ Track,
15
+ } from "discord-player";
16
+ import { setTimeout } from "node:timers/promises";
17
+ import { BaseDecryptor } from "./Crypto/BaseDecryptor";
18
+ import {
19
+ buildTrackFromSearch,
20
+ deezerRegex,
21
+ getCrypto,
22
+ isUrl,
23
+ search,
24
+ searchOneTrack,
25
+ streamTrack,
26
+ validate,
27
+ } from "./utils/util";
28
+
29
+ /**
30
+ * -------------------------------NOTICE-------------------------------------
31
+ * STREAMING CODE IS MAINLY TAKEN FROM https://github.com/PerformanC/NodeLink
32
+ * WHICH HAS THE "BSD 2-Clause "Simplified" License"
33
+ *
34
+ * PLEASE SHOW THE ORIGINAL AUTHOR SUPPORT BY STARING HIS GITHUB REPO
35
+ * --------------------------------------------------------------------------
36
+ */
37
+
38
+ export type DeezerExtractorOptions = {
39
+ decryptionKey?: string; // needed for decrypting deezer songs
40
+ createStream?: (
41
+ track: Track,
42
+ ext: DeezerExtractor
43
+ ) => Promise<ExtractorStreamable>;
44
+ searchLimit?: number;
45
+ reloadUserInterval?: number;
46
+ priority?: number;
47
+ arl: string;
48
+ decryptor?: typeof BaseDecryptor;
49
+ };
50
+
51
+ export type DeezerUserInfo = {
52
+ cookie: string;
53
+ licenseToken: string;
54
+ csrfToken: string;
55
+ mediaUrl: string;
56
+ };
57
+
58
+ export const Warnings = {
59
+ MissingDecryption:
60
+ "Decryption Key missing! This is needed for extracting streams.",
61
+ } as const;
62
+ export type Warnings = (typeof Warnings)[keyof typeof Warnings];
63
+
64
+ function parseCookie(obj: Record<string, string>) {
65
+ let str = "";
66
+ for (const key of Object.keys(obj)) {
67
+ str += ` ${key}=${obj[key]};`;
68
+ }
69
+
70
+ return str.trim();
71
+ }
72
+
73
+ async function fetchDeezerUser(ext: DeezerExtractor): Promise<DeezerUserInfo> {
74
+ // extract deezer username
75
+ // dynamically load crypto because some might not want streaming
76
+ const crypto = await getCrypto();
77
+ const randomToken = crypto.randomBytes(16).toString("hex");
78
+ const deezerUsrDataUrl = `https://www.deezer.com/ajax/gw-light.php?method=deezer.getUserData&input=3&api_version=1.0&api_token=${randomToken}`;
79
+
80
+ const usrDataRes = await ext.fetch(deezerUsrDataUrl);
81
+ const usrData = await usrDataRes.json();
82
+
83
+ const licenseToken = usrData.results.USER.OPTIONS.license_token;
84
+ if (typeof licenseToken !== "string")
85
+ throw new Error("Unable to get licenseToken");
86
+
87
+ const csrfToken = usrData.results.checkForm;
88
+ if (typeof csrfToken !== "string")
89
+ throw new Error(
90
+ "Unable to get csrf token which is required for decryption"
91
+ );
92
+
93
+ return {
94
+ cookie: usrDataRes.headers.get("set-cookie")!,
95
+ licenseToken,
96
+ csrfToken,
97
+ mediaUrl: usrData.results.URL_MEDIA || "https://media.deezer.com",
98
+ };
99
+ }
100
+
101
+ export class DeezerExtractor extends BaseExtractor<DeezerExtractorOptions> {
102
+ static readonly identifier: string =
103
+ "com.retrouser955.discord-player.deezr-ext";
104
+ userInfo!: DeezerUserInfo;
105
+ /* tslint:disable-next-line */
106
+ __interval?: ReturnType<typeof setInterval>;
107
+
108
+ async fetch(
109
+ input: Parameters<typeof fetch>[0],
110
+ options?: Parameters<typeof fetch>[1]
111
+ ) {
112
+ if (!options) options = {};
113
+ options.headers = {
114
+ Cookie: parseCookie({ arl: this.options.arl }),
115
+ "User-Agent":
116
+ "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0",
117
+ DNT: "1",
118
+ Origin: "https://www.deezer.com",
119
+ Connection: "keep-alive",
120
+ Referer: "https://www.deezer.com/login",
121
+ ...options?.headers,
122
+ };
123
+ return fetch(input, options);
124
+ }
125
+
126
+ async activate(): Promise<void> {
127
+ this.protocols = ["deezer"];
128
+ if (!this.options.decryptionKey)
129
+ process.emitWarning(Warnings.MissingDecryption);
130
+ else {
131
+ this.userInfo = await fetchDeezerUser(this);
132
+
133
+ this.context.player.debug(
134
+ "USER INFO EXT: " + JSON.stringify(this.userInfo)
135
+ );
136
+ }
137
+
138
+ if (this.options.priority) {
139
+ this.priority = this.options.priority;
140
+ }
141
+
142
+ this.__interval = setInterval(async () => {
143
+ try {
144
+ this.userInfo = await fetchDeezerUser(this);
145
+ } catch {
146
+ this.context.player.debug(
147
+ "[DEEZER_EXTRACTOR_ERR]: Unable to fetch user information from Deezer. Retrying in 3 seconds ..."
148
+ );
149
+ await setTimeout(3000 /* 3 seconds */);
150
+ try {
151
+ this.userInfo = await fetchDeezerUser(this);
152
+ } catch (err) {
153
+ this.context.player.debug(
154
+ "[DEEZER_EXTRACTOR_ERR]: Retry failed. Using old user ..."
155
+ );
156
+ }
157
+ }
158
+ }, this.options.reloadUserInterval || 8.64e7 /* one day */).unref();
159
+ }
160
+
161
+ async deactivate() {
162
+ if (this.__interval) clearInterval(this.__interval);
163
+ this.protocols = [];
164
+ }
165
+
166
+ async validate(
167
+ query: string,
168
+ type: SearchQueryType & "deezer"
169
+ ): Promise<boolean> {
170
+ return validate(query) || type === "deezer" || !isUrl(query);
171
+ }
172
+
173
+ buildPlaylistData(
174
+ data: DeezerPlaylist,
175
+ handleContext: ExtractorSearchContext
176
+ ) {
177
+ const raw: string[] = data.url.split("/");
178
+ const identifier: string = raw[raw.length - 1].split("?")[0];
179
+
180
+ return new Playlist(this.context.player, {
181
+ title: data.name,
182
+ thumbnail: data.thumbnail[0].url,
183
+ author: {
184
+ name: data.artist.name,
185
+ url: data.artist.url,
186
+ },
187
+ type: data.type,
188
+ tracks: data.tracks.map((v) => this.buildTrack(v, handleContext)),
189
+ description: "",
190
+ source: "arbitrary",
191
+ id: identifier,
192
+ url: data.url,
193
+ });
194
+ }
195
+
196
+ async handle(
197
+ query: string,
198
+ context: ExtractorSearchContext
199
+ ): Promise<ExtractorInfo> {
200
+ if (!isUrl(query)) {
201
+ const rawSearch = await search(query);
202
+ const tracks = buildTrackFromSearch(
203
+ rawSearch,
204
+ this.context.player,
205
+ context.requestedBy
206
+ );
207
+ return this.createResponse(null, tracks);
208
+ }
209
+
210
+ if (deezerRegex.share.test(query)) {
211
+ const redirect = await this.fetch(query);
212
+ query = redirect.url; // follow the redirect of deezer page links
213
+ }
214
+ const metadata = await getData(query);
215
+
216
+ if (metadata?.type === "song")
217
+ return this.createResponse(null, [this.buildTrack(metadata, context)]);
218
+ if (metadata?.type === "playlist" || metadata?.type === "album") {
219
+ const playlist = this.buildPlaylistData(metadata, context);
220
+
221
+ return this.createResponse(playlist, playlist.tracks);
222
+ }
223
+
224
+ throw new Error("Unable to get data from Deezer");
225
+ }
226
+
227
+ buildTrack(track: DeezerTrack, { requestedBy }: ExtractorSearchContext) {
228
+ return new Track(this.context.player, {
229
+ title: track.name,
230
+ author: track.author.map((v) => v.name).join(", "),
231
+ url: track.url,
232
+ source: "arbitrary",
233
+ thumbnail: track.thumbnail[0].url,
234
+ duration: DPUtil.buildTimeCode(DPUtil.parseMS(track.duration * 1000)),
235
+ requestedBy,
236
+ });
237
+ }
238
+
239
+ async bridge(track: Track): Promise<ExtractorStreamable | null> {
240
+ const deezerTrack = await searchOneTrack(
241
+ `${track.author} ${track.source === "youtube" ? track.cleanTitle : track.title}`
242
+ );
243
+
244
+ if (!deezerTrack) return null;
245
+ const dpTrack = buildTrackFromSearch(
246
+ deezerTrack,
247
+ this.context.player,
248
+ track.requestedBy
249
+ );
250
+
251
+ const stream = this.stream(dpTrack[0]);
252
+
253
+ return stream;
254
+ }
255
+
256
+ stream(info: Track): Promise<ExtractorStreamable> {
257
+ return streamTrack(info, this);
258
+ }
259
+ }
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from "./DeezerExtractor"
2
- export * from "./utils/util"
1
+ export * from "./DeezerExtractor"
2
+ export * from "./utils/util"
3
3
  export * from "./Crypto"