DiscordCoreAPI
A Discord bot library written in C++, with custom asynchronous coroutines.
Loading...
Searching...
No Matches
SoundCloudAPI.hpp
Go to the documentation of this file.
1/*
2 DiscordCoreAPI, A bot library for Discord, written in C++, and featuring explicit multithreading through the usage of custom, asynchronous C++ CoRoutines.
3
4 Copyright 2021, 2022 Chris M. (RealTimeChris)
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either
9 version 2.1 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
19 USA
20*/
21/// SoundCloudAPI.hpp - Header for the SoundCloud api related stuff.
22/// Aug 25, 2021
23/// https://discordcoreapi.com
24/// \file SoundCloudAPI.hpp
25
26#pragma once
27
31
32namespace DiscordCoreInternal {
33
34 class DiscordCoreAPI_Dll SoundCloudRequestBuilder {
35 public:
36 SoundCloudRequestBuilder() noexcept = default;
37
38 protected:
39 static std::string clientId;
40
41 const std::string baseUrl02{ "https://api-v2.soundcloud.com" };
42 DiscordCoreAPI::ConfigManager* configManager{ nullptr };
43 const std::string baseUrl{ "https://soundcloud.com" };
44 const std::string appVersion{ "1654762087" };
45 HttpsClient* httpsClient{ nullptr };
46
47 std::vector<DiscordCoreAPI::Song> collectSearchResults(const std::string& string);
48
49 DiscordCoreAPI::Song constructDownloadInfo(DiscordCoreAPI::Song& newSong);
50
51 DiscordCoreAPI::Song collectFinalSong(DiscordCoreAPI::Song& newSong);
52
53 std::string collectClientId();
54 };
55
56 class DiscordCoreAPI_Dll SoundCloudAPI : public SoundCloudRequestBuilder {
57 public:
58 SoundCloudAPI(DiscordCoreAPI::ConfigManager* configManagerNew, HttpsClient* httpsClient, const DiscordCoreAPI::Snowflake guildId);
59
60 void weFailedToDownloadOrDecode(const DiscordCoreAPI::Song& newSong, std::stop_token token, int32_t currentReconnectTries);
61
62 void downloadAndStreamAudio(const DiscordCoreAPI::Song& newSong, std::stop_token token, int32_t currentReconnectTries);
63
64 std::vector<DiscordCoreAPI::Song> searchForSong(const std::string& searchQuery);
65
66 DiscordCoreAPI::Song collectFinalSong(DiscordCoreAPI::Song& newSong);
67
68 protected:
69 DiscordCoreAPI::Snowflake guildId{};
70 const int32_t maxBufferSize{ 8192 };
71 DiscordCoreAPI::Song theSong{};
72 };
73
74};// namespace DiscordCoreAPI
A song from the various platforms.