Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
forward more events
Browse files Browse the repository at this point in the history
  • Loading branch information
Snowflake107 committed Oct 28, 2020
1 parent adda605 commit 724a9e6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import ytdl, { downloadOptions } from "ytdl-core";
import { opus as Opus, FFmpeg } from "prism-media";
import { Readable, Duplex } from "stream";

const evn = ["info", "progress"];
// ytdl events
const evn = ["info", "progress", "abort", "request", "response", "error", "redirect", "retry", "reconnect"];

interface YTDLStreamOptions extends downloadOptions {
seek?: number;
Expand Down Expand Up @@ -66,7 +67,7 @@ const StreamDownloader = (url: string, options: YTDLStreamOptions) => {
for (const event of evn) {
inputStream.on(event, (...args) => output.emit(event, ...args));
}
inputStream.on("error", (e) => output.destroy(e));
inputStream.on("error", () => transcoder.destroy());
output.on("close", () => transcoder.destroy());
return output;
};
Expand All @@ -83,11 +84,6 @@ const StreamDownloader = (url: string, options: YTDLStreamOptions) => {
inputStream.on(event, (...args) => outputStream.emit(event, ...args));
}

inputStream.on("error", (e) => {
transcoder.destroy(e);
opus.destroy(e);
});

outputStream.on("close", () => {
transcoder.destroy();
opus.destroy();
Expand Down Expand Up @@ -148,7 +144,7 @@ const arbitraryStream = (stream: string | Readable | Duplex, options: StreamOpti
});
if (typeof stream !== "string") {
transcoder = stream.pipe(transcoder);
stream.on("error", (e) => transcoder.destroy(e));
stream.on("error", () => transcoder.destroy());
}
if (options && !options.opusEncoded) {
transcoder.on("close", () => transcoder.destroy());
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "discord-ytdl-core",
"version": "4.1.1",
"version": "4.1.2",
"description": "Simple ytdl wrapper for discord bots with custom ffmpeg args support.",
"main": "index.js",
"types": "index.d.ts",
Expand Down

0 comments on commit 724a9e6

Please sign in to comment.