Skip to content

Commit 4bb7c0f

Browse files
committed
fix(song.ts): changing youtube-sr to ytdl-core in Song.ts makeResource()
fix #1644
1 parent d785326 commit 4bb7c0f

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

package-lock.json

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"play-dl": "^1.9.7",
3131
"soundcloud-downloader": "^0.2.3",
3232
"string-progressbar": "^1.0.4",
33-
"youtube-sr": "~4.3.0"
33+
"youtube-sr": "~4.3.0",
34+
"ytdl-core": "^4.11.5"
3435
},
3536
"devDependencies": {
3637
"@types/i18n": "^0.13.12",

structs/Song.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { i18n } from "../utils/i18n";
44
import { videoPattern, isURL } from "../utils/patterns";
55

66
const { stream, video_basic_info } = require("play-dl");
7+
import ytdl from "ytdl-core";
78

89
export interface SongData {
910
url: string;
@@ -60,18 +61,20 @@ export class Song {
6061
}
6162
}
6263

63-
public async makeResource(): Promise<AudioResource<Song> | void> {
64+
public async makeResource(): Promise<AudioResource | void> {
6465
let playStream;
6566

6667
const source = this.url.includes("youtube") ? "youtube" : "soundcloud";
6768

6869
if (source === "youtube") {
69-
playStream = await stream(this.url);
70+
playStream = ytdl(this.url, { filter: "audioonly", liveBuffer: 0, quality: "lowestaudio" });
7071
}
7172

7273
if (!stream) return;
7374

74-
return createAudioResource(playStream.stream, { metadata: this, inputType: playStream.type, inlineVolume: true });
75+
if (!playStream) throw new Error("No stream found");
76+
77+
return createAudioResource(playStream, { metadata: this, inlineVolume: true });
7578
}
7679

7780
public startMessage() {

0 commit comments

Comments
 (0)