58 std::unique_lock lock{ accessMutex };
59 jsonifier::vector<song> vector01{};
60 jsonifier::vector<song> vector02{};
61 if (searchQuery.find(
"soundcloud") == jsonifier::string::npos && searchQuery.find(
"youtube") == jsonifier::string::npos) {
62 vector01 = discord_core_client::getSoundCloudAPI(guildId).searchForSong(searchQuery, limit);
63 vector02 = discord_core_client::getYouTubeAPI(guildId).searchForSong(searchQuery, limit);
64 }
else if (searchQuery.find(
"youtube") != jsonifier::string::npos) {
65 vector02 = discord_core_client::getYouTubeAPI(guildId).searchForSong(searchQuery, limit);
66 }
else if (searchQuery.find(
"soundcloud") != jsonifier::string::npos) {
67 vector01 = discord_core_client::getSoundCloudAPI(guildId).searchForSong(searchQuery, limit);
69 uint64_t totalLength = vector01.size() + vector02.size();
70 jsonifier::vector<song> newVector{};
71 uint64_t vector01Used{};
72 uint64_t vector02Used{};
73 if (vector01.size() == 0 && vector02.size() != 0 || (vector01.size() >= 1 && vector02.size() >= 1)) {
75 }
else if (vector02.size() == 0 && vector01.size() != 0 || (vector02.size() >= 1 && vector01.size() >= 1)) {
78 for (uint64_t x = 0; x < totalLength; ++x) {
79 if ((vector01Used < vector01.size()) && (x % 2 == 0) && vector01.size() > 0) {
80 newVector.emplace_back(vector01[vector01Used]);
83 }
else if (vector02Used < vector02.size() && vector02.size() > 0) {
84 newVector.emplace_back(vector02[vector02Used]);
94 std::unique_lock lock{ accessMutex };
95 audioDataBuffer.clearContents();
97 taskThread.cancelAndWait();
99 discord_core_client::getVoiceConnection(guildId).currentUserId = songNew.addedByUserId;
101 song newerSong{ discord_core_client::getSoundCloudAPI(guildId).collectFinalSong(songNew) };
102 taskThread = discord_core_client::getSoundCloudAPI(guildId).downloadAndStreamAudio(newerSong);
105 song newerSong{ discord_core_client::getYouTubeAPI(guildId).collectFinalSong(songNew) };
106 taskThread = discord_core_client::getYouTubeAPI(guildId).downloadAndStreamAudio(newerSong);
108 return discord_core_client::getVoiceConnection(guildId).play();