discord-player 5.4.0 → 5.4.1-dev.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.
@@ -1,95 +0,0 @@
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(name) {
10
- return this.filters[name];
11
- }
12
- static has(name) {
13
- return name in this.filters;
14
- }
15
- static *[Symbol.iterator]() {
16
- for (const [k, v] of Object.entries(this.filters)) {
17
- yield { name: k, value: v };
18
- }
19
- }
20
- static get names() {
21
- return Object.keys(this.filters);
22
- }
23
- // @ts-expect-error AudioFilters.length
24
- static get length() {
25
- return this.names.length;
26
- }
27
- static toString() {
28
- return this.names.map((m) => this[m]).join(","); // eslint-disable-line @typescript-eslint/no-explicit-any
29
- }
30
- /**
31
- * Create ffmpeg args from the specified filters name
32
- * @param filter The filter name
33
- * @returns
34
- */
35
- static create(filters) {
36
- if (!filters || !Array.isArray(filters))
37
- return this.toString();
38
- return filters
39
- .filter((predicate) => typeof predicate === "string")
40
- .map((m) => this.get(m))
41
- .join(",");
42
- }
43
- /**
44
- * Defines audio filter
45
- * @param filterName The name of the filter
46
- * @param value The ffmpeg args
47
- */
48
- static define(filterName, value) {
49
- this.filters[filterName] = value;
50
- }
51
- /**
52
- * Defines multiple audio filters
53
- * @param filtersArray Array of filters containing the filter name and ffmpeg args
54
- */
55
- static defineBulk(filtersArray) {
56
- filtersArray.forEach((arr) => this.define(arr.name, arr.value));
57
- }
58
- }
59
- exports.AudioFilters = AudioFilters;
60
- AudioFilters.filters = {
61
- bassboost_low: bass(15),
62
- bassboost: bass(20),
63
- bassboost_high: bass(30),
64
- "8D": "apulsator=hz=0.09",
65
- vaporwave: "aresample=48000,asetrate=48000*0.8",
66
- nightcore: "aresample=48000,asetrate=48000*1.25",
67
- phaser: "aphaser=in_gain=0.4",
68
- tremolo: "tremolo",
69
- vibrato: "vibrato=f=6.5",
70
- reverse: "areverse",
71
- treble: "treble=g=5",
72
- normalizer2: "dynaudnorm=g=101",
73
- normalizer: "acompressor",
74
- surrounding: "surround",
75
- pulsator: "apulsator=hz=1",
76
- subboost: "asubboost",
77
- karaoke: "stereotools=mlev=0.03",
78
- flanger: "flanger",
79
- gate: "agate",
80
- haas: "haas",
81
- mcompand: "mcompand",
82
- mono: "pan=mono|c0=.5*c0+.5*c1",
83
- mstlr: "stereotools=mode=ms>lr",
84
- mstrr: "stereotools=mode=ms>rr",
85
- compressor: "compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6",
86
- 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",
87
- softlimiter: "compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8",
88
- chorus: "chorus=0.7:0.9:55:0.4:0.25:2",
89
- chorus2d: "chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3",
90
- 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",
91
- fadein: "afade=t=in:ss=0:d=10",
92
- dim: `afftfilt="'real=re * (1-clip((b/nb)*b,0,1))':imag='im * (1-clip((b/nb)*b,0,1))'"`,
93
- earrape: "channelsplit,sidechaingate=level_in=64"
94
- };
95
- exports.default = AudioFilters;
@@ -1,53 +0,0 @@
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 +0,0 @@
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
- // #region 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
- // #endregion 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,136 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.Util = void 0;
27
- const promises_1 = require("timers/promises");
28
- class Util {
29
- /**
30
- * Utils
31
- */
32
- constructor() { } // eslint-disable-line @typescript-eslint/no-empty-function
33
- /**
34
- * Creates duration string
35
- * @param {object} durObj The duration object
36
- * @returns {string}
37
- */
38
- static durationString(durObj) {
39
- return Object.values(durObj)
40
- .map((m) => (isNaN(m) ? 0 : m))
41
- .join(":");
42
- }
43
- /**
44
- * Parses milliseconds to consumable time object
45
- * @param {number} milliseconds The time in ms
46
- * @returns {TimeData}
47
- */
48
- static parseMS(milliseconds) {
49
- if (isNaN(milliseconds))
50
- milliseconds = 0;
51
- const round = milliseconds > 0 ? Math.floor : Math.ceil;
52
- return {
53
- days: round(milliseconds / 86400000),
54
- hours: round(milliseconds / 3600000) % 24,
55
- minutes: round(milliseconds / 60000) % 60,
56
- seconds: round(milliseconds / 1000) % 60
57
- };
58
- }
59
- /**
60
- * Builds time code
61
- * @param {TimeData} duration The duration object
62
- * @returns {string}
63
- */
64
- static buildTimeCode(duration) {
65
- const items = Object.keys(duration);
66
- const required = ["days", "hours", "minutes", "seconds"];
67
- const parsed = items.filter((x) => required.includes(x)).map((m) => duration[m]);
68
- const final = parsed
69
- .slice(parsed.findIndex((x) => x !== 0))
70
- .map((x) => x.toString().padStart(2, "0"))
71
- .join(":");
72
- return final.length <= 3 ? `0:${final.padStart(2, "0") || 0}` : final;
73
- }
74
- /**
75
- * Picks last item of the given array
76
- * @param {any[]} arr The array
77
- * @returns {any}
78
- */
79
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
80
- static last(arr) {
81
- if (!Array.isArray(arr))
82
- return;
83
- return arr[arr.length - 1];
84
- }
85
- /**
86
- * Checks if the voice channel is empty
87
- * @param {VoiceChannel|StageChannel} channel The voice channel
88
- * @returns {boolean}
89
- */
90
- static isVoiceEmpty(channel) {
91
- return channel.members.filter((member) => !member.user.bot).size === 0;
92
- }
93
- /**
94
- * Safer require
95
- * @param {string} id Node require id
96
- * @returns {any}
97
- */
98
- static require(id) {
99
- try {
100
- return require(id);
101
- }
102
- catch {
103
- return null;
104
- }
105
- }
106
- /**
107
- * Asynchronous timeout
108
- * @param {number} time The time in ms to wait
109
- * @returns {Promise<unknown>}
110
- */
111
- static wait(time) {
112
- return (0, promises_1.setTimeout)(time, undefined, { ref: false });
113
- }
114
- static noop() { } // eslint-disable-line @typescript-eslint/no-empty-function
115
- static async getFetch() {
116
- if ("fetch" in globalThis)
117
- return globalThis.fetch;
118
- for (const lib of ["node-fetch", "undici"]) {
119
- try {
120
- return await Promise.resolve().then(() => __importStar(require(lib))).then((res) => res.fetch || res.default?.fetch || res.default);
121
- }
122
- catch {
123
- try {
124
- // eslint-disable-next-line
125
- const res = require(lib);
126
- if (res)
127
- return res.fetch || res.default?.fetch || res.default;
128
- }
129
- catch {
130
- // no?
131
- }
132
- }
133
- }
134
- }
135
- }
136
- exports.Util = Util;