Skip to content

Commit

Permalink
Resolve songs via identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
Elitex07 committed Sep 9, 2023
1 parent ca8da68 commit 94614fb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion build/structures/Riffy.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,15 @@ class Riffy extends EventEmitter {
const regex = /^https?:\/\//;
const identifier = regex.test(query) ? query : `${sources}:${query}`;

const response = await node.rest.makeRequest(`GET`, `/${node.rest.version}/loadtracks?identifier=${encodeURIComponent(identifier)}`);
let response = await node.rest.makeRequest(`GET`, `/${node.rest.version}/loadtracks?identifier=${encodeURIComponent(identifier)}`);

// for resolving identifiers - Only works in Spotify and Youtube
if (response.loadType === "empty" || response.loadType === "NO_MATCHES") {
response = await node.rest.makeRequest(`GET`, `/${node.rest.version}/loadtracks?identifier=https://open.spotify.com/track/${query}`);
if (response.loadType === "empty" || response.loadType === "NO_MATCHES") {
response = await node.rest.makeRequest(`GET`, `/${node.rest.version}/loadtracks?identifier=https://www.youtube.com/watch?v=${query}`);
}
}

if (node.rest.version === "v4") {
if (response.loadType === "track") {
Expand Down

0 comments on commit 94614fb

Please sign in to comment.