Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

discord-player

Package Overview
Dependencies
Maintainers
2
Versions
359
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

discord-player - npm Package Compare versions

Comparing version 5.3.0-dev.2 to 5.3.0-dev.3

dist/utils/FFmpegStream.js

123

dist/index.d.ts

@@ -1005,87 +1005,35 @@ /// <reference types="node" />

/**
* The available audio filters
* @typedef {object} AudioFilters
* @property {string} bassboost_low The bassboost filter (+15dB)
* @property {string} bassboost The bassboost filter (+20dB)
* @property {string} bassboost_high The bassboost filter (+30dB)
* @property {string} 8D The 8D filter
* @property {string} vaporwave The vaporwave filter
* @property {string} nightcore The nightcore filter
* @property {string} phaser The phaser filter
* @property {string} tremolo The tremolo filter
* @property {string} vibrato The vibrato filter
* @property {string} reverse The reverse filter
* @property {string} treble The treble filter
* @property {string} normalizer The normalizer filter (dynamic audio normalizer based)
* @property {string} normalizer2 The normalizer filter (audio compressor based)
* @property {string} surrounding The surrounding filter
* @property {string} pulsator The pulsator filter
* @property {string} subboost The subboost filter
* @property {string} karaoke The kakaoke filter
* @property {string} flanger The flanger filter
* @property {string} gate The gate filter
* @property {string} haas The haas filter
* @property {string} mcompand The mcompand filter
* @property {string} mono The mono filter
* @property {string} mstlr The mstlr filter
* @property {string} mstrr The mstrr filter
* @property {string} compressor The compressor filter
* @property {string} expander The expander filter
* @property {string} softlimiter The softlimiter filter
* @property {string} chorus The chorus filter
* @property {string} chorus2d The chorus2d filter
* @property {string} chorus3d The chorus3d filter
* @property {string} fadein The fadein filter
* @property {string} dim The dim filter
* @property {string} earrape The earrape filter
*/
declare const FilterList: {
bassboost_low: string;
bassboost: string;
bassboost_high: string;
"8D": string;
vaporwave: string;
nightcore: string;
phaser: string;
tremolo: string;
vibrato: string;
reverse: string;
treble: string;
normalizer2: string;
normalizer: string;
surrounding: string;
pulsator: string;
subboost: string;
karaoke: string;
flanger: string;
gate: string;
haas: string;
mcompand: string;
mono: string;
mstlr: string;
mstrr: string;
compressor: string;
expander: string;
softlimiter: string;
chorus: string;
chorus2d: string;
chorus3d: string;
fadein: string;
dim: string;
earrape: string;
[Symbol.iterator](): IterableIterator<{
declare class AudioFilters {
constructor();
static get filters(): Record<FiltersName, string>;
static get<K extends FiltersName>(name: K): Record<keyof QueueFilters, string>[K];
static has<K extends FiltersName>(name: K): boolean;
static [Symbol.iterator](): IterableIterator<{
name: FiltersName;
value: string;
}>;
readonly names: (keyof QueueFilters)[];
readonly length: number;
toString(): string;
create(filter?: FiltersName[]): string;
define(filterName: string, value: string): void;
defineBulk(filterArray: {
static get names(): (keyof QueueFilters)[];
static get length(): number;
static toString(): string;
/**
* Create ffmpeg args from the specified filters name
* @param filter The filter name
* @returns
*/
static create(filters?: FiltersName[]): string;
/**
* Defines audio filter
* @param filterName The name of the filter
* @param value The ffmpeg args
*/
static define(filterName: string, value: string): void;
/**
* Defines multiple audio filters
* @param filtersArray Array of filters containing the filter name and ffmpeg args
*/
static defineBulk(filtersArray: {
name: string;
value: string;
}[]): void;
};
}

@@ -1194,4 +1142,19 @@ declare enum ErrorStatusCode {

interface FFmpegStreamOptions {
fmt?: string;
encoderArgs?: string[];
seek?: number;
skip?: boolean;
}
declare function FFMPEG_ARGS_STRING(stream: string, fmt?: string): string[];
declare function FFMPEG_ARGS_PIPED(fmt?: string): string[];
/**
* Creates FFmpeg stream
* @param stream The source stream
* @param options FFmpeg stream options
*/
declare function createFFmpegStream(stream: Readable | Duplex | string, options?: FFmpegStreamOptions): Readable | Duplex;
declare const version: string;
export { FilterList as AudioFilters, ErrorStatusCode, ExtractorModel, ExtractorModelData, FiltersName, PlayOptions, Player, PlayerError, PlayerEvents, PlayerInitOptions, PlayerOptions, PlayerProgressbarOptions, PlayerSearchResult, Playlist, PlaylistInitData, PlaylistJSON, QueryResolver, QueryType, Queue, QueueFilters, QueueRepeatMode, RawTrackData, SearchOptions, StreamDispatcher, TimeData, Track, TrackJSON, TrackSource, Util, VoiceEvents, VoiceUtils, version };
export { AudioFilters, ErrorStatusCode, ExtractorModel, ExtractorModelData, FFMPEG_ARGS_PIPED, FFMPEG_ARGS_STRING, FFmpegStreamOptions, FiltersName, PlayOptions, Player, PlayerError, PlayerEvents, PlayerInitOptions, PlayerOptions, PlayerProgressbarOptions, PlayerSearchResult, Playlist, PlaylistInitData, PlaylistJSON, QueryResolver, QueryType, Queue, QueueFilters, QueueRepeatMode, RawTrackData, SearchOptions, StreamDispatcher, TimeData, Track, TrackJSON, TrackSource, Util, VoiceEvents, VoiceUtils, createFFmpegStream, version };

@@ -31,3 +31,4 @@ "use strict";

tslib_1.__exportStar(require("./types/types"), exports);
tslib_1.__exportStar(require("./utils/FFmpegStream"), exports);
// eslint-disable-next-line @typescript-eslint/no-var-requires
exports.version = require(`${__dirname}/../package.json`).version;

@@ -9,3 +9,3 @@ "use strict";

const types_1 = require("../types/types");
const discord_ytdl_core_1 = tslib_1.__importDefault(require("discord-ytdl-core"));
const ytdl_core_1 = tslib_1.__importDefault(require("ytdl-core"));
const voice_1 = require("@discordjs/voice");

@@ -16,2 +16,3 @@ const Util_1 = require("../utils/Util");

const PlayerError_1 = require("./PlayerError");
const FFmpegStream_1 = require("../utils/FFmpegStream");
class Queue {

@@ -630,3 +631,3 @@ /**

let stream = null;
const customDownloader = typeof this.onBeforeCreateStream === "function";
const hasCustomDownloader = typeof this.onBeforeCreateStream === "function";
if (["youtube", "spotify"].includes(track.raw.source)) {

@@ -636,57 +637,34 @@ let spotifyResolved = false;

track.raw.engine = await youtube_sr_1.default.search(`${track.author} ${track.title}`, { type: "video" })
.then((x) => x[0].url)
.then((res) => res[0].url)
.catch(() => null);
spotifyResolved = true;
}
const link = track.raw.source === "spotify" ? track.raw.engine : track.url;
if (!link)
const url = track.raw.source === "spotify" ? track.raw.engine : track.url;
if (!url)
return void this.play(this.tracks.shift(), { immediate: true });
if (customDownloader) {
stream = (await this.onBeforeCreateStream(track, spotifyResolved ? "youtube" : track.raw.source, this)) ?? null;
if (stream)
stream = discord_ytdl_core_1.default
.arbitraryStream(stream, {
opusEncoded: false,
fmt: "s16le",
encoderArgs: options.encoderArgs ?? this._activeFilters.length ? ["-af", AudioFilters_1.default.create(this._activeFilters)] : [],
seek: options.seek ? options.seek / 1000 : 0
})
.on("error", (err) => {
return err.message.toLowerCase().includes("premature close") ? null : this.player.emit("error", this, err);
});
if (hasCustomDownloader) {
stream = (await this.onBeforeCreateStream(track, spotifyResolved ? "youtube" : track.raw.source, this)) || null;
}
else {
stream = (0, discord_ytdl_core_1.default)(link, {
...this.options.ytdlOptions,
// discord-ytdl-core
opusEncoded: false,
fmt: "s16le",
encoderArgs: options.encoderArgs ?? this._activeFilters.length ? ["-af", AudioFilters_1.default.create(this._activeFilters)] : [],
seek: options.seek ? options.seek / 1000 : 0
}).on("error", (err) => {
return err.message.toLowerCase().includes("premature close") ? null : this.player.emit("error", this, err);
});
if (!stream) {
stream = (0, ytdl_core_1.default)(url, this.options.ytdlOptions);
}
}
else {
const tryArb = (customDownloader && (await this.onBeforeCreateStream(track, track.raw.source || track.raw.engine, this))) || null;
const arbitrarySource = tryArb
? tryArb
: track.raw.source === "soundcloud"
const arbitraryStream = (hasCustomDownloader && (await this.onBeforeCreateStream(track, track.raw.source || track.raw.engine, this))) || null;
stream =
arbitraryStream || track.raw.source === "soundcloud"
? await track.raw.engine.downloadProgressive()
: typeof track.raw.engine === "function"
? await track.raw.engine()
? await track.raw.engine
: track.raw.engine;
stream = discord_ytdl_core_1.default
.arbitraryStream(arbitrarySource, {
opusEncoded: false,
fmt: "s16le",
encoderArgs: options.encoderArgs ?? this._activeFilters.length ? ["-af", AudioFilters_1.default.create(this._activeFilters)] : [],
seek: options.seek ? options.seek / 1000 : 0
})
.on("error", (err) => {
return err.message.toLowerCase().includes("premature close") ? null : this.player.emit("error", this, err);
});
}
const resource = this.connection.createStream(stream, {
const ffmpegStream = (0, FFmpegStream_1.createFFmpegStream)(stream, {
encoderArgs: options.encoderArgs || this._activeFilters.length ? ["-af", AudioFilters_1.default.create(this._activeFilters)] : [],
seek: options.seek ? options.seek / 1000 : 0,
fmt: "s16le"
}).on("error", (err) => {
if (!`${err}`.toLowerCase().includes("premature close"))
this.player.emit("error", this, err);
});
const resource = this.connection.createStream(ffmpegStream, {
type: voice_1.StreamType.Raw,

@@ -693,0 +671,0 @@ data: track,

@@ -5,106 +5,95 @@ "use strict";

const bass = (g) => `bass=g=${g}:f=110:w=0.3`;
/**
* The available audio filters
* @typedef {object} AudioFilters
* @property {string} bassboost_low The bassboost filter (+15dB)
* @property {string} bassboost The bassboost filter (+20dB)
* @property {string} bassboost_high The bassboost filter (+30dB)
* @property {string} 8D The 8D filter
* @property {string} vaporwave The vaporwave filter
* @property {string} nightcore The nightcore filter
* @property {string} phaser The phaser filter
* @property {string} tremolo The tremolo filter
* @property {string} vibrato The vibrato filter
* @property {string} reverse The reverse filter
* @property {string} treble The treble filter
* @property {string} normalizer The normalizer filter (dynamic audio normalizer based)
* @property {string} normalizer2 The normalizer filter (audio compressor based)
* @property {string} surrounding The surrounding filter
* @property {string} pulsator The pulsator filter
* @property {string} subboost The subboost filter
* @property {string} karaoke The kakaoke filter
* @property {string} flanger The flanger filter
* @property {string} gate The gate filter
* @property {string} haas The haas filter
* @property {string} mcompand The mcompand filter
* @property {string} mono The mono filter
* @property {string} mstlr The mstlr filter
* @property {string} mstrr The mstrr filter
* @property {string} compressor The compressor filter
* @property {string} expander The expander filter
* @property {string} softlimiter The softlimiter filter
* @property {string} chorus The chorus filter
* @property {string} chorus2d The chorus2d filter
* @property {string} chorus3d The chorus3d filter
* @property {string} fadein The fadein filter
* @property {string} dim The dim filter
* @property {string} earrape The earrape filter
*/
const FilterList = {
bassboost_low: bass(15),
bassboost: bass(20),
bassboost_high: bass(30),
"8D": "apulsator=hz=0.09",
vaporwave: "aresample=48000,asetrate=48000*0.8",
nightcore: "aresample=48000,asetrate=48000*1.25",
phaser: "aphaser=in_gain=0.4",
tremolo: "tremolo",
vibrato: "vibrato=f=6.5",
reverse: "areverse",
treble: "treble=g=5",
normalizer2: "dynaudnorm=g=101",
normalizer: "acompressor",
surrounding: "surround",
pulsator: "apulsator=hz=1",
subboost: "asubboost",
karaoke: "stereotools=mlev=0.03",
flanger: "flanger",
gate: "agate",
haas: "haas",
mcompand: "mcompand",
mono: "pan=mono|c0=.5*c0+.5*c1",
mstlr: "stereotools=mode=ms>lr",
mstrr: "stereotools=mode=ms>rr",
compressor: "compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6",
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",
softlimiter: "compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8",
chorus: "chorus=0.7:0.9:55:0.4:0.25:2",
chorus2d: "chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3",
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",
fadein: "afade=t=in:ss=0:d=10",
dim: `afftfilt="'real=re * (1-clip((b/nb)*b,0,1))':imag='im * (1-clip((b/nb)*b,0,1))'"`,
earrape: "channelsplit,sidechaingate=level_in=64",
*[Symbol.iterator]() {
class AudioFilters {
constructor() {
return AudioFilters;
}
static get filters() {
return {
bassboost_low: bass(15),
bassboost: bass(20),
bassboost_high: bass(30),
"8D": "apulsator=hz=0.09",
vaporwave: "aresample=48000,asetrate=48000*0.8",
nightcore: "aresample=48000,asetrate=48000*1.25",
phaser: "aphaser=in_gain=0.4",
tremolo: "tremolo",
vibrato: "vibrato=f=6.5",
reverse: "areverse",
treble: "treble=g=5",
normalizer2: "dynaudnorm=g=101",
normalizer: "acompressor",
surrounding: "surround",
pulsator: "apulsator=hz=1",
subboost: "asubboost",
karaoke: "stereotools=mlev=0.03",
flanger: "flanger",
gate: "agate",
haas: "haas",
mcompand: "mcompand",
mono: "pan=mono|c0=.5*c0+.5*c1",
mstlr: "stereotools=mode=ms>lr",
mstrr: "stereotools=mode=ms>rr",
compressor: "compand=points=-80/-105|-62/-80|-15.4/-15.4|0/-12|20/-7.6",
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",
softlimiter: "compand=attacks=0:points=-80/-80|-12.4/-12.4|-6/-8|0/-6.8|20/-2.8",
chorus: "chorus=0.7:0.9:55:0.4:0.25:2",
chorus2d: "chorus=0.6:0.9:50|60:0.4|0.32:0.25|0.4:2|1.3",
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",
fadein: "afade=t=in:ss=0:d=10",
dim: `afftfilt="'real=re * (1-clip((b/nb)*b,0,1))':imag='im * (1-clip((b/nb)*b,0,1))'"`,
earrape: "channelsplit,sidechaingate=level_in=64"
};
}
static get(name) {
return this.filters[name];
}
static has(name) {
return name in this.filters;
}
static *[Symbol.iterator]() {
for (const [k, v] of Object.entries(this)) {
if (typeof this[k] === "string")
if (typeof this.filters[k] === "string")
yield { name: k, value: v };
}
},
get names() {
return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this[p] !== "function");
},
get length() {
return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this[p] !== "function").length;
},
toString() {
}
static get names() {
return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this.filters[p] !== "function");
}
// @ts-expect-error AudioFilters.length
static get length() {
return Object.keys(this).filter((p) => !["names", "length"].includes(p) && typeof this.filters[p] !== "function").length;
}
static toString() {
return this.names.map((m) => this[m]).join(","); // eslint-disable-line @typescript-eslint/no-explicit-any
},
create(filter) {
if (!filter || !Array.isArray(filter))
}
/**
* Create ffmpeg args from the specified filters name
* @param filter The filter name
* @returns
*/
static create(filters) {
if (!filters || !Array.isArray(filters))
return this.toString();
return filter
return filters
.filter((predicate) => typeof predicate === "string")
.map((m) => this[m])
.map((m) => this.get(m))
.join(",");
},
define(filterName, value) {
if (typeof this[filterName] && typeof this[filterName] === "function")
return;
this[filterName] = value;
},
defineBulk(filterArray) {
filterArray.forEach((arr) => this.define(arr.name, arr.value));
}
};
exports.AudioFilters = FilterList;
exports.default = FilterList;
/**
* Defines audio filter
* @param filterName The name of the filter
* @param value The ffmpeg args
*/
static define(filterName, value) {
this.filters[filterName] = value;
}
/**
* Defines multiple audio filters
* @param filtersArray Array of filters containing the filter name and ffmpeg args
*/
static defineBulk(filtersArray) {
filtersArray.forEach((arr) => this.define(arr.name, arr.value));
}
}
exports.AudioFilters = AudioFilters;
exports.default = AudioFilters;

@@ -120,3 +120,11 @@ "use strict";

catch {
// uh?
try {
// eslint-disable-next-line
const res = require(lib);
if (res)
return res.fetch || res.default?.fetch || res.default;
}
catch {
// no?
}
}

@@ -123,0 +131,0 @@ }

{
"name": "discord-player",
"version": "5.3.0-dev.2",
"version": "5.3.0-dev.3",
"description": "Complete framework to facilitate music commands using discord.js",

@@ -69,3 +69,2 @@ "main": "dist/index.js",

"@discordjs/voice": "^0.11.0",
"discord-ytdl-core": "^5.0.4",
"libsodium-wrappers": "^0.7.10",

@@ -72,0 +71,0 @@ "soundcloud-scraper": "^5.0.3",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc