18#include <rapidjson/document.h>
30 L
"/CloudServices/AudioCom/ApiEndpoint",
31 L
"https://api.audio.com"
35 L
"/CloudServices/AudioCom/OAuthClientID",
40 L
"/CloudServices/AudioCom/OAuthClientSecret",
41 L
"shKqnY2sLTfRK7hztwzNEVxnmhJfOy1i"
45 L
"/CloudServices/AudioCom/OAuthRedirectURL",
46 L
"https://audio.com/auth/sign-in/success"
50 L
"/CloudServices/AudioCom/OAuthLoginPage",
51 L
"https://audio.com/audacity/link?clientId={auth_client_id}"
55 L
"/CloudServices/AudioCom/FinishUploadPage",
56 L
"https://audio.com/audacity/upload?audioId={audio_id}&token={auth_token}&clientId={auth_client_id}"
60 L
"/CloudServices/AudioCom/AudioURL",
61 L
"https://audio.com/{user_slug}/audio/{audio_slug}/edit"
65 L
"/CloudServices/AudioCom/DownloadMimeType",
69std::string
Substitute(std::string pattern, std::initializer_list<std::pair<std::string_view, std::string_view>> substitutions)
71 for(
auto& [
key, value] : substitutions)
73 auto pos = pattern.find(
key);
79 if (pattern[pos - 1] ==
'{' && pattern[pos +
key.size()] ==
'}')
80 pattern.replace(pos - 1,
key.size() + 2, value);
84 return std::move(pattern);
133 std::string_view audioID, std::string_view token)
const
137 {
"auth_token", token },
142 std::string_view userSlug, std::string_view audioSlug)
const
145 mAudioURL, { {
"user_slug", userSlug }, {
"audio_slug", audioSlug } });
150 return std::chrono::seconds(3);
155 return {
"audio/x-wavpack",
"audio/x-flac",
"audio/x-wav" };
160 if(mimeType ==
"audio/x-wavpack")
162 rapidjson::Document config;
164 config.AddMember(
"quality", rapidjson::Value(2), config.GetAllocator());
165 config.AddMember(
"bit_rate", rapidjson::Value(40), config.GetAllocator());
166 config.AddMember(
"bit_depth", 24, config.GetAllocator());
167 config.AddMember(
"hybrid_mode",
false, config.GetAllocator());
170 if(mimeType ==
"audio/x-flac")
172 rapidjson::Document config;
174 config.AddMember(
"bit_depth", rapidjson::Value(24), config.GetAllocator());
175 config.AddMember(
"level", rapidjson::Value(5), config.GetAllocator());
177 if(mimeType ==
"audio/x-wav")
181 throw std::invalid_argument(
"unknown mime-type");
194 if (language.Contains(L
"-") && language.Length() > 2)
195 return wxString::Format(
"%s;q=1.0, %s;q=0.7, *;q=0.5", language, language.Left(2)).ToStdString();
197 return wxString::Format(
"%s;q=1.0, *;q=0.5", language).ToStdString();
Declare functions to perform UTF-8 to std::wstring conversions.
bool Read(T *pVar) const
overload of Read returning a boolean that is true if the value was previously defined */
Specialization of Setting for strings.
Configuration for the audio.com.
std::string GetDownloadMime() const
std::string GetAcceptLanguageValue() const
Returns the preferred language.
std::string mOAuthRedirectURL
std::string GetOAuthClientID() const
OAuth2 client ID.
rapidjson::Document GetExportConfig(const std::string &exporterName) const
Export configuration suitable for the mime type provided.
std::string GetOAuthRedirectURL() const
OAuth2 redirect URL. Only used to satisfy the protocol.
std::string GetAPIUrl(std::string_view apiURI) const
Helper to construct the full URLs for the API.
std::string GetAPIEndpoint() const
API endpoint.
std::chrono::milliseconds GetProgressCallbackTimeout() const
Timeout between progress callbacks.
std::string mOAuthClientID
std::string mFinishUploadPage
std::string GetOAuthClientSecret() const
OAuth2 client secret.
std::string mPreferredMimeType
std::string GetAudioURL(std::string_view userSlug, std::string_view audioSlug) const
Helper to construct the page URL for the authorised upload.
std::string GetFinishUploadPage(std::string_view audioID, std::string_view token) const
Helper to construct the page URL for the anonymous upload last stage.
std::string mOAuthClientSecret
std::string mOAuthLoginPage
std::string GetOAuthLoginPage() const
Page to open in browser to initiate OAuth.
std::vector< std::string > GetPreferredAudioFormats() const
Preferred audio format.
constexpr size_t npos(-1)
std::string ToUTF8(const std::wstring &wstr)
StringSetting audioComOAuthLoginPage
StringSetting audioComOAuthRedirectURL
StringSetting audioComOAuthClientID
StringSetting audioComOAuthClientSecret
StringSetting audioComAudioDownloadMimeType
StringSetting audioComAudioURL
std::string Substitute(std::string pattern, std::initializer_list< std::pair< std::string_view, std::string_view > > substitutions)
StringSetting audioComFinishUploadPage
StringSetting audioComApiEndpoint
const ServiceConfig & GetServiceConfig()
Returns the instance of the ServiceConfig.