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.
Binary file
package/.yarnrc.yml CHANGED
@@ -1 +1 @@
1
- nodeLinker: node-modules
1
+ nodeLinker: node-modules
package/LICENSE CHANGED
@@ -1,121 +1,121 @@
1
- Creative Commons Legal Code
2
-
3
- CC0 1.0 Universal
4
-
5
- CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
- LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
- ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
- INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
- REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
- PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
- THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
- HEREUNDER.
13
-
14
- Statement of Purpose
15
-
16
- The laws of most jurisdictions throughout the world automatically confer
17
- exclusive Copyright and Related Rights (defined below) upon the creator
18
- and subsequent owner(s) (each and all, an "owner") of an original work of
19
- authorship and/or a database (each, a "Work").
20
-
21
- Certain owners wish to permanently relinquish those rights to a Work for
22
- the purpose of contributing to a commons of creative, cultural and
23
- scientific works ("Commons") that the public can reliably and without fear
24
- of later claims of infringement build upon, modify, incorporate in other
25
- works, reuse and redistribute as freely as possible in any form whatsoever
26
- and for any purposes, including without limitation commercial purposes.
27
- These owners may contribute to the Commons to promote the ideal of a free
28
- culture and the further production of creative, cultural and scientific
29
- works, or to gain reputation or greater distribution for their Work in
30
- part through the use and efforts of others.
31
-
32
- For these and/or other purposes and motivations, and without any
33
- expectation of additional consideration or compensation, the person
34
- associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
- is an owner of Copyright and Related Rights in the Work, voluntarily
36
- elects to apply CC0 to the Work and publicly distribute the Work under its
37
- terms, with knowledge of his or her Copyright and Related Rights in the
38
- Work and the meaning and intended legal effect of CC0 on those rights.
39
-
40
- 1. Copyright and Related Rights. A Work made available under CC0 may be
41
- protected by copyright and related or neighboring rights ("Copyright and
42
- Related Rights"). Copyright and Related Rights include, but are not
43
- limited to, the following:
44
-
45
- i. the right to reproduce, adapt, distribute, perform, display,
46
- communicate, and translate a Work;
47
- ii. moral rights retained by the original author(s) and/or performer(s);
48
- iii. publicity and privacy rights pertaining to a person's image or
49
- likeness depicted in a Work;
50
- iv. rights protecting against unfair competition in regards to a Work,
51
- subject to the limitations in paragraph 4(a), below;
52
- v. rights protecting the extraction, dissemination, use and reuse of data
53
- in a Work;
54
- vi. database rights (such as those arising under Directive 96/9/EC of the
55
- European Parliament and of the Council of 11 March 1996 on the legal
56
- protection of databases, and under any national implementation
57
- thereof, including any amended or successor version of such
58
- directive); and
59
- vii. other similar, equivalent or corresponding rights throughout the
60
- world based on applicable law or treaty, and any national
61
- implementations thereof.
62
-
63
- 2. Waiver. To the greatest extent permitted by, but not in contravention
64
- of, applicable law, Affirmer hereby overtly, fully, permanently,
65
- irrevocably and unconditionally waives, abandons, and surrenders all of
66
- Affirmer's Copyright and Related Rights and associated claims and causes
67
- of action, whether now known or unknown (including existing as well as
68
- future claims and causes of action), in the Work (i) in all territories
69
- worldwide, (ii) for the maximum duration provided by applicable law or
70
- treaty (including future time extensions), (iii) in any current or future
71
- medium and for any number of copies, and (iv) for any purpose whatsoever,
72
- including without limitation commercial, advertising or promotional
73
- purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
- member of the public at large and to the detriment of Affirmer's heirs and
75
- successors, fully intending that such Waiver shall not be subject to
76
- revocation, rescission, cancellation, termination, or any other legal or
77
- equitable action to disrupt the quiet enjoyment of the Work by the public
78
- as contemplated by Affirmer's express Statement of Purpose.
79
-
80
- 3. Public License Fallback. Should any part of the Waiver for any reason
81
- be judged legally invalid or ineffective under applicable law, then the
82
- Waiver shall be preserved to the maximum extent permitted taking into
83
- account Affirmer's express Statement of Purpose. In addition, to the
84
- extent the Waiver is so judged Affirmer hereby grants to each affected
85
- person a royalty-free, non transferable, non sublicensable, non exclusive,
86
- irrevocable and unconditional license to exercise Affirmer's Copyright and
87
- Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
- maximum duration provided by applicable law or treaty (including future
89
- time extensions), (iii) in any current or future medium and for any number
90
- of copies, and (iv) for any purpose whatsoever, including without
91
- limitation commercial, advertising or promotional purposes (the
92
- "License"). The License shall be deemed effective as of the date CC0 was
93
- applied by Affirmer to the Work. Should any part of the License for any
94
- reason be judged legally invalid or ineffective under applicable law, such
95
- partial invalidity or ineffectiveness shall not invalidate the remainder
96
- of the License, and in such case Affirmer hereby affirms that he or she
97
- will not (i) exercise any of his or her remaining Copyright and Related
98
- Rights in the Work or (ii) assert any associated claims and causes of
99
- action with respect to the Work, in either case contrary to Affirmer's
100
- express Statement of Purpose.
101
-
102
- 4. Limitations and Disclaimers.
103
-
104
- a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
- surrendered, licensed or otherwise affected by this document.
106
- b. Affirmer offers the Work as-is and makes no representations or
107
- warranties of any kind concerning the Work, express, implied,
108
- statutory or otherwise, including without limitation warranties of
109
- title, merchantability, fitness for a particular purpose, non
110
- infringement, or the absence of latent or other defects, accuracy, or
111
- the present or absence of errors, whether or not discoverable, all to
112
- the greatest extent permissible under applicable law.
113
- c. Affirmer disclaims responsibility for clearing rights of other persons
114
- that may apply to the Work or any use thereof, including without
115
- limitation any person's Copyright and Related Rights in the Work.
116
- Further, Affirmer disclaims responsibility for obtaining any necessary
117
- consents, permissions or other rights required for any use of the
118
- Work.
119
- d. Affirmer understands and acknowledges that Creative Commons is not a
120
- party to this document and has no duty or obligation with respect to
121
- this CC0 or use of the Work.
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { Track, ExtractorStreamable, BaseExtractor, SearchQueryType, ExtractorSearchContext, Playlist as Playlist$1, ExtractorInfo, Player } from 'discord-player';
2
1
  import { Playlist, Track as Track$1 } from '@mithron/deezer-music-metadata';
2
+ import { Track, ExtractorStreamable, BaseExtractor, SearchQueryType, ExtractorSearchContext, Playlist as Playlist$1, ExtractorInfo, Player } from 'discord-player';
3
3
  import * as crypto from 'crypto';
4
4
  import { PassThrough } from 'stream';
5
5
  import Blowfish from 'blowfish-node';
@@ -74,7 +74,7 @@ interface DeezerSearchTrackResponse {
74
74
  type: "track";
75
75
  }[];
76
76
  }
77
- declare function buildTrackFromSearch(track: DeezerSearchTrackResponse, player: Player, requestedBy?: Track['requestedBy']): Track<unknown>[];
77
+ declare function buildTrackFromSearch(track: DeezerSearchTrackResponse, player: Player, requestedBy?: Track["requestedBy"]): Track<unknown>[];
78
78
  declare function extractTrackId(query: string): string;
79
79
  declare function searchOneTrack(query: string): Promise<DeezerSearchTrackResponse | undefined>;
80
80
  declare function streamTrack(track: Track, ext: DeezerExtractor): Promise<PassThrough>;
package/dist/index.js CHANGED
@@ -28,8 +28,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  BaseDecryptor: () => BaseDecryptor,
34
34
  DeezerExtractor: () => DeezerExtractor,
35
35
  JSDecryptor: () => JSDecryptor,
@@ -45,11 +45,12 @@ __export(src_exports, {
45
45
  streamTrack: () => streamTrack,
46
46
  validate: () => validate
47
47
  });
48
- module.exports = __toCommonJS(src_exports);
48
+ module.exports = __toCommonJS(index_exports);
49
49
 
50
50
  // src/DeezerExtractor.ts
51
- var import_discord_player2 = require("discord-player");
52
51
  var import_deezer_music_metadata = require("@mithron/deezer-music-metadata");
52
+ var import_discord_player2 = require("discord-player");
53
+ var import_promises = require("timers/promises");
53
54
 
54
55
  // src/utils/util.ts
55
56
  var import_discord_player = require("discord-player");
@@ -110,22 +111,28 @@ var DeezerAPIRoutes = {
110
111
  async function search(query, limit = 10) {
111
112
  const route = DeezerAPIRoutes.searchTrack(query, limit);
112
113
  const response = await fetch(route);
113
- if (!response.status.toString().startsWith("2")) throw new Error("Server responded with a non 2xx status.");
114
+ if (!response.status.toString().startsWith("2"))
115
+ throw new Error("Server responded with a non 2xx status.");
114
116
  const jsonTrack = await response.json();
115
- if (!jsonTrack.data || !Array.isArray(jsonTrack.data) || jsonTrack.data.length === 0) throw new Error("Unable get tracks from Deezer for the query '" + query + "'");
117
+ if (!jsonTrack.data || !Array.isArray(jsonTrack.data) || jsonTrack.data.length === 0)
118
+ throw new Error(
119
+ "Unable get tracks from Deezer for the query '" + query + "'"
120
+ );
116
121
  return jsonTrack;
117
122
  }
118
123
  function buildTrackFromSearch(track, player, requestedBy) {
119
- const tracks = track.data.map((v) => new import_discord_player.Track(player, {
120
- source: "arbitrary",
121
- duration: import_discord_player.Util.buildTimeCode(import_discord_player.Util.parseMS(v.duration * 1e3)),
122
- author: Array.isArray(v.artist) ? v.artist.map((a) => a.name).join(", ") : v.artist.name,
123
- url: v.link,
124
- title: v.title,
125
- thumbnail: v.album.cover_xl || v.album.cover_medium || v.album.cover || v.album.cover_small || "https://play-lh.googleusercontent.com/xtIOV8iPeAY4GrldTDo3CbLAEpbea2DqnfxaB4Nn2p5qz6KAiumY74qH86pgu1HA1A",
126
- live: false,
127
- requestedBy
128
- }));
124
+ const tracks = track.data.map(
125
+ (v) => new import_discord_player.Track(player, {
126
+ source: "arbitrary",
127
+ duration: import_discord_player.Util.buildTimeCode(import_discord_player.Util.parseMS(v.duration * 1e3)),
128
+ author: Array.isArray(v.artist) ? v.artist.map((a) => a.name).join(", ") : v.artist.name,
129
+ url: v.link,
130
+ title: v.title,
131
+ thumbnail: v.album.cover_xl || v.album.cover_medium || v.album.cover || v.album.cover_small || "https://play-lh.googleusercontent.com/xtIOV8iPeAY4GrldTDo3CbLAEpbea2DqnfxaB4Nn2p5qz6KAiumY74qH86pgu1HA1A",
132
+ live: false,
133
+ requestedBy
134
+ })
135
+ );
129
136
  return tracks;
130
137
  }
131
138
  function extractTrackId(query) {
@@ -150,39 +157,54 @@ async function streamTrack(track, ext) {
150
157
  const trackKey = Buffer.alloc(16);
151
158
  const Decryptor = ext.options.decryptor || JSDecryptor;
152
159
  for (let iter = 0; iter < 16; iter++)
153
- trackKey.writeInt8(trackHash[iter].charCodeAt(0) ^ trackHash[iter + 16].charCodeAt(0) ^ decryptionKey[iter].charCodeAt(0), iter);
154
- const trackInfoRes = await ext.fetch(`https://www.deezer.com/ajax/gw-light.php?method=song.getListData&input=3&api_version=1.0&api_token=${ext.userInfo.csrfToken}`, {
155
- method: "POST",
156
- headers: {
157
- Cookie: `${ext.userInfo.cookie}; arl=${ext.options.arl}`,
158
- "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0",
159
- "DNT": "1"
160
- },
161
- body: JSON.stringify({
162
- sng_ids: [trackId]
163
- })
164
- });
160
+ trackKey.writeInt8(
161
+ /* tslint:disable-next-line no-bitwise */
162
+ trackHash[iter].charCodeAt(0) ^ /* tslint:disable-next-line no-bitwise */
163
+ trackHash[iter + 16].charCodeAt(0) ^ decryptionKey[iter].charCodeAt(0),
164
+ iter
165
+ );
166
+ const trackInfoRes = await ext.fetch(
167
+ `https://www.deezer.com/ajax/gw-light.php?method=song.getListData&input=3&api_version=1.0&api_token=${ext.userInfo.csrfToken}`,
168
+ {
169
+ method: "POST",
170
+ headers: {
171
+ Cookie: `${ext.userInfo.cookie}; arl=${ext.options.arl}`,
172
+ "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0",
173
+ DNT: "1"
174
+ },
175
+ body: JSON.stringify({
176
+ sng_ids: [trackId]
177
+ })
178
+ }
179
+ );
165
180
  const songInfo = (await trackInfoRes.json()).results.data[0];
166
181
  const streamInfoRes = await fetch("https://media.deezer.com/v1/get_url", {
167
182
  method: "POST",
168
183
  body: JSON.stringify({
169
184
  license_token: ext.userInfo.licenseToken,
170
- media: [{
171
- type: "FULL",
172
- formats: [{
173
- cipher: "BF_CBC_STRIPE",
174
- format: "FLAC"
175
- }, {
176
- cipher: "BF_CBC_STRIPE",
177
- format: "MP3_256"
178
- }, {
179
- cipher: "BF_CBC_STRIPE",
180
- format: "MP3_128"
181
- }, {
182
- cipher: "BF_CBC_STRIPE",
183
- format: "MP3_MISC"
184
- }]
185
- }],
185
+ media: [
186
+ {
187
+ type: "FULL",
188
+ formats: [
189
+ {
190
+ cipher: "BF_CBC_STRIPE",
191
+ format: "FLAC"
192
+ },
193
+ {
194
+ cipher: "BF_CBC_STRIPE",
195
+ format: "MP3_256"
196
+ },
197
+ {
198
+ cipher: "BF_CBC_STRIPE",
199
+ format: "MP3_128"
200
+ },
201
+ {
202
+ cipher: "BF_CBC_STRIPE",
203
+ format: "MP3_MISC"
204
+ }
205
+ ]
206
+ }
207
+ ],
186
208
  track_tokens: [songInfo.TRACK_TOKEN]
187
209
  })
188
210
  });
@@ -227,14 +249,13 @@ async function streamTrack(track, ext) {
227
249
  var deezerRegex = {
228
250
  track: /(^https:)\/\/(www\.)?deezer.com\/([a-zA-Z]+\/)?track\/[0-9]+/,
229
251
  playlistNalbums: /(^https:)\/\/(www\.)?deezer.com\/[a-zA-Z]+\/(playlist|album)\/[0-9]+(\?)?(.*)/,
230
- share: /(^https:)\/\/deezer\.page\.link\/[A-Za-z0-9]+/
252
+ share: /(^https:)\/\/dzr\.page\.link\/[A-Za-z0-9]+/
231
253
  };
232
254
  function validate(query) {
233
255
  return deezerRegex.track.test(query) ?? deezerRegex.playlistNalbums.test(query) ?? deezerRegex.share.test(query);
234
256
  }
235
257
 
236
258
  // src/DeezerExtractor.ts
237
- var import_promises = require("timers/promises");
238
259
  var Warnings = {
239
260
  MissingDecryption: "Decryption Key missing! This is needed for extracting streams."
240
261
  };
@@ -252,9 +273,13 @@ async function fetchDeezerUser(ext) {
252
273
  const usrDataRes = await ext.fetch(deezerUsrDataUrl);
253
274
  const usrData = await usrDataRes.json();
254
275
  const licenseToken = usrData.results.USER.OPTIONS.license_token;
255
- if (typeof licenseToken !== "string") throw new Error("Unable to get licenseToken");
276
+ if (typeof licenseToken !== "string")
277
+ throw new Error("Unable to get licenseToken");
256
278
  const csrfToken = usrData.results.checkForm;
257
- if (typeof csrfToken !== "string") throw new Error("Unable to get csrf token which is required for decryption");
279
+ if (typeof csrfToken !== "string")
280
+ throw new Error(
281
+ "Unable to get csrf token which is required for decryption"
282
+ );
258
283
  return {
259
284
  cookie: usrDataRes.headers.get("set-cookie"),
260
285
  licenseToken,
@@ -268,20 +293,23 @@ var DeezerExtractor = class extends import_discord_player2.BaseExtractor {
268
293
  options.headers = {
269
294
  Cookie: parseCookie({ arl: this.options.arl }),
270
295
  "User-Agent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0",
271
- "DNT": "1",
272
- "Origin": "https://www.deezer.com",
273
- "Connection": "keep-alive",
274
- "Referer": "https://www.deezer.com/login",
296
+ DNT: "1",
297
+ Origin: "https://www.deezer.com",
298
+ Connection: "keep-alive",
299
+ Referer: "https://www.deezer.com/login",
275
300
  ...options?.headers
276
301
  };
277
302
  return fetch(input, options);
278
303
  }
279
304
  async activate() {
280
305
  this.protocols = ["deezer"];
281
- if (!this.options.decryptionKey) process.emitWarning(Warnings.MissingDecryption);
306
+ if (!this.options.decryptionKey)
307
+ process.emitWarning(Warnings.MissingDecryption);
282
308
  else {
283
309
  this.userInfo = await fetchDeezerUser(this);
284
- this.context.player.debug("USER INFO EXT: " + JSON.stringify(this.userInfo));
310
+ this.context.player.debug(
311
+ "USER INFO EXT: " + JSON.stringify(this.userInfo)
312
+ );
285
313
  }
286
314
  if (this.options.priority) {
287
315
  this.priority = this.options.priority;
@@ -291,7 +319,9 @@ var DeezerExtractor = class extends import_discord_player2.BaseExtractor {
291
319
  try {
292
320
  this.userInfo = await fetchDeezerUser(this);
293
321
  } catch {
294
- this.context.player.debug("[DEEZER_EXTRACTOR_ERR]: Unable to fetch user information from Deezer. Retrying in 3 seconds ...");
322
+ this.context.player.debug(
323
+ "[DEEZER_EXTRACTOR_ERR]: Unable to fetch user information from Deezer. Retrying in 3 seconds ..."
324
+ );
295
325
  await (0, import_promises.setTimeout)(
296
326
  3e3
297
327
  /* 3 seconds */
@@ -299,7 +329,9 @@ var DeezerExtractor = class extends import_discord_player2.BaseExtractor {
299
329
  try {
300
330
  this.userInfo = await fetchDeezerUser(this);
301
331
  } catch (err) {
302
- this.context.player.debug("[DEEZER_EXTRACTOR_ERR]: Retry failed. Using old user ...");
332
+ this.context.player.debug(
333
+ "[DEEZER_EXTRACTOR_ERR]: Retry failed. Using old user ..."
334
+ );
303
335
  }
304
336
  }
305
337
  },
@@ -335,7 +367,11 @@ var DeezerExtractor = class extends import_discord_player2.BaseExtractor {
335
367
  async handle(query, context) {
336
368
  if (!isUrl(query)) {
337
369
  const rawSearch = await search(query);
338
- const tracks = buildTrackFromSearch(rawSearch, this.context.player, context.requestedBy);
370
+ const tracks = buildTrackFromSearch(
371
+ rawSearch,
372
+ this.context.player,
373
+ context.requestedBy
374
+ );
339
375
  return this.createResponse(null, tracks);
340
376
  }
341
377
  if (deezerRegex.share.test(query)) {
@@ -343,7 +379,8 @@ var DeezerExtractor = class extends import_discord_player2.BaseExtractor {
343
379
  query = redirect.url;
344
380
  }
345
381
  const metadata = await (0, import_deezer_music_metadata.getData)(query);
346
- if (metadata?.type === "song") return this.createResponse(null, [this.buildTrack(metadata, context)]);
382
+ if (metadata?.type === "song")
383
+ return this.createResponse(null, [this.buildTrack(metadata, context)]);
347
384
  if (metadata?.type === "playlist" || metadata?.type === "album") {
348
385
  const playlist = this.buildPlaylistData(metadata, context);
349
386
  return this.createResponse(playlist, playlist.tracks);
@@ -357,14 +394,20 @@ var DeezerExtractor = class extends import_discord_player2.BaseExtractor {
357
394
  url: track.url,
358
395
  source: "arbitrary",
359
396
  thumbnail: track.thumbnail[0].url,
360
- duration: import_discord_player2.Util.buildTimeCode(import_discord_player2.Util.parseMS(track.duration)),
397
+ duration: import_discord_player2.Util.buildTimeCode(import_discord_player2.Util.parseMS(track.duration * 1e3)),
361
398
  requestedBy
362
399
  });
363
400
  }
364
401
  async bridge(track) {
365
- const deezerTrack = await searchOneTrack(`${track.author} ${track.source === "youtube" ? track.cleanTitle : track.title}`);
402
+ const deezerTrack = await searchOneTrack(
403
+ `${track.author} ${track.source === "youtube" ? track.cleanTitle : track.title}`
404
+ );
366
405
  if (!deezerTrack) return null;
367
- const dpTrack = buildTrackFromSearch(deezerTrack, this.context.player, track.requestedBy);
406
+ const dpTrack = buildTrackFromSearch(
407
+ deezerTrack,
408
+ this.context.player,
409
+ track.requestedBy
410
+ );
368
411
  const stream = this.stream(dpTrack[0]);
369
412
  return stream;
370
413
  }
package/package.json CHANGED
@@ -1,36 +1,36 @@
1
- {
2
- "name": "discord-player-deezer",
3
- "version": "2.5.0-beta.1",
4
- "description": "A custom extractor made for discord-player that enables you to extract from Deezer.",
5
- "main": "dist/index.js",
6
- "author": "retro_ig",
7
- "license": "MIT",
8
- "dependencies": {
9
- "@mithron/deezer-music-metadata": "^1.0.3",
10
- "blowfish-node": "^1.1.4"
11
- },
12
- "devDependencies": {
13
- "@discord-player/extractor": "^7.1.0",
14
- "@types/node": "^22.10.10",
15
- "discord-player": "^7.1.0",
16
- "prettier": "^3.4.2",
17
- "tslint": "^6.1.3",
18
- "tslint-config-prettier": "^1.18.0",
19
- "tsup": "^8.3.5",
20
- "typescript": "^5.7.2"
21
- },
22
- "scripts": {
23
- "build": "yarn lint && tsup",
24
- "lint": "tslint -p tsconfig.json",
25
- "npm:publish": "yarn build && npm publish --access public",
26
- "prepare": "tsup"
27
- },
28
- "repository": {
29
- "type": "git",
30
- "url": "git+https://github.com/retrouser955/discord-player-deezer.git"
31
- },
32
- "bugs": {
33
- "url": "https://github.com/retrouser955/discord-player-deezer/issues"
34
- },
35
- "packageManager": "yarn@4.5.1+sha512.341db9396b6e289fecc30cd7ab3af65060e05ebff4b3b47547b278b9e67b08f485ecd8c79006b405446262142c7a38154445ef7f17c1d5d1de7d90bf9ce7054d"
36
- }
1
+ {
2
+ "name": "discord-player-deezer",
3
+ "version": "2.6.0",
4
+ "description": "A custom extractor made for discord-player that enables you to extract from Deezer.",
5
+ "main": "dist/index.js",
6
+ "author": "retro_ig",
7
+ "license": "MIT",
8
+ "dependencies": {
9
+ "@mithron/deezer-music-metadata": "^1.0.3",
10
+ "blowfish-node": "^1.1.4"
11
+ },
12
+ "devDependencies": {
13
+ "@discord-player/extractor": "^7.1.0",
14
+ "@types/node": "^22.10.10",
15
+ "discord-player": "^7.1.0",
16
+ "prettier": "^3.4.2",
17
+ "tslint": "^6.1.3",
18
+ "tslint-config-prettier": "^1.18.0",
19
+ "tsup": "^8.3.5",
20
+ "typescript": "^5.7.2"
21
+ },
22
+ "scripts": {
23
+ "build": "yarn lint && tsup",
24
+ "lint": "tslint -p tsconfig.json",
25
+ "npm:publish": "yarn build && npm publish --access public",
26
+ "prepare": "tsup"
27
+ },
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/retrouser955/discord-player-deezer.git"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/retrouser955/discord-player-deezer/issues"
34
+ },
35
+ "packageManager": "yarn@4.5.1+sha512.341db9396b6e289fecc30cd7ab3af65060e05ebff4b3b47547b278b9e67b08f485ecd8c79006b405446262142c7a38154445ef7f17c1d5d1de7d90bf9ce7054d"
36
+ }