discord-player 5.3.0-dev.2 → 5.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,32 +1,33 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.version = exports.Util = exports.StreamDispatcher = exports.VoiceUtils = exports.Track = exports.Queue = exports.QueryResolver = exports.ErrorStatusCode = exports.PlayerError = exports.Player = exports.Playlist = exports.ExtractorModel = exports.AudioFilters = void 0;
4
- const tslib_1 = require("tslib");
5
- // try applying smooth volume patch on load
6
- require("./smoothVolume");
7
- var AudioFilters_1 = require("./utils/AudioFilters");
8
- Object.defineProperty(exports, "AudioFilters", { enumerable: true, get: function () { return AudioFilters_1.AudioFilters; } });
9
- var ExtractorModel_1 = require("./Structures/ExtractorModel");
10
- Object.defineProperty(exports, "ExtractorModel", { enumerable: true, get: function () { return ExtractorModel_1.ExtractorModel; } });
11
- var Playlist_1 = require("./Structures/Playlist");
12
- Object.defineProperty(exports, "Playlist", { enumerable: true, get: function () { return Playlist_1.Playlist; } });
13
- var Player_1 = require("./Player");
14
- Object.defineProperty(exports, "Player", { enumerable: true, get: function () { return Player_1.Player; } });
15
- var PlayerError_1 = require("./Structures/PlayerError");
16
- Object.defineProperty(exports, "PlayerError", { enumerable: true, get: function () { return PlayerError_1.PlayerError; } });
17
- Object.defineProperty(exports, "ErrorStatusCode", { enumerable: true, get: function () { return PlayerError_1.ErrorStatusCode; } });
18
- var QueryResolver_1 = require("./utils/QueryResolver");
19
- Object.defineProperty(exports, "QueryResolver", { enumerable: true, get: function () { return QueryResolver_1.QueryResolver; } });
20
- var Queue_1 = require("./Structures/Queue");
21
- Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return Queue_1.Queue; } });
22
- var Track_1 = require("./Structures/Track");
23
- Object.defineProperty(exports, "Track", { enumerable: true, get: function () { return Track_1.Track; } });
24
- var VoiceUtils_1 = require("./VoiceInterface/VoiceUtils");
25
- Object.defineProperty(exports, "VoiceUtils", { enumerable: true, get: function () { return VoiceUtils_1.VoiceUtils; } });
26
- var StreamDispatcher_1 = require("./VoiceInterface/StreamDispatcher");
27
- Object.defineProperty(exports, "StreamDispatcher", { enumerable: true, get: function () { return StreamDispatcher_1.StreamDispatcher; } });
28
- var Util_1 = require("./utils/Util");
29
- Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return Util_1.Util; } });
30
- tslib_1.__exportStar(require("./types/types"), exports);
31
- // eslint-disable-next-line @typescript-eslint/no-var-requires
32
- exports.version = require(`${__dirname}/../package.json`).version;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = exports.Util = exports.StreamDispatcher = exports.VoiceUtils = exports.Track = exports.Queue = exports.QueryResolver = exports.ErrorStatusCode = exports.PlayerError = exports.Player = exports.Playlist = exports.ExtractorModel = exports.AudioFilters = void 0;
4
+ const tslib_1 = require("tslib");
5
+ // try applying smooth volume patch on load
6
+ require("./smoothVolume");
7
+ var AudioFilters_1 = require("./utils/AudioFilters");
8
+ Object.defineProperty(exports, "AudioFilters", { enumerable: true, get: function () { return AudioFilters_1.AudioFilters; } });
9
+ var ExtractorModel_1 = require("./Structures/ExtractorModel");
10
+ Object.defineProperty(exports, "ExtractorModel", { enumerable: true, get: function () { return ExtractorModel_1.ExtractorModel; } });
11
+ var Playlist_1 = require("./Structures/Playlist");
12
+ Object.defineProperty(exports, "Playlist", { enumerable: true, get: function () { return Playlist_1.Playlist; } });
13
+ var Player_1 = require("./Player");
14
+ Object.defineProperty(exports, "Player", { enumerable: true, get: function () { return Player_1.Player; } });
15
+ var PlayerError_1 = require("./Structures/PlayerError");
16
+ Object.defineProperty(exports, "PlayerError", { enumerable: true, get: function () { return PlayerError_1.PlayerError; } });
17
+ Object.defineProperty(exports, "ErrorStatusCode", { enumerable: true, get: function () { return PlayerError_1.ErrorStatusCode; } });
18
+ var QueryResolver_1 = require("./utils/QueryResolver");
19
+ Object.defineProperty(exports, "QueryResolver", { enumerable: true, get: function () { return QueryResolver_1.QueryResolver; } });
20
+ var Queue_1 = require("./Structures/Queue");
21
+ Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return Queue_1.Queue; } });
22
+ var Track_1 = require("./Structures/Track");
23
+ Object.defineProperty(exports, "Track", { enumerable: true, get: function () { return Track_1.Track; } });
24
+ var VoiceUtils_1 = require("./VoiceInterface/VoiceUtils");
25
+ Object.defineProperty(exports, "VoiceUtils", { enumerable: true, get: function () { return VoiceUtils_1.VoiceUtils; } });
26
+ var StreamDispatcher_1 = require("./VoiceInterface/StreamDispatcher");
27
+ Object.defineProperty(exports, "StreamDispatcher", { enumerable: true, get: function () { return StreamDispatcher_1.StreamDispatcher; } });
28
+ var Util_1 = require("./utils/Util");
29
+ Object.defineProperty(exports, "Util", { enumerable: true, get: function () { return Util_1.Util; } });
30
+ tslib_1.__exportStar(require("./types/types"), exports);
31
+ tslib_1.__exportStar(require("./utils/FFmpegStream"), exports);
32
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
33
+ exports.version = require(`${__dirname}/../package.json`).version;
package/dist/index.mjs CHANGED
@@ -4,6 +4,8 @@ export default mod;
4
4
  export const AudioFilters = mod.AudioFilters;
5
5
  export const ErrorStatusCode = mod.ErrorStatusCode;
6
6
  export const ExtractorModel = mod.ExtractorModel;
7
+ export const FFMPEG_ARGS_PIPED = mod.FFMPEG_ARGS_PIPED;
8
+ export const FFMPEG_ARGS_STRING = mod.FFMPEG_ARGS_STRING;
7
9
  export const Player = mod.Player;
8
10
  export const PlayerError = mod.PlayerError;
9
11
  export const Playlist = mod.Playlist;
@@ -15,4 +17,5 @@ export const StreamDispatcher = mod.StreamDispatcher;
15
17
  export const Track = mod.Track;
16
18
  export const Util = mod.Util;
17
19
  export const VoiceUtils = mod.VoiceUtils;
20
+ export const createFFmpegStream = mod.createFFmpegStream;
18
21
  export const version = mod.version;
@@ -1,13 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const VolumeTransformer_1 = require("./VoiceInterface/VolumeTransformer");
4
- try {
5
- // eslint-disable-next-line
6
- const mod = require("prism-media");
7
- if (typeof mod.VolumeTransformer.hasSmoothing !== "boolean") {
8
- Reflect.set(mod, "VolumeTransformer", VolumeTransformer_1.VolumeTransformer);
9
- }
10
- }
11
- catch {
12
- /* do nothing */
13
- }
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const VolumeTransformer_1 = require("./VoiceInterface/VolumeTransformer");
4
+ try {
5
+ // eslint-disable-next-line
6
+ const mod = require("prism-media");
7
+ if (typeof mod.VolumeTransformer.hasSmoothing !== "boolean") {
8
+ Reflect.set(mod, "VolumeTransformer", VolumeTransformer_1.VolumeTransformer);
9
+ }
10
+ }
11
+ catch {
12
+ /* do nothing */
13
+ }
@@ -1,58 +1,58 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueueRepeatMode = exports.QueryType = void 0;
4
- /**
5
- * The search query type
6
- * This can be one of:
7
- * - AUTO
8
- * - YOUTUBE
9
- * - YOUTUBE_PLAYLIST
10
- * - SOUNDCLOUD_TRACK
11
- * - SOUNDCLOUD_PLAYLIST
12
- * - SOUNDCLOUD
13
- * - SPOTIFY_SONG
14
- * - SPOTIFY_ALBUM
15
- * - SPOTIFY_PLAYLIST
16
- * - FACEBOOK
17
- * - VIMEO
18
- * - ARBITRARY
19
- * - REVERBNATION
20
- * - YOUTUBE_SEARCH
21
- * - YOUTUBE_VIDEO
22
- * - SOUNDCLOUD_SEARCH
23
- * @typedef {number} QueryType
24
- */
25
- var QueryType;
26
- (function (QueryType) {
27
- QueryType[QueryType["AUTO"] = 0] = "AUTO";
28
- QueryType[QueryType["YOUTUBE"] = 1] = "YOUTUBE";
29
- QueryType[QueryType["YOUTUBE_PLAYLIST"] = 2] = "YOUTUBE_PLAYLIST";
30
- QueryType[QueryType["SOUNDCLOUD_TRACK"] = 3] = "SOUNDCLOUD_TRACK";
31
- QueryType[QueryType["SOUNDCLOUD_PLAYLIST"] = 4] = "SOUNDCLOUD_PLAYLIST";
32
- QueryType[QueryType["SOUNDCLOUD"] = 5] = "SOUNDCLOUD";
33
- QueryType[QueryType["SPOTIFY_SONG"] = 6] = "SPOTIFY_SONG";
34
- QueryType[QueryType["SPOTIFY_ALBUM"] = 7] = "SPOTIFY_ALBUM";
35
- QueryType[QueryType["SPOTIFY_PLAYLIST"] = 8] = "SPOTIFY_PLAYLIST";
36
- QueryType[QueryType["FACEBOOK"] = 9] = "FACEBOOK";
37
- QueryType[QueryType["VIMEO"] = 10] = "VIMEO";
38
- QueryType[QueryType["ARBITRARY"] = 11] = "ARBITRARY";
39
- QueryType[QueryType["REVERBNATION"] = 12] = "REVERBNATION";
40
- QueryType[QueryType["YOUTUBE_SEARCH"] = 13] = "YOUTUBE_SEARCH";
41
- QueryType[QueryType["YOUTUBE_VIDEO"] = 14] = "YOUTUBE_VIDEO";
42
- QueryType[QueryType["SOUNDCLOUD_SEARCH"] = 15] = "SOUNDCLOUD_SEARCH";
43
- })(QueryType = exports.QueryType || (exports.QueryType = {}));
44
- /**
45
- * The queue repeat mode. This can be one of:
46
- * - OFF
47
- * - TRACK
48
- * - QUEUE
49
- * - AUTOPLAY
50
- * @typedef {number} QueueRepeatMode
51
- */
52
- var QueueRepeatMode;
53
- (function (QueueRepeatMode) {
54
- QueueRepeatMode[QueueRepeatMode["OFF"] = 0] = "OFF";
55
- QueueRepeatMode[QueueRepeatMode["TRACK"] = 1] = "TRACK";
56
- QueueRepeatMode[QueueRepeatMode["QUEUE"] = 2] = "QUEUE";
57
- QueueRepeatMode[QueueRepeatMode["AUTOPLAY"] = 3] = "AUTOPLAY";
58
- })(QueueRepeatMode = exports.QueueRepeatMode || (exports.QueueRepeatMode = {}));
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueueRepeatMode = exports.QueryType = void 0;
4
+ /**
5
+ * The search query type
6
+ * This can be one of:
7
+ * - AUTO
8
+ * - YOUTUBE
9
+ * - YOUTUBE_PLAYLIST
10
+ * - SOUNDCLOUD_TRACK
11
+ * - SOUNDCLOUD_PLAYLIST
12
+ * - SOUNDCLOUD
13
+ * - SPOTIFY_SONG
14
+ * - SPOTIFY_ALBUM
15
+ * - SPOTIFY_PLAYLIST
16
+ * - FACEBOOK
17
+ * - VIMEO
18
+ * - ARBITRARY
19
+ * - REVERBNATION
20
+ * - YOUTUBE_SEARCH
21
+ * - YOUTUBE_VIDEO
22
+ * - SOUNDCLOUD_SEARCH
23
+ * @typedef {number} QueryType
24
+ */
25
+ var QueryType;
26
+ (function (QueryType) {
27
+ QueryType[QueryType["AUTO"] = 0] = "AUTO";
28
+ QueryType[QueryType["YOUTUBE"] = 1] = "YOUTUBE";
29
+ QueryType[QueryType["YOUTUBE_PLAYLIST"] = 2] = "YOUTUBE_PLAYLIST";
30
+ QueryType[QueryType["SOUNDCLOUD_TRACK"] = 3] = "SOUNDCLOUD_TRACK";
31
+ QueryType[QueryType["SOUNDCLOUD_PLAYLIST"] = 4] = "SOUNDCLOUD_PLAYLIST";
32
+ QueryType[QueryType["SOUNDCLOUD"] = 5] = "SOUNDCLOUD";
33
+ QueryType[QueryType["SPOTIFY_SONG"] = 6] = "SPOTIFY_SONG";
34
+ QueryType[QueryType["SPOTIFY_ALBUM"] = 7] = "SPOTIFY_ALBUM";
35
+ QueryType[QueryType["SPOTIFY_PLAYLIST"] = 8] = "SPOTIFY_PLAYLIST";
36
+ QueryType[QueryType["FACEBOOK"] = 9] = "FACEBOOK";
37
+ QueryType[QueryType["VIMEO"] = 10] = "VIMEO";
38
+ QueryType[QueryType["ARBITRARY"] = 11] = "ARBITRARY";
39
+ QueryType[QueryType["REVERBNATION"] = 12] = "REVERBNATION";
40
+ QueryType[QueryType["YOUTUBE_SEARCH"] = 13] = "YOUTUBE_SEARCH";
41
+ QueryType[QueryType["YOUTUBE_VIDEO"] = 14] = "YOUTUBE_VIDEO";
42
+ QueryType[QueryType["SOUNDCLOUD_SEARCH"] = 15] = "SOUNDCLOUD_SEARCH";
43
+ })(QueryType = exports.QueryType || (exports.QueryType = {}));
44
+ /**
45
+ * The queue repeat mode. This can be one of:
46
+ * - OFF
47
+ * - TRACK
48
+ * - QUEUE
49
+ * - AUTOPLAY
50
+ * @typedef {number} QueueRepeatMode
51
+ */
52
+ var QueueRepeatMode;
53
+ (function (QueueRepeatMode) {
54
+ QueueRepeatMode[QueueRepeatMode["OFF"] = 0] = "OFF";
55
+ QueueRepeatMode[QueueRepeatMode["TRACK"] = 1] = "TRACK";
56
+ QueueRepeatMode[QueueRepeatMode["QUEUE"] = 2] = "QUEUE";
57
+ QueueRepeatMode[QueueRepeatMode["AUTOPLAY"] = 3] = "AUTOPLAY";
58
+ })(QueueRepeatMode = exports.QueueRepeatMode || (exports.QueueRepeatMode = {}));
@@ -1,109 +1,97 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AudioFilters = void 0;
4
- const bass = (g) => `bass=g=${g}:f=110:w=0.3`;
5
- /**
6
- * The available audio filters
7
- * @typedef {object} AudioFilters
8
- * @property {string} bassboost_low The bassboost filter (+15dB)
9
- * @property {string} bassboost The bassboost filter (+20dB)
10
- * @property {string} bassboost_high The bassboost filter (+30dB)
11
- * @property {string} 8D The 8D filter
12
- * @property {string} vaporwave The vaporwave filter
13
- * @property {string} nightcore The nightcore filter
14
- * @property {string} phaser The phaser filter
15
- * @property {string} tremolo The tremolo filter
16
- * @property {string} vibrato The vibrato filter
17
- * @property {string} reverse The reverse filter
18
- * @property {string} treble The treble filter
19
- * @property {string} normalizer The normalizer filter (dynamic audio normalizer based)
20
- * @property {string} normalizer2 The normalizer filter (audio compressor based)
21
- * @property {string} surrounding The surrounding filter
22
- * @property {string} pulsator The pulsator filter
23
- * @property {string} subboost The subboost filter
24
- * @property {string} karaoke The kakaoke filter
25
- * @property {string} flanger The flanger filter
26
- * @property {string} gate The gate filter
27
- * @property {string} haas The haas filter
28
- * @property {string} mcompand The mcompand filter
29
- * @property {string} mono The mono filter
30
- * @property {string} mstlr The mstlr filter
31
- * @property {string} mstrr The mstrr filter
32
- * @property {string} compressor The compressor filter
33
- * @property {string} expander The expander filter
34
- * @property {string} softlimiter The softlimiter filter
35
- * @property {string} chorus The chorus filter
36
- * @property {string} chorus2d The chorus2d filter
37
- * @property {string} chorus3d The chorus3d filter
38
- * @property {string} fadein The fadein filter
39
- * @property {string} dim The dim filter
40
- * @property {string} earrape The earrape filter
41
- */
42
- const FilterList = {
43
- bassboost_low: bass(15),
44
- bassboost: bass(20),
45
- bassboost_high: bass(30),
46
- "8D": "apulsator=hz=0.09",
47
- vaporwave: "aresample=48000,asetrate=48000*0.8",
48
- nightcore: "aresample=48000,asetrate=48000*1.25",
49
- phaser: "aphaser=in_gain=0.4",
50
- tremolo: "tremolo",
51
- vibrato: "vibrato=f=6.5",
52
- reverse: "areverse",
53
- treble: "treble=g=5",
54
- normalizer2: "dynaudnorm=g=101",
55
- normalizer: "acompressor",
56
- surrounding: "surround",
57
- pulsator: "apulsator=hz=1",
58
- subboost: "asubboost",
59
- karaoke: "stereotools=mlev=0.03",
60
- flanger: "flanger",
61
- gate: "agate",
62
- haas: "haas",
63
- mcompand: "mcompand",
64
- mono: "pan=mono|c0=.5*c0+.5*c1",
65
- mstlr: "stereotools=mode=ms>lr",
66
- mstrr: "stereotools=mode=ms>rr",
67
- compressor: "compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6",
68
- expander: "compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3",
69
- softlimiter: "compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8",
70
- chorus: "chorus=0.7:0.9:55:0.4:0.25:2",
71
- chorus2d: "chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3",
72
- chorus3d: "chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3",
73
- fadein: "afade=t=in:ss=0:d=10",
74
- dim: `afftfilt="'real=re * (1-clip((b/nb)*b,0,1))':imag='im * (1-clip((b/nb)*b,0,1))'"`,
75
- earrape: "channelsplit,sidechaingate=level_in=64",
76
- *[Symbol.iterator]() {
77
- for (const [k, v] of Object.entries(this)) {
78
- if (typeof this[k] === "string")
79
- yield { name: k, value: v };
80
- }
81
- },
82
- get names() {
83
- return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this[p] !== "function");
84
- },
85
- get length() {
86
- return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this[p] !== "function").length;
87
- },
88
- toString() {
89
- return this.names.map((m) => this[m]).join(","); // eslint-disable-line @typescript-eslint/no-explicit-any
90
- },
91
- create(filter) {
92
- if (!filter || !Array.isArray(filter))
93
- return this.toString();
94
- return filter
95
- .filter((predicate) => typeof predicate === "string")
96
- .map((m) => this[m])
97
- .join(",");
98
- },
99
- define(filterName, value) {
100
- if (typeof this[filterName] && typeof this[filterName] === "function")
101
- return;
102
- this[filterName] = value;
103
- },
104
- defineBulk(filterArray) {
105
- filterArray.forEach((arr) => this.define(arr.name, arr.value));
106
- }
107
- };
108
- exports.AudioFilters = FilterList;
109
- exports.default = FilterList;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AudioFilters = void 0;
4
+ const bass = (g) => `bass=g=${g}:f=110:w=0.3`;
5
+ class AudioFilters {
6
+ constructor() {
7
+ return AudioFilters;
8
+ }
9
+ static get filters() {
10
+ return {
11
+ bassboost_low: bass(15),
12
+ bassboost: bass(20),
13
+ bassboost_high: bass(30),
14
+ "8D": "apulsator=hz=0.09",
15
+ vaporwave: "aresample=48000,asetrate=48000*0.8",
16
+ nightcore: "aresample=48000,asetrate=48000*1.25",
17
+ phaser: "aphaser=in_gain=0.4",
18
+ tremolo: "tremolo",
19
+ vibrato: "vibrato=f=6.5",
20
+ reverse: "areverse",
21
+ treble: "treble=g=5",
22
+ normalizer2: "dynaudnorm=g=101",
23
+ normalizer: "acompressor",
24
+ surrounding: "surround",
25
+ pulsator: "apulsator=hz=1",
26
+ subboost: "asubboost",
27
+ karaoke: "stereotools=mlev=0.03",
28
+ flanger: "flanger",
29
+ gate: "agate",
30
+ haas: "haas",
31
+ mcompand: "mcompand",
32
+ mono: "pan=mono|c0=.5*c0+.5*c1",
33
+ mstlr: "stereotools=mode=ms>lr",
34
+ mstrr: "stereotools=mode=ms>rr",
35
+ compressor: "compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6",
36
+ expander: "compand=attacks=0:points=-80/-169|-54/-80|-49.5/-64.6|-41.1/-41.1|-25.8/-15|-10.8/-4.5|0/0|20/8.3",
37
+ softlimiter: "compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8",
38
+ chorus: "chorus=0.7:0.9:55:0.4:0.25:2",
39
+ chorus2d: "chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3",
40
+ chorus3d: "chorus=0.5:0.9:50|60|40:0.4|0.32|0.3:0.25|0.4|0.3:2|2.3|1.3",
41
+ fadein: "afade=t=in:ss=0:d=10",
42
+ dim: `afftfilt="'real=re * (1-clip((b/nb)*b,0,1))':imag='im * (1-clip((b/nb)*b,0,1))'"`,
43
+ earrape: "channelsplit,sidechaingate=level_in=64"
44
+ };
45
+ }
46
+ static get(name) {
47
+ return this.filters[name];
48
+ }
49
+ static has(name) {
50
+ return name in this.filters;
51
+ }
52
+ static *[Symbol.iterator]() {
53
+ for (const [k, v] of Object.entries(this.filters)) {
54
+ yield { name: k, value: v };
55
+ }
56
+ }
57
+ static get names() {
58
+ return Object.keys(this.filters);
59
+ }
60
+ // @ts-expect-error AudioFilters.length
61
+ static get length() {
62
+ return this.names.length;
63
+ }
64
+ static toString() {
65
+ return this.names.map((m) => this[m]).join(","); // eslint-disable-line @typescript-eslint/no-explicit-any
66
+ }
67
+ /**
68
+ * Create ffmpeg args from the specified filters name
69
+ * @param filter The filter name
70
+ * @returns
71
+ */
72
+ static create(filters) {
73
+ if (!filters || !Array.isArray(filters))
74
+ return this.toString();
75
+ return filters
76
+ .filter((predicate) => typeof predicate === "string")
77
+ .map((m) => this.get(m))
78
+ .join(",");
79
+ }
80
+ /**
81
+ * Defines audio filter
82
+ * @param filterName The name of the filter
83
+ * @param value The ffmpeg args
84
+ */
85
+ static define(filterName, value) {
86
+ this.filters[filterName] = value;
87
+ }
88
+ /**
89
+ * Defines multiple audio filters
90
+ * @param filtersArray Array of filters containing the filter name and ffmpeg args
91
+ */
92
+ static defineBulk(filtersArray) {
93
+ filtersArray.forEach((arr) => this.define(arr.name, arr.value));
94
+ }
95
+ }
96
+ exports.AudioFilters = AudioFilters;
97
+ exports.default = AudioFilters;
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createFFmpegStream = exports.FFMPEG_ARGS_PIPED = exports.FFMPEG_ARGS_STRING = void 0;
4
+ const prism_media_1 = require("prism-media");
5
+ function FFMPEG_ARGS_STRING(stream, fmt) {
6
+ // prettier-ignore
7
+ return [
8
+ "-reconnect", "1",
9
+ "-reconnect_streamed", "1",
10
+ "-reconnect_delay_max", "5",
11
+ "-i", stream,
12
+ "-analyzeduration", "0",
13
+ "-loglevel", "0",
14
+ "-f", `${typeof fmt === "string" ? fmt : "s16le"}`,
15
+ "-ar", "48000",
16
+ "-ac", "2"
17
+ ];
18
+ }
19
+ exports.FFMPEG_ARGS_STRING = FFMPEG_ARGS_STRING;
20
+ function FFMPEG_ARGS_PIPED(fmt) {
21
+ // prettier-ignore
22
+ return [
23
+ "-analyzeduration", "0",
24
+ "-loglevel", "0",
25
+ "-f", `${typeof fmt === "string" ? fmt : "s16le"}`,
26
+ "-ar", "48000",
27
+ "-ac", "2"
28
+ ];
29
+ }
30
+ exports.FFMPEG_ARGS_PIPED = FFMPEG_ARGS_PIPED;
31
+ /**
32
+ * Creates FFmpeg stream
33
+ * @param stream The source stream
34
+ * @param options FFmpeg stream options
35
+ */
36
+ function createFFmpegStream(stream, options) {
37
+ if (options.skip && typeof stream !== "string")
38
+ return stream;
39
+ options ?? (options = {});
40
+ const args = typeof stream === "string" ? FFMPEG_ARGS_STRING(stream, options.fmt) : FFMPEG_ARGS_PIPED(options.fmt);
41
+ if (!Number.isNaN(options.seek))
42
+ args.unshift("-ss", String(options.seek));
43
+ if (Array.isArray(options.encoderArgs))
44
+ args.push(...options.encoderArgs);
45
+ const transcoder = new prism_media_1.FFmpeg({ shell: false, args });
46
+ transcoder.on("close", () => transcoder.destroy());
47
+ if (typeof stream !== "string") {
48
+ stream.on("error", () => transcoder.destroy());
49
+ stream.pipe(transcoder);
50
+ }
51
+ return transcoder;
52
+ }
53
+ exports.createFFmpegStream = createFFmpegStream;
@@ -1,68 +1,68 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueryResolver = void 0;
4
- const ytdl_core_1 = require("ytdl-core");
5
- const youtube_sr_1 = require("youtube-sr");
6
- const types_1 = require("../types/types");
7
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
- // @ts-ignore
9
- const soundcloud_scraper_1 = require("soundcloud-scraper");
10
- // scary things below *sigh*
11
- const spotifySongRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:track\/|\?uri=spotify:track:)((\w|-){22})/;
12
- const spotifyPlaylistRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:playlist\/|\?uri=spotify:playlist:)((\w|-){22})/;
13
- const spotifyAlbumRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:album\/|\?uri=spotify:album:)((\w|-){22})/;
14
- const vimeoRegex = /(http|https)?:\/\/(www\.|player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)/;
15
- const facebookRegex = /(https?:\/\/)(www\.|m\.)?(facebook|fb).com\/.*\/videos\/.*/;
16
- const reverbnationRegex = /https:\/\/(www.)?reverbnation.com\/(.+)\/song\/(.+)/;
17
- const attachmentRegex = /^(?:(?:https?|ftp):\/\/)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/;
18
- // scary things above *sigh*
19
- class QueryResolver {
20
- /**
21
- * Query resolver
22
- */
23
- constructor() { } // eslint-disable-line @typescript-eslint/no-empty-function
24
- /**
25
- * Resolves the given search query
26
- * @param {string} query The query
27
- * @returns {QueryType}
28
- */
29
- static resolve(query) {
30
- if ((0, soundcloud_scraper_1.validateURL)(query, "track"))
31
- return types_1.QueryType.SOUNDCLOUD_TRACK;
32
- if ((0, soundcloud_scraper_1.validateURL)(query, "playlist") || query.includes("/sets/"))
33
- return types_1.QueryType.SOUNDCLOUD_PLAYLIST;
34
- if (youtube_sr_1.YouTube.isPlaylist(query))
35
- return types_1.QueryType.YOUTUBE_PLAYLIST;
36
- if ((0, ytdl_core_1.validateID)(query) || (0, ytdl_core_1.validateURL)(query))
37
- return types_1.QueryType.YOUTUBE_VIDEO;
38
- if (spotifySongRegex.test(query))
39
- return types_1.QueryType.SPOTIFY_SONG;
40
- if (spotifyPlaylistRegex.test(query))
41
- return types_1.QueryType.SPOTIFY_PLAYLIST;
42
- if (spotifyAlbumRegex.test(query))
43
- return types_1.QueryType.SPOTIFY_ALBUM;
44
- if (vimeoRegex.test(query))
45
- return types_1.QueryType.VIMEO;
46
- if (facebookRegex.test(query))
47
- return types_1.QueryType.FACEBOOK;
48
- if (reverbnationRegex.test(query))
49
- return types_1.QueryType.REVERBNATION;
50
- if (attachmentRegex.test(query))
51
- return types_1.QueryType.ARBITRARY;
52
- return types_1.QueryType.YOUTUBE_SEARCH;
53
- }
54
- /**
55
- * Parses vimeo id from url
56
- * @param {string} query The query
57
- * @returns {string}
58
- */
59
- static getVimeoID(query) {
60
- return QueryResolver.resolve(query) === types_1.QueryType.VIMEO
61
- ? query
62
- .split("/")
63
- .filter((x) => !!x)
64
- .pop()
65
- : null;
66
- }
67
- }
68
- exports.QueryResolver = QueryResolver;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.QueryResolver = void 0;
4
+ const ytdl_core_1 = require("ytdl-core");
5
+ const youtube_sr_1 = require("youtube-sr");
6
+ const types_1 = require("../types/types");
7
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
+ // @ts-ignore
9
+ const soundcloud_scraper_1 = require("soundcloud-scraper");
10
+ // scary things below *sigh*
11
+ const spotifySongRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:track\/|\?uri=spotify:track:)((\w|-){22})/;
12
+ const spotifyPlaylistRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:playlist\/|\?uri=spotify:playlist:)((\w|-){22})/;
13
+ const spotifyAlbumRegex = /https?:\/\/(?:embed\.|open\.)(?:spotify\.com\/)(?:album\/|\?uri=spotify:album:)((\w|-){22})/;
14
+ const vimeoRegex = /(http|https)?:\/\/(www\.|player\.)?vimeo\.com\/(?:channels\/(?:\w+\/)?|groups\/([^/]*)\/videos\/|video\/|)(\d+)(?:|\/\?)/;
15
+ const facebookRegex = /(https?:\/\/)(www\.|m\.)?(facebook|fb).com\/.*\/videos\/.*/;
16
+ const reverbnationRegex = /https:\/\/(www.)?reverbnation.com\/(.+)\/song\/(.+)/;
17
+ const attachmentRegex = /^(?:(?:https?|ftp):\/\/)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:\/\S*)?$/;
18
+ // scary things above *sigh*
19
+ class QueryResolver {
20
+ /**
21
+ * Query resolver
22
+ */
23
+ constructor() { } // eslint-disable-line @typescript-eslint/no-empty-function
24
+ /**
25
+ * Resolves the given search query
26
+ * @param {string} query The query
27
+ * @returns {QueryType}
28
+ */
29
+ static resolve(query) {
30
+ if ((0, soundcloud_scraper_1.validateURL)(query, "track"))
31
+ return types_1.QueryType.SOUNDCLOUD_TRACK;
32
+ if ((0, soundcloud_scraper_1.validateURL)(query, "playlist") || query.includes("/sets/"))
33
+ return types_1.QueryType.SOUNDCLOUD_PLAYLIST;
34
+ if (youtube_sr_1.YouTube.isPlaylist(query))
35
+ return types_1.QueryType.YOUTUBE_PLAYLIST;
36
+ if ((0, ytdl_core_1.validateID)(query) || (0, ytdl_core_1.validateURL)(query))
37
+ return types_1.QueryType.YOUTUBE_VIDEO;
38
+ if (spotifySongRegex.test(query))
39
+ return types_1.QueryType.SPOTIFY_SONG;
40
+ if (spotifyPlaylistRegex.test(query))
41
+ return types_1.QueryType.SPOTIFY_PLAYLIST;
42
+ if (spotifyAlbumRegex.test(query))
43
+ return types_1.QueryType.SPOTIFY_ALBUM;
44
+ if (vimeoRegex.test(query))
45
+ return types_1.QueryType.VIMEO;
46
+ if (facebookRegex.test(query))
47
+ return types_1.QueryType.FACEBOOK;
48
+ if (reverbnationRegex.test(query))
49
+ return types_1.QueryType.REVERBNATION;
50
+ if (attachmentRegex.test(query))
51
+ return types_1.QueryType.ARBITRARY;
52
+ return types_1.QueryType.YOUTUBE_SEARCH;
53
+ }
54
+ /**
55
+ * Parses vimeo id from url
56
+ * @param {string} query The query
57
+ * @returns {string}
58
+ */
59
+ static getVimeoID(query) {
60
+ return QueryResolver.resolve(query) === types_1.QueryType.VIMEO
61
+ ? query
62
+ .split("/")
63
+ .filter((x) => !!x)
64
+ .pop()
65
+ : null;
66
+ }
67
+ }
68
+ exports.QueryResolver = QueryResolver;