forked from audacity/audacity
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ServiceConfig.cpp
91 lines (72 loc) · 2.3 KB
/
ServiceConfig.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*!********************************************************************
Audacity: A Digital Audio Editor
ServiceConfig.cpp
Dmitry Vedenko
**********************************************************************/
#include "ServiceConfig.h"
#include "Languages.h"
namespace cloud::audiocom
{
std::string_view ServiceConfig::GetAPIEndpoint() const
{
return "https://api.audio.com";
}
std::string_view ServiceConfig::GetOAuthLoginPage() const
{
static const std::string loginPage =
std::string("https://audio.com/audacity/link?clientId=") +
std::string(GetOAuthClientID());
return loginPage;
}
std::string_view ServiceConfig::GetOAuthClientID() const
{
return "1741964426607541";
}
std::string_view ServiceConfig::GetOAuthRedirectURL() const
{
//return "audacity://link";
return "https://audio.com/auth/sign-in/success";
}
std::string ServiceConfig::GetAPIUrl(std::string_view apiURI) const
{
return std::string(GetAPIEndpoint()) + std::string(apiURI);
}
std::string ServiceConfig::GetFinishUploadPage(
std::string_view audioID, std::string_view token) const
{
return "https://audio.com/audacity/upload?audioId=" + std::string(audioID) +
"&token=" + std::string(token) +
"&clientId=" + std::string(GetOAuthClientID());
}
std::string ServiceConfig::GetAudioURL(
std::string_view userSlug, std::string_view audioSlug) const
{
return "https://audio.com/" + std::string(userSlug) + "/audio/" + std::string(audioSlug) + "/edit";
}
std::chrono::milliseconds ServiceConfig::GetProgressCallbackTimeout() const
{
return std::chrono::seconds(3);
}
MimeTypesList ServiceConfig::GetPreferredAudioFormats() const
{
return { "audio/x-wavpack", "audio/x-flac", "audio/x-wav" };
}
MimeType ServiceConfig::GetDownloadMime() const
{
return "audio/x-wav";
}
std::string ServiceConfig::GetAcceptLanguageValue() const
{
auto language = Languages::GetLang();
if (language.Contains(L"-") && language.Length() > 2)
return wxString::Format("%s;q=1.0, %s;q=0.7, *;q=0.5", language, language.Left(2)).ToStdString();
else
return wxString::Format("%s;q=1.0, *;q=0.5", language).ToStdString();
}
const ServiceConfig& GetServiceConfig()
{
static ServiceConfig config;
return config;
}
} // namespace cloud::audiocom