Skip to content

Commit

Permalink
[Enhancement] updated play-dl to the latest version, fixed breaking c…
Browse files Browse the repository at this point in the history
…hanges for play command after play-dl update
  • Loading branch information
naseif committed Nov 1, 2021
1 parent 2d51fe8 commit 307a129
Show file tree
Hide file tree
Showing 3 changed files with 207 additions and 226 deletions.
13 changes: 10 additions & 3 deletions commands/Music/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,29 @@ module.exports = {
leaveOnEmpty: true,
async onBeforeCreateStream(track, source, _queue) {
if (source === "soundcloud") {
const client_id = await playdl.getFreeClientID();
playdl.setToken({
soundcloud: {
client_id: client_id,
},
});
if (await playdl.so_validate(track.url)) {
let soundCloudInfo = await playdl.soundcloud(track.url);
console.log(soundCloudInfo);
return (await playdl.stream_from_info(soundCloudInfo)).stream;
}
return;
}

if (source === "youtube") {
if (playdl.sp_validate(track.url)) {
const validateSP = playdl.sp_validate(track.url);
const spotifyList = ["track", "album", "playlist"];
if (spotifyList.includes(validateSP)) {
if (playdl.is_expired()) {
await playdl.refreshToken();
}
let spotifyInfo = await playdl.spotify(track.url);
let youtube = await playdl.search(`${spotifyInfo.name}`, {
limit: 1,
limit: 2,
});
return (await playdl.stream(youtube[0].url)).stream;
}
Expand Down
Loading

0 comments on commit 307a129

Please sign in to comment.