discord-ytdl-core
Advanced tools
Comparing version 3.0.0 to 3.0.1
import ytdl, { downloadOptions } from "ytdl-core"; | ||
import prism from "prism-media"; | ||
interface CreateOpusStreamOptions extends downloadOptions { | ||
interface StreamOptions extends downloadOptions { | ||
seek?: number; | ||
encoderArgs?: any[]; | ||
} | ||
declare const DiscordYTDLCore: ((url: string, options: CreateOpusStreamOptions) => prism.opus.Encoder) & typeof ytdl; | ||
declare const DiscordYTDLCore: ((url: string, options: StreamOptions) => prism.opus.Encoder) & typeof ytdl; | ||
export = DiscordYTDLCore; |
25
index.js
@@ -9,7 +9,18 @@ "use strict"; | ||
/** | ||
* Create an opus stream for your video with provided encoder args | ||
* @param url - YouTube URL of the video | ||
* @param options - YTDL options | ||
*/ | ||
const createOpusStream = (url, options) => { | ||
* Create an opus stream for your video with provided encoder args | ||
* @param url - YouTube URL of the video | ||
* @param options - YTDL options | ||
* @param [options.seek] seek - Time in seconds to seek | ||
* @param [options.encoderArgs] encoderArgs - FFmpeg encoder args | ||
* @returns {Stream} | ||
* @example const ytdl = require("discord-ytdl-core"); | ||
* const stream = ytdl("VIDEO_URL", { | ||
* seek: 3, | ||
* encoderArgs: ["-af", "bass=g=20,dynaudnorm=f=200"] | ||
* }); | ||
* VoiceConnection.play(stream, { | ||
* type: "opus" | ||
* }); | ||
*/ | ||
const OpusStream = (url, options) => { | ||
if (!url) { | ||
@@ -19,3 +30,3 @@ throw new Error("No input url provided"); | ||
if (typeof url !== "string") { | ||
throw new SyntaxError("input URL must be a string"); | ||
throw new SyntaxError(`input URL must be a string. Received ${typeof url}!`); | ||
} | ||
@@ -52,3 +63,3 @@ let FFmpegArgs = [ | ||
}; | ||
const DiscordYTDLCore = Object.assign(createOpusStream, ytdl_core_1.default); | ||
const DiscordYTDLCore = Object.assign(OpusStream, ytdl_core_1.default); | ||
module.exports = DiscordYTDLCore; |
27
index.ts
import ytdl, { downloadOptions } from "ytdl-core"; | ||
import prism from "prism-media"; | ||
interface CreateOpusStreamOptions extends downloadOptions { | ||
interface StreamOptions extends downloadOptions { | ||
seek?: number; | ||
@@ -10,7 +10,18 @@ encoderArgs?: any[]; | ||
/** | ||
* Create an opus stream for your video with provided encoder args | ||
* @param url - YouTube URL of the video | ||
* @param options - YTDL options | ||
*/ | ||
const createOpusStream = (url: string, options: CreateOpusStreamOptions) => { | ||
* Create an opus stream for your video with provided encoder args | ||
* @param url - YouTube URL of the video | ||
* @param options - YTDL options | ||
* @param [options.seek] seek - Time in seconds to seek | ||
* @param [options.encoderArgs] encoderArgs - FFmpeg encoder args | ||
* @returns {Stream} | ||
* @example const ytdl = require("discord-ytdl-core"); | ||
* const stream = ytdl("VIDEO_URL", { | ||
* seek: 3, | ||
* encoderArgs: ["-af", "bass=g=20,dynaudnorm=f=200"] | ||
* }); | ||
* VoiceConnection.play(stream, { | ||
* type: "opus" | ||
* }); | ||
*/ | ||
const OpusStream = (url: string, options: StreamOptions) => { | ||
if (!url) { | ||
@@ -20,3 +31,3 @@ throw new Error("No input url provided"); | ||
if (typeof url !== "string") { | ||
throw new SyntaxError("input URL must be a string"); | ||
throw new SyntaxError(`input URL must be a string. Received ${typeof url}!`); | ||
} | ||
@@ -62,5 +73,5 @@ | ||
const DiscordYTDLCore = Object.assign(createOpusStream, ytdl); | ||
const DiscordYTDLCore = Object.assign(OpusStream, ytdl); | ||
export = DiscordYTDLCore; | ||
{ | ||
"name": "discord-ytdl-core", | ||
"version": "3.0.0", | ||
"version": "3.0.1", | ||
"description": "Simple ytdl wrapper for discord bots with custom ffmpeg args support.", | ||
@@ -45,3 +45,3 @@ "main": "index.js", | ||
"prism-media": "^1.2.2", | ||
"ytdl-core": "^2.1.5" | ||
"ytdl-core": "^3.1.1" | ||
}, | ||
@@ -52,4 +52,3 @@ "devDependencies": { | ||
"ffmpeg-static": "^4.0.1" | ||
}, | ||
"runkitExampleFilename": "example.js" | ||
} | ||
} |
@@ -17,5 +17,5 @@ # [discord-ytdl-core](https://discord-ytdl-core.netlify.app "Documentation") | ||
## **Supported Opus Engines:** | ||
- **[@discordjs/opus](https://npmjs.com/package/@discordjs/opus)** - Best performance | ||
- **[node-opus](https://npmjs.com/package/node-opus)** - Deprecated | ||
## **Supported Opus Engines** | ||
- **[@discordjs/opus](https://npmjs.com/package/@discordjs/opus)** | ||
- **[node-opus](https://npmjs.com/package/node-opus)** | ||
- **[opusscript](https://npmjs.com/package/opusscript)** | ||
@@ -50,7 +50,7 @@ | ||
if (msg.author.bot || !msg.guild) return; | ||
if (msg.content === "??play") { | ||
if (msg.content === "!play") { | ||
if (!msg.member.voice.channel) return msg.channel.send("You're not in a voice channel?"); | ||
let stream = ytdl("https://youtube.com/watch?v=ERu6jh_1gR0", { | ||
filter: "audioonly", | ||
encoderArgs: ['-af', 'equalizer=f=40:width_type=h:width=50:g=10'] // FFmpeg args array (optional) | ||
encoderArgs: ['-af', 'bass=g=10,dynaudnorm=f=200'] // Sets Bass Boost | ||
}); | ||
@@ -73,10 +73,4 @@ | ||
# Example Bots | ||
- **[P74Y](https://github.com/Snowflake107/P74Y)** | ||
> **If you have a bot which uses this package, create a Pull Request.** | ||
# Other functions | ||
This package can do all the functions of normal **[ytdl-core](https://npmjs.com/package/ytdl-core)**. | ||
Visit **[ytdl-core](https://npmjs.com/package/ytdl-core)** for other functions. | ||
@@ -83,0 +77,0 @@ # Related |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
20348
131
86
1
+ Addedminiget@2.1.0(transitive)
+ Addedytdl-core@3.4.2(transitive)
- Removedytdl-core@2.1.7(transitive)
Updatedytdl-core@^3.1.1