distube 4.0.0-dev.6 → 4.0.2
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/dist/index.d.ts +7 -26
- package/dist/index.js +54 -74
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +53 -68
- package/dist/index.mjs.map +1 -1
- package/package.json +18 -18
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,6 @@ import { TypedEmitter } from 'tiny-typed-emitter';
|
|
|
6
6
|
import { AudioPlayer, VoiceConnection, AudioResource, StreamType as StreamType$1 } from '@discordjs/voice';
|
|
7
7
|
import { FFmpeg } from 'prism-media';
|
|
8
8
|
import * as _discordjs_collection from '@discordjs/collection';
|
|
9
|
-
import https from 'https';
|
|
10
|
-
import http from 'http';
|
|
11
9
|
|
|
12
10
|
declare type Awaitable<T = any> = T | PromiseLike<T>;
|
|
13
11
|
declare type DisTubeVoiceEvents = {
|
|
@@ -58,6 +56,7 @@ interface DisTubeOptions {
|
|
|
58
56
|
emitAddListWhenCreatingQueue?: boolean;
|
|
59
57
|
joinNewVoiceChannel?: boolean;
|
|
60
58
|
streamType?: StreamType;
|
|
59
|
+
directLink?: boolean;
|
|
61
60
|
}
|
|
62
61
|
declare type GuildIdResolvable = Queue | DisTubeVoice | Snowflake | Message | GuildTextBasedChannel | VoiceBasedChannel | VoiceState | Guild | GuildMember | Interaction | string;
|
|
63
62
|
interface OtherSongInfo {
|
|
@@ -161,6 +160,7 @@ declare const defaultOptions: {
|
|
|
161
160
|
emitAddListWhenCreatingQueue: boolean;
|
|
162
161
|
joinNewVoiceChannel: boolean;
|
|
163
162
|
streamType: StreamType;
|
|
163
|
+
directLink: boolean;
|
|
164
164
|
};
|
|
165
165
|
|
|
166
166
|
declare const ERROR_MESSAGES: {
|
|
@@ -269,12 +269,12 @@ declare class SearchResultVideo extends ISearchResult {
|
|
|
269
269
|
thumbnail: string;
|
|
270
270
|
constructor(info: Video);
|
|
271
271
|
}
|
|
272
|
+
declare type SearchResult = SearchResultVideo | SearchResultPlaylist;
|
|
272
273
|
declare class SearchResultPlaylist extends ISearchResult {
|
|
273
274
|
type: SearchResultType.PLAYLIST;
|
|
274
275
|
length: number;
|
|
275
276
|
constructor(info: Playlist$1);
|
|
276
277
|
}
|
|
277
|
-
declare type SearchResult = SearchResultVideo | SearchResultPlaylist;
|
|
278
278
|
|
|
279
279
|
declare class Song<T = unknown> {
|
|
280
280
|
#private;
|
|
@@ -433,6 +433,7 @@ declare class Options {
|
|
|
433
433
|
emitAddListWhenCreatingQueue: boolean;
|
|
434
434
|
joinNewVoiceChannel: boolean;
|
|
435
435
|
streamType: StreamType;
|
|
436
|
+
directLink: boolean;
|
|
436
437
|
constructor(options: DisTubeOptions);
|
|
437
438
|
}
|
|
438
439
|
|
|
@@ -543,22 +544,7 @@ declare function checkInvalidKey(target: Record<string, any>, source: Record<str
|
|
|
543
544
|
declare function isObject(obj: any): obj is object;
|
|
544
545
|
declare function isRecord<T = unknown>(obj: any): obj is Record<string, T>;
|
|
545
546
|
|
|
546
|
-
declare class
|
|
547
|
-
validate(url: string): Promise<boolean>;
|
|
548
|
-
resolve(url: string, options?: {
|
|
549
|
-
member?: GuildMember;
|
|
550
|
-
metadata?: any;
|
|
551
|
-
}): Promise<Song<any>>;
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
declare const getResponseHeaders: (httpModule: typeof http | typeof https, url: string) => Promise<http.IncomingHttpHeaders>;
|
|
555
|
-
declare const validateAudioURL: (httpModule: typeof http | typeof https, protocol: string, url: string) => Promise<boolean>;
|
|
556
|
-
declare const resolveHttpSong: (url: string, options: {
|
|
557
|
-
source: "http" | "https";
|
|
558
|
-
member?: GuildMember;
|
|
559
|
-
metadata?: any;
|
|
560
|
-
}) => Promise<Song<any>>;
|
|
561
|
-
declare class HTTPSPlugin extends ExtractorPlugin {
|
|
547
|
+
declare class DirectLinkPlugin extends ExtractorPlugin {
|
|
562
548
|
validate(url: string): Promise<boolean>;
|
|
563
549
|
resolve(url: string, options?: {
|
|
564
550
|
member?: GuildMember;
|
|
@@ -580,12 +566,7 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
580
566
|
static get version(): string;
|
|
581
567
|
get version(): string;
|
|
582
568
|
play(voiceChannel: VoiceBasedChannel, song: string | Song | SearchResult | Playlist, options?: PlayOptions): Promise<void>;
|
|
583
|
-
createCustomPlaylist(songs: (string | Song | SearchResult)[], options?:
|
|
584
|
-
member?: GuildMember;
|
|
585
|
-
properties?: Record<string, any>;
|
|
586
|
-
parallel?: boolean;
|
|
587
|
-
metadata?: any;
|
|
588
|
-
}): Promise<Playlist>;
|
|
569
|
+
createCustomPlaylist(songs: (string | Song | SearchResult)[], options?: CustomPlaylistOptions): Promise<Playlist>;
|
|
589
570
|
search(string: string, options?: {
|
|
590
571
|
type?: SearchResultType;
|
|
591
572
|
limit?: number;
|
|
@@ -620,4 +601,4 @@ declare class DisTube extends TypedEmitter<DisTubeEvents> {
|
|
|
620
601
|
emitError(error: Error, channel?: GuildTextBasedChannel): void;
|
|
621
602
|
}
|
|
622
603
|
|
|
623
|
-
export { Awaitable, BaseManager, Chapter, CustomPlaylistOptions, CustomPlugin, DisTube, DisTubeBase, DisTubeError, DisTubeEvents, DisTubeHandler, DisTubeOptions, DisTubeStream, DisTubeVoice, DisTubeVoiceEvents, DisTubeVoiceManager, ExtractorPlugin, Filter, FilterManager, FilterResolvable, Filters, GuildIdManager, GuildIdResolvable,
|
|
604
|
+
export { Awaitable, BaseManager, Chapter, CustomPlaylistOptions, CustomPlugin, DirectLinkPlugin, DisTube, DisTubeBase, DisTubeError, DisTubeEvents, DisTubeHandler, DisTubeOptions, DisTubeStream, DisTubeVoice, DisTubeVoiceEvents, DisTubeVoiceManager, ExtractorPlugin, Filter, FilterManager, FilterResolvable, Filters, GuildIdManager, GuildIdResolvable, Options, OtherSongInfo, PlayHandlerOptions, PlayOptions, Playlist, PlaylistInfo, Plugin, PluginType, Queue, QueueManager, RelatedSong, RepeatMode, ResolveOptions, ResolvePlaylistOptions, SearchResult, SearchResultPlaylist, SearchResultType, SearchResultVideo, Song, StreamType, TaskQueue, checkIntents, checkInvalidKey, chooseBestVideoFormat, DisTube as default, defaultFilters, defaultOptions, formatDuration, isClientInstance, isGuildInstance, isMemberInstance, isMessageInstance, isObject, isRecord, isSnowflake, isSupportedVoiceChannel, isTextChannelInstance, isURL, isVoiceChannelEmpty, parseNumber, resolveGuildId, toSecond, version };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
"use strict";
|
|
3
2
|
var __create = Object.create;
|
|
4
3
|
var __defProp = Object.defineProperty;
|
|
5
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -57,7 +56,7 @@ var require_package = __commonJS({
|
|
|
57
56
|
"package.json"(exports, module2) {
|
|
58
57
|
module2.exports = {
|
|
59
58
|
name: "distube",
|
|
60
|
-
version: "4.0.
|
|
59
|
+
version: "4.0.2",
|
|
61
60
|
description: "A Discord.js module to simplify your music commands and play songs with audio filters on Discord without any API key.",
|
|
62
61
|
main: "./dist/index.js",
|
|
63
62
|
module: "./dist/index.mjs",
|
|
@@ -81,7 +80,7 @@ var require_package = __commonJS({
|
|
|
81
80
|
prettier: 'prettier --write "**/*.{ts,json,yml,yaml,md}"',
|
|
82
81
|
build: "tsup",
|
|
83
82
|
"build:check": "tsc --noEmit",
|
|
84
|
-
update: "ncu -u
|
|
83
|
+
update: "ncu -u && yarn up '**' -R",
|
|
85
84
|
postinstall: "husky install",
|
|
86
85
|
prepublishOnly: "yarn lint && yarn test",
|
|
87
86
|
prepack: "yarn build && pinst --disable",
|
|
@@ -123,28 +122,29 @@ var require_package = __commonJS({
|
|
|
123
122
|
dependencies: {
|
|
124
123
|
"@distube/ytdl-core": "^4.11.3",
|
|
125
124
|
"@distube/ytpl": "^1.1.1",
|
|
126
|
-
"@distube/ytsr": "^1.1.
|
|
125
|
+
"@distube/ytsr": "^1.1.8",
|
|
127
126
|
"prism-media": "https://codeload.github.com/distubejs/prism-media/tar.gz/main#workaround.tar.gz",
|
|
128
127
|
"tiny-typed-emitter": "^2.1.0",
|
|
129
|
-
tslib: "^2.4.0"
|
|
128
|
+
tslib: "^2.4.0",
|
|
129
|
+
undici: "^5.8.0"
|
|
130
130
|
},
|
|
131
131
|
devDependencies: {
|
|
132
|
-
"@babel/core": "^7.18.
|
|
132
|
+
"@babel/core": "^7.18.9",
|
|
133
133
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
|
134
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.18.
|
|
135
|
-
"@babel/preset-env": "^7.18.
|
|
134
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.18.9",
|
|
135
|
+
"@babel/preset-env": "^7.18.9",
|
|
136
136
|
"@babel/preset-typescript": "^7.18.6",
|
|
137
137
|
"@commitlint/cli": "^17.0.3",
|
|
138
138
|
"@commitlint/config-conventional": "^17.0.3",
|
|
139
|
-
"@discordjs/voice": "
|
|
139
|
+
"@discordjs/voice": "^0.11.0",
|
|
140
140
|
"@distube/docgen": "distubejs/docgen",
|
|
141
|
-
"@types/jest": "^28.1.
|
|
142
|
-
"@types/node": "^18.0.
|
|
143
|
-
"@typescript-eslint/eslint-plugin": "^5.30.
|
|
144
|
-
"@typescript-eslint/parser": "^5.30.
|
|
141
|
+
"@types/jest": "^28.1.6",
|
|
142
|
+
"@types/node": "^18.0.6",
|
|
143
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
144
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
145
145
|
"babel-jest": "^28.1.3",
|
|
146
|
-
"discord.js": "
|
|
147
|
-
eslint: "^8.
|
|
146
|
+
"discord.js": "^14.0.2",
|
|
147
|
+
eslint: "^8.20.0",
|
|
148
148
|
"eslint-config-distube": "^1.6.4",
|
|
149
149
|
"eslint-config-prettier": "^8.5.0",
|
|
150
150
|
"eslint-plugin-deprecation": "^1.3.2",
|
|
@@ -153,7 +153,7 @@ var require_package = __commonJS({
|
|
|
153
153
|
jest: "^28.1.3",
|
|
154
154
|
"jsdoc-babel": "^0.5.0",
|
|
155
155
|
"nano-staged": "^0.8.0",
|
|
156
|
-
"npm-check-updates": "^15.3.
|
|
156
|
+
"npm-check-updates": "^15.3.4",
|
|
157
157
|
pinst: "^3.0.0",
|
|
158
158
|
prettier: "^2.7.1",
|
|
159
159
|
tsup: "^6.1.3",
|
|
@@ -162,7 +162,7 @@ var require_package = __commonJS({
|
|
|
162
162
|
peerDependencies: {
|
|
163
163
|
"@discordjs/opus": "*",
|
|
164
164
|
"@discordjs/voice": "*",
|
|
165
|
-
"discord.js": "14
|
|
165
|
+
"discord.js": "14"
|
|
166
166
|
},
|
|
167
167
|
peerDependenciesMeta: {
|
|
168
168
|
"@discordjs/opus": {
|
|
@@ -181,8 +181,7 @@ var require_package = __commonJS({
|
|
|
181
181
|
engines: {
|
|
182
182
|
node: ">=16.9.0"
|
|
183
183
|
},
|
|
184
|
-
packageManager: "yarn@3.2.0"
|
|
185
|
-
stableVersion: "4.0.0-dev"
|
|
184
|
+
packageManager: "yarn@3.2.0"
|
|
186
185
|
};
|
|
187
186
|
}
|
|
188
187
|
});
|
|
@@ -192,6 +191,7 @@ var src_exports = {};
|
|
|
192
191
|
__export(src_exports, {
|
|
193
192
|
BaseManager: () => BaseManager,
|
|
194
193
|
CustomPlugin: () => CustomPlugin,
|
|
194
|
+
DirectLinkPlugin: () => DirectLinkPlugin,
|
|
195
195
|
DisTube: () => DisTube,
|
|
196
196
|
DisTubeBase: () => DisTubeBase,
|
|
197
197
|
DisTubeError: () => DisTubeError,
|
|
@@ -202,8 +202,6 @@ __export(src_exports, {
|
|
|
202
202
|
ExtractorPlugin: () => ExtractorPlugin,
|
|
203
203
|
FilterManager: () => FilterManager,
|
|
204
204
|
GuildIdManager: () => GuildIdManager,
|
|
205
|
-
HTTPPlugin: () => HTTPPlugin,
|
|
206
|
-
HTTPSPlugin: () => HTTPSPlugin,
|
|
207
205
|
Options: () => Options,
|
|
208
206
|
Playlist: () => Playlist,
|
|
209
207
|
Plugin: () => Plugin,
|
|
@@ -224,7 +222,6 @@ __export(src_exports, {
|
|
|
224
222
|
defaultFilters: () => defaultFilters,
|
|
225
223
|
defaultOptions: () => defaultOptions,
|
|
226
224
|
formatDuration: () => formatDuration,
|
|
227
|
-
getResponseHeaders: () => getResponseHeaders,
|
|
228
225
|
isClientInstance: () => isClientInstance,
|
|
229
226
|
isGuildInstance: () => isGuildInstance,
|
|
230
227
|
isMemberInstance: () => isMemberInstance,
|
|
@@ -238,9 +235,7 @@ __export(src_exports, {
|
|
|
238
235
|
isVoiceChannelEmpty: () => isVoiceChannelEmpty,
|
|
239
236
|
parseNumber: () => parseNumber,
|
|
240
237
|
resolveGuildId: () => resolveGuildId,
|
|
241
|
-
resolveHttpSong: () => resolveHttpSong,
|
|
242
238
|
toSecond: () => toSecond,
|
|
243
|
-
validateAudioURL: () => validateAudioURL,
|
|
244
239
|
version: () => version
|
|
245
240
|
});
|
|
246
241
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -301,7 +296,8 @@ var defaultOptions = {
|
|
|
301
296
|
emitAddSongWhenCreatingQueue: true,
|
|
302
297
|
emitAddListWhenCreatingQueue: true,
|
|
303
298
|
joinNewVoiceChannel: true,
|
|
304
|
-
streamType: 0 /* OPUS
|
|
299
|
+
streamType: 0 /* OPUS */,
|
|
300
|
+
directLink: true
|
|
305
301
|
};
|
|
306
302
|
|
|
307
303
|
// src/struct/DisTubeError.ts
|
|
@@ -426,6 +422,7 @@ var Playlist = class {
|
|
|
426
422
|
this.songs = playlist;
|
|
427
423
|
this.name = this.songs[0].name ? `${this.songs[0].name} and ${this.songs.length - 1} more songs.` : `${this.songs.length} songs playlist`;
|
|
428
424
|
this.thumbnail = this.songs[0].thumbnail;
|
|
425
|
+
this.member = member || void 0;
|
|
429
426
|
} else {
|
|
430
427
|
this.source = (playlist.source || "youtube").toLowerCase();
|
|
431
428
|
if (!Array.isArray(playlist.songs) || !playlist.songs.length)
|
|
@@ -434,12 +431,12 @@ var Playlist = class {
|
|
|
434
431
|
this.name = playlist.name || playlist.title || (this.songs[0].name ? `${this.songs[0].name} and ${this.songs.length - 1} more songs.` : `${this.songs.length} songs playlist`);
|
|
435
432
|
this.url = playlist.url || playlist.webpage_url;
|
|
436
433
|
this.thumbnail = playlist.thumbnail || this.songs[0].thumbnail;
|
|
434
|
+
this.member = member || playlist.member || void 0;
|
|
437
435
|
}
|
|
438
436
|
this.songs.map((s) => s.constructor.name === "Song" && (s.playlist = this));
|
|
439
437
|
if (properties)
|
|
440
438
|
for (const [key, value] of Object.entries(properties))
|
|
441
439
|
this[key] = value;
|
|
442
|
-
this.member = member;
|
|
443
440
|
this.metadata = metadata;
|
|
444
441
|
}
|
|
445
442
|
get duration() {
|
|
@@ -1195,6 +1192,8 @@ Name: ${song.name}`;
|
|
|
1195
1192
|
}
|
|
1196
1193
|
this.emitError(error, queue.textChannel);
|
|
1197
1194
|
if (queue.songs.length > 0) {
|
|
1195
|
+
queue._next = queue._prev = false;
|
|
1196
|
+
queue.beginTime = 0;
|
|
1198
1197
|
this.playSong(queue).then((e) => {
|
|
1199
1198
|
if (!e)
|
|
1200
1199
|
this.emit("playSong", queue, queue.songs[0]);
|
|
@@ -1278,8 +1277,11 @@ var DisTubeHandler = class extends DisTubeBase {
|
|
|
1278
1277
|
return new Song(song, options);
|
|
1279
1278
|
if (song instanceof SearchResultPlaylist)
|
|
1280
1279
|
return this.resolvePlaylist(song.url, options);
|
|
1281
|
-
if (isObject(song))
|
|
1280
|
+
if (isObject(song)) {
|
|
1281
|
+
if (!("url" in song) && !("id" in song))
|
|
1282
|
+
throw new DisTubeError("CANNOT_RESOLVE_SONG", song);
|
|
1282
1283
|
return new Song(song, options);
|
|
1284
|
+
}
|
|
1283
1285
|
if (import_ytpl.default.validateID(song))
|
|
1284
1286
|
return this.resolvePlaylist(song, options);
|
|
1285
1287
|
if (import_ytdl_core.default.validateURL(song))
|
|
@@ -1471,6 +1473,7 @@ var Options = class {
|
|
|
1471
1473
|
__publicField(this, "emitAddListWhenCreatingQueue");
|
|
1472
1474
|
__publicField(this, "joinNewVoiceChannel");
|
|
1473
1475
|
__publicField(this, "streamType");
|
|
1476
|
+
__publicField(this, "directLink");
|
|
1474
1477
|
if (typeof options !== "object" || Array.isArray(options)) {
|
|
1475
1478
|
throw new DisTubeError("INVALID_TYPE", "object", options, "DisTubeOptions");
|
|
1476
1479
|
}
|
|
@@ -1493,6 +1496,7 @@ var Options = class {
|
|
|
1493
1496
|
this.emitAddListWhenCreatingQueue = opts.emitAddListWhenCreatingQueue;
|
|
1494
1497
|
this.joinNewVoiceChannel = opts.joinNewVoiceChannel;
|
|
1495
1498
|
this.streamType = opts.streamType;
|
|
1499
|
+
this.directLink = opts.directLink;
|
|
1496
1500
|
checkInvalidKey(opts, this, "DisTubeOptions");
|
|
1497
1501
|
__privateMethod(this, _validateOptions, validateOptions_fn).call(this);
|
|
1498
1502
|
}
|
|
@@ -1554,6 +1558,9 @@ validateOptions_fn = /* @__PURE__ */ __name(function(options = this) {
|
|
|
1554
1558
|
if (typeof options.streamType !== "number" || isNaN(options.streamType) || !StreamType[options.streamType]) {
|
|
1555
1559
|
throw new DisTubeError("INVALID_TYPE", "StreamType", options.streamType, "DisTubeOptions.streamType");
|
|
1556
1560
|
}
|
|
1561
|
+
if (typeof options.directLink !== "boolean") {
|
|
1562
|
+
throw new DisTubeError("INVALID_TYPE", "boolean", options.directLink, "DisTubeOptions.directLink");
|
|
1563
|
+
}
|
|
1557
1564
|
}, "#validateOptions");
|
|
1558
1565
|
|
|
1559
1566
|
// src/core/DisTubeStream.ts
|
|
@@ -2034,7 +2041,7 @@ function isMemberInstance(member) {
|
|
|
2034
2041
|
}
|
|
2035
2042
|
__name(isMemberInstance, "isMemberInstance");
|
|
2036
2043
|
function isTextChannelInstance(channel) {
|
|
2037
|
-
return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && typeof channel.name === "string" && import_discord2.Constants.TextBasedChannelTypes.includes(channel.type) && typeof channel.nsfw === "boolean" &&
|
|
2044
|
+
return !!channel && isSnowflake(channel.id) && isSnowflake(channel.guildId) && typeof channel.name === "string" && import_discord2.Constants.TextBasedChannelTypes.includes(channel.type) && typeof channel.nsfw === "boolean" && "messages" in channel && typeof channel.send === "function";
|
|
2038
2045
|
}
|
|
2039
2046
|
__name(isTextChannelInstance, "isTextChannelInstance");
|
|
2040
2047
|
function isMessageInstance(message) {
|
|
@@ -2089,52 +2096,28 @@ function isRecord(obj) {
|
|
|
2089
2096
|
}
|
|
2090
2097
|
__name(isRecord, "isRecord");
|
|
2091
2098
|
|
|
2092
|
-
// src/plugin/
|
|
2093
|
-
var
|
|
2094
|
-
var
|
|
2099
|
+
// src/plugin/DirectLink.ts
|
|
2100
|
+
var import_undici = require("undici");
|
|
2101
|
+
var DirectLinkPlugin = class extends ExtractorPlugin {
|
|
2095
2102
|
async validate(url) {
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
// src/plugin/https.ts
|
|
2105
|
-
var import_https = __toESM(require("https"));
|
|
2106
|
-
var import_url2 = require("url");
|
|
2107
|
-
var getResponseHeaders = /* @__PURE__ */ __name(async (httpModule, url) => new Promise((resolve, reject) => {
|
|
2108
|
-
httpModule.get(url).on("response", (res) => {
|
|
2109
|
-
resolve(res.headers);
|
|
2110
|
-
}).on("error", reject);
|
|
2111
|
-
}), "getResponseHeaders");
|
|
2112
|
-
var validateAudioURL = /* @__PURE__ */ __name(async (httpModule, protocol, url) => {
|
|
2113
|
-
if (new import_url2.URL(url).protocol.toLowerCase() !== protocol) {
|
|
2103
|
+
try {
|
|
2104
|
+
const headers = await (0, import_undici.request)(url, { method: "HEAD" }).then((res) => res.headers);
|
|
2105
|
+
const type = headers["content-type"];
|
|
2106
|
+
if (type?.startsWith("audio"))
|
|
2107
|
+
return true;
|
|
2108
|
+
} catch {
|
|
2109
|
+
}
|
|
2114
2110
|
return false;
|
|
2115
2111
|
}
|
|
2116
|
-
const headers = await getResponseHeaders(httpModule, url), type = headers["content-type"];
|
|
2117
|
-
if (type?.startsWith("audio")) {
|
|
2118
|
-
return true;
|
|
2119
|
-
}
|
|
2120
|
-
return false;
|
|
2121
|
-
}, "validateAudioURL");
|
|
2122
|
-
var resolveHttpSong = /* @__PURE__ */ __name(async (url, options) => {
|
|
2123
|
-
url = url.replace(/\/+$/, "");
|
|
2124
|
-
return new Song({
|
|
2125
|
-
name: url.substring(url.lastIndexOf("/") + 1).replace(/((\?|#).*)?$/, "") || url,
|
|
2126
|
-
url
|
|
2127
|
-
}, options);
|
|
2128
|
-
}, "resolveHttpSong");
|
|
2129
|
-
var HTTPSPlugin = class extends ExtractorPlugin {
|
|
2130
|
-
async validate(url) {
|
|
2131
|
-
return validateAudioURL(import_https.default, "https:", url);
|
|
2132
|
-
}
|
|
2133
2112
|
async resolve(url, options = {}) {
|
|
2134
|
-
|
|
2113
|
+
url = url.replace(/\/+$/, "");
|
|
2114
|
+
return new Song({
|
|
2115
|
+
name: url.substring(url.lastIndexOf("/") + 1).replace(/((\?|#).*)?$/, "") || url,
|
|
2116
|
+
url
|
|
2117
|
+
}, options);
|
|
2135
2118
|
}
|
|
2136
2119
|
};
|
|
2137
|
-
__name(
|
|
2120
|
+
__name(DirectLinkPlugin, "DirectLinkPlugin");
|
|
2138
2121
|
|
|
2139
2122
|
// src/DisTube.ts
|
|
2140
2123
|
var import_ytsr = __toESM(require("@distube/ytsr"));
|
|
@@ -2161,7 +2144,8 @@ var DisTube = class extends import_tiny_typed_emitter2.TypedEmitter {
|
|
|
2161
2144
|
this.handler = new DisTubeHandler(this);
|
|
2162
2145
|
this.queues = new QueueManager(this);
|
|
2163
2146
|
this.filters = { ...defaultFilters, ...this.options.customFilters };
|
|
2164
|
-
this.options.
|
|
2147
|
+
if (this.options.directLink)
|
|
2148
|
+
this.options.plugins.push(new DirectLinkPlugin());
|
|
2165
2149
|
this.options.plugins.map((p) => p.init(this));
|
|
2166
2150
|
this.extractorPlugins = this.options.plugins.filter((p) => p.type === "extractor");
|
|
2167
2151
|
this.customPlugins = this.options.plugins.filter((p) => p.type === "custom");
|
|
@@ -2385,6 +2369,7 @@ __name(DisTube, "DisTube");
|
|
|
2385
2369
|
0 && (module.exports = {
|
|
2386
2370
|
BaseManager,
|
|
2387
2371
|
CustomPlugin,
|
|
2372
|
+
DirectLinkPlugin,
|
|
2388
2373
|
DisTube,
|
|
2389
2374
|
DisTubeBase,
|
|
2390
2375
|
DisTubeError,
|
|
@@ -2395,8 +2380,6 @@ __name(DisTube, "DisTube");
|
|
|
2395
2380
|
ExtractorPlugin,
|
|
2396
2381
|
FilterManager,
|
|
2397
2382
|
GuildIdManager,
|
|
2398
|
-
HTTPPlugin,
|
|
2399
|
-
HTTPSPlugin,
|
|
2400
2383
|
Options,
|
|
2401
2384
|
Playlist,
|
|
2402
2385
|
Plugin,
|
|
@@ -2416,7 +2399,6 @@ __name(DisTube, "DisTube");
|
|
|
2416
2399
|
defaultFilters,
|
|
2417
2400
|
defaultOptions,
|
|
2418
2401
|
formatDuration,
|
|
2419
|
-
getResponseHeaders,
|
|
2420
2402
|
isClientInstance,
|
|
2421
2403
|
isGuildInstance,
|
|
2422
2404
|
isMemberInstance,
|
|
@@ -2430,9 +2412,7 @@ __name(DisTube, "DisTube");
|
|
|
2430
2412
|
isVoiceChannelEmpty,
|
|
2431
2413
|
parseNumber,
|
|
2432
2414
|
resolveGuildId,
|
|
2433
|
-
resolveHttpSong,
|
|
2434
2415
|
toSecond,
|
|
2435
|
-
validateAudioURL,
|
|
2436
2416
|
version
|
|
2437
2417
|
});
|
|
2438
2418
|
//# sourceMappingURL=index.js.map
|