Hello I am trying to solve a problem with a Discord Music Bot, it works fine with Spotify songs and playlists, but Youtube playlists no (although songs it does work). I can add song by song to the queue but not a list.
This is the error:
music_message 476:TypeError: arr is not iterable
in this part of the code:
if (isYoutube(qry) && isYoutubePlaylist(qry)) {
try {
const arr = await youtube_tracks_from_playlist(qry);
for (let item of arr)
addToQueue(item, mapKey)
message.react(EMOJI_GREEN_CIRCLE)
} catch (e) {
console.log('music_message 476:' + e)
message.channel.send('Failed to process playlist: ' + qry);
}
}
But due to the fact that the error is that it cannot be iterated I guess the error comes from before and the format of the object. So here is the function:
async function youtube_tracks_from_playlist(url, isretry=false) {
const data = await ytlist(url, 'url');
console.log("Type of youtube data: " + typeof data)
console.log("Data: " + data)
if (data && 'data' in data && 'playlist' in data.data && data.data.playlist && data.data.playlist.length) {
return data.data.playlist
} else {
if (!isretry) {
console.log('retrying yt playlist processing')
return await youtube_tracks_from_playlist(url, true);
} else {
return null;
}
}
}
And in case it helps here are the outputs of the console to types of data and ytlist def:
const ytlist = require('youtube-playlist');
Type of youtube data: object
Data: [object Object]
Type of arr: object
arr: null
So, I have no clue if that [object Object] is the common thing I am supposed to get, or what is the problem?