discord-player-deezer 2.1.0 → 2.2.1-dev.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/.yarn/install-state.gz +0 -0
- package/.yarnrc.yml +1 -0
- package/LICENSE +121 -121
- package/dist/index.d.ts +6 -3
- package/dist/index.js +32 -7
- package/package.json +35 -36
- package/readme.md +34 -34
- package/src/DeezerExtractor.ts +138 -131
- package/src/index.ts +1 -1
- package/src/utils/util.ts +216 -194
- package/tsconfig.json +24 -24
- package/tslint.json +2 -2
- package/tsup.config.ts +8 -8
|
Binary file
|
package/.yarnrc.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
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,4 +1,4 @@
|
|
|
1
|
-
import { Track, ExtractorStreamable, BaseExtractor, ExtractorSearchContext, Playlist as Playlist$1, ExtractorInfo, Player } from 'discord-player';
|
|
1
|
+
import { Track, ExtractorStreamable, BaseExtractor, SearchQueryType, ExtractorSearchContext, Playlist as Playlist$1, ExtractorInfo, Player } from 'discord-player';
|
|
2
2
|
import { Playlist, Track as Track$1 } from '@mithron/deezer-music-metadata';
|
|
3
3
|
import * as crypto from 'crypto';
|
|
4
4
|
import { PassThrough } from 'stream';
|
|
@@ -14,6 +14,7 @@ import { PassThrough } from 'stream';
|
|
|
14
14
|
type DeezerExtractorOptions = {
|
|
15
15
|
decryptionKey?: string;
|
|
16
16
|
createStream?: (track: Track, ext: DeezerExtractor) => Promise<ExtractorStreamable>;
|
|
17
|
+
searchLimit?: number;
|
|
17
18
|
};
|
|
18
19
|
type DeezerUserInfo = {
|
|
19
20
|
cookie: string;
|
|
@@ -29,7 +30,7 @@ declare class DeezerExtractor extends BaseExtractor<DeezerExtractorOptions> {
|
|
|
29
30
|
static identifier: string;
|
|
30
31
|
userInfo: DeezerUserInfo;
|
|
31
32
|
activate(): Promise<void>;
|
|
32
|
-
validate(query: string): Promise<boolean>;
|
|
33
|
+
validate(query: string, type: SearchQueryType & "deezer"): Promise<boolean>;
|
|
33
34
|
buildPlaylistData(data: Playlist, handleContext: ExtractorSearchContext): Playlist$1;
|
|
34
35
|
handle(query: string, context: ExtractorSearchContext): Promise<ExtractorInfo>;
|
|
35
36
|
buildTrack(track: Track$1, { requestedBy }: ExtractorSearchContext): Track<unknown>;
|
|
@@ -38,6 +39,8 @@ declare class DeezerExtractor extends BaseExtractor<DeezerExtractorOptions> {
|
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
declare function getCrypto(): Promise<typeof crypto>;
|
|
42
|
+
declare function isUrl(query: string): Promise<boolean>;
|
|
43
|
+
declare function search(query: string, limit?: number): Promise<DeezerSearchTrackResponse>;
|
|
41
44
|
type ArrayOrObject<T> = T | T[];
|
|
42
45
|
interface DeezerSearchTrackResponse {
|
|
43
46
|
data: {
|
|
@@ -67,4 +70,4 @@ declare const deezerRegex: {
|
|
|
67
70
|
};
|
|
68
71
|
declare function validate(query: string): boolean;
|
|
69
72
|
|
|
70
|
-
export { type ArrayOrObject, DeezerExtractor, type DeezerExtractorOptions, type DeezerSearchTrackResponse, type DeezerUserInfo, Warnings, buildTrackFromSearch, deezerRegex, extractTrackId, getCrypto, searchOneTrack, streamTrack, validate };
|
|
73
|
+
export { type ArrayOrObject, DeezerExtractor, type DeezerExtractorOptions, type DeezerSearchTrackResponse, type DeezerUserInfo, Warnings, buildTrackFromSearch, deezerRegex, extractTrackId, getCrypto, isUrl, search, searchOneTrack, streamTrack, validate };
|
package/dist/index.js
CHANGED
|
@@ -28,19 +28,21 @@ 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
|
|
32
|
-
__export(
|
|
31
|
+
var index_exports = {};
|
|
32
|
+
__export(index_exports, {
|
|
33
33
|
DeezerExtractor: () => DeezerExtractor,
|
|
34
34
|
Warnings: () => Warnings,
|
|
35
35
|
buildTrackFromSearch: () => buildTrackFromSearch,
|
|
36
36
|
deezerRegex: () => deezerRegex,
|
|
37
37
|
extractTrackId: () => extractTrackId,
|
|
38
38
|
getCrypto: () => getCrypto,
|
|
39
|
+
isUrl: () => isUrl,
|
|
40
|
+
search: () => search,
|
|
39
41
|
searchOneTrack: () => searchOneTrack,
|
|
40
42
|
streamTrack: () => streamTrack,
|
|
41
43
|
validate: () => validate
|
|
42
44
|
});
|
|
43
|
-
module.exports = __toCommonJS(
|
|
45
|
+
module.exports = __toCommonJS(index_exports);
|
|
44
46
|
|
|
45
47
|
// src/DeezerExtractor.ts
|
|
46
48
|
var import_discord_player2 = require("discord-player");
|
|
@@ -59,12 +61,28 @@ async function getCrypto() {
|
|
|
59
61
|
}
|
|
60
62
|
return rawCrypto;
|
|
61
63
|
}
|
|
64
|
+
async function isUrl(query) {
|
|
65
|
+
try {
|
|
66
|
+
new URL(query);
|
|
67
|
+
return true;
|
|
68
|
+
} catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
62
72
|
var DeezerAPIRoutes = {
|
|
63
73
|
searchTrack(query, limit) {
|
|
64
74
|
const url = `https://api.deezer.com/search/track?q=${encodeURIComponent(query)}&${limit ? `limit=${limit}` : ""}`;
|
|
65
75
|
return url;
|
|
66
76
|
}
|
|
67
77
|
};
|
|
78
|
+
async function search(query, limit = 10) {
|
|
79
|
+
const route = DeezerAPIRoutes.searchTrack(query, limit);
|
|
80
|
+
const response = await fetch(route);
|
|
81
|
+
if (!response.status.toString().startsWith("2")) throw new Error("Server responded with a non 2xx status.");
|
|
82
|
+
const jsonTrack = await response.json();
|
|
83
|
+
if (!jsonTrack.data || !Array.isArray(jsonTrack.data) || jsonTrack.data.length === 0) throw new Error("Unable get tracks from Deezer for the query '" + query + "'");
|
|
84
|
+
return jsonTrack;
|
|
85
|
+
}
|
|
68
86
|
function buildTrackFromSearch(track, player, requestedBy) {
|
|
69
87
|
const tracks = track.data.map((v) => new import_discord_player.Track(player, {
|
|
70
88
|
source: "arbitrary",
|
|
@@ -143,6 +161,8 @@ async function streamTrack(track, ext) {
|
|
|
143
161
|
let buffer = Buffer.alloc(0);
|
|
144
162
|
let i = 0;
|
|
145
163
|
const bufferSize = 2048;
|
|
164
|
+
const blowfishDecrypter = new import_blowfish_node.default(new Uint8Array(trackKey), import_blowfish_node.default.MODE.CBC, import_blowfish_node.default.PADDING.NULL);
|
|
165
|
+
blowfishDecrypter.setIv(new Uint8Array(IV));
|
|
146
166
|
const passThrough = new import_stream.PassThrough();
|
|
147
167
|
readable.on("readable", () => {
|
|
148
168
|
let chunk = null;
|
|
@@ -157,8 +177,6 @@ async function streamTrack(track, ext) {
|
|
|
157
177
|
} else {
|
|
158
178
|
buffer = Buffer.concat([buffer, chunk]);
|
|
159
179
|
}
|
|
160
|
-
const blowfishDecrypter = new import_blowfish_node.default(new Uint8Array(trackKey), import_blowfish_node.default.MODE.CBC, import_blowfish_node.default.PADDING.NULL);
|
|
161
|
-
blowfishDecrypter.setIv(new Uint8Array(IV));
|
|
162
180
|
while (buffer.length >= bufferSize) {
|
|
163
181
|
const bufferSized = buffer.subarray(0, bufferSize);
|
|
164
182
|
if (i % 3 === 0) {
|
|
@@ -209,8 +227,8 @@ var DeezerExtractor = class extends import_discord_player2.BaseExtractor {
|
|
|
209
227
|
this.context.player.debug("USER INFO EXT: " + JSON.stringify(this.userInfo));
|
|
210
228
|
}
|
|
211
229
|
}
|
|
212
|
-
async validate(query) {
|
|
213
|
-
return validate(query);
|
|
230
|
+
async validate(query, type) {
|
|
231
|
+
return validate(query) || type === "deezer";
|
|
214
232
|
}
|
|
215
233
|
buildPlaylistData(data, handleContext) {
|
|
216
234
|
const raw = data.url.split("/");
|
|
@@ -231,6 +249,11 @@ var DeezerExtractor = class extends import_discord_player2.BaseExtractor {
|
|
|
231
249
|
});
|
|
232
250
|
}
|
|
233
251
|
async handle(query, context) {
|
|
252
|
+
if (context.protocol === "deezer" && !isUrl(query)) {
|
|
253
|
+
const rawSearch = await search(query);
|
|
254
|
+
const tracks = buildTrackFromSearch(rawSearch, this.context.player, context.requestedBy);
|
|
255
|
+
return this.createResponse(null, tracks);
|
|
256
|
+
}
|
|
234
257
|
if (deezerRegex.share.test(query)) {
|
|
235
258
|
const redirect = await fetch(query);
|
|
236
259
|
query = redirect.url;
|
|
@@ -274,6 +297,8 @@ DeezerExtractor.identifier = "com.retrouser955.discord-player.deezr-ext";
|
|
|
274
297
|
deezerRegex,
|
|
275
298
|
extractTrackId,
|
|
276
299
|
getCrypto,
|
|
300
|
+
isUrl,
|
|
301
|
+
search,
|
|
277
302
|
searchOneTrack,
|
|
278
303
|
streamTrack,
|
|
279
304
|
validate
|
package/package.json
CHANGED
|
@@ -1,36 +1,35 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "discord-player-deezer",
|
|
3
|
-
"version": "2.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
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"@
|
|
15
|
-
"discord-player": "^
|
|
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": "https://github.com/retrouser955/discord-player-deezer/"
|
|
31
|
-
},
|
|
32
|
-
"bugs": {
|
|
33
|
-
"url": "https://github.com/retrouser955/discord-player-deezer/issues"
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "discord-player-deezer",
|
|
3
|
+
"version": "2.2.1-dev.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": "https://github.com/retrouser955/discord-player-deezer/"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/retrouser955/discord-player-deezer/issues"
|
|
34
|
+
}
|
|
35
|
+
}
|
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
|
```
|