Replace Spotify username/password with access token
This commit is contained in:
@@ -246,10 +246,7 @@ void EngineBase::ReloadSettings() {
|
||||
|
||||
#ifdef HAVE_SPOTIFY
|
||||
s.beginGroup(SpotifySettingsPage::kSettingsGroup);
|
||||
spotify_username_ = s.value("username").toString();
|
||||
QByteArray password = s.value("password").toByteArray();
|
||||
if (password.isEmpty()) spotify_password_.clear();
|
||||
else spotify_password_ = QString::fromUtf8(QByteArray::fromBase64(password));
|
||||
spotify_access_token_ = s.value("access_token").toString();
|
||||
s.endGroup();
|
||||
#endif
|
||||
|
||||
|
||||
@@ -249,8 +249,7 @@ class EngineBase : public QObject {
|
||||
|
||||
// Spotify
|
||||
#ifdef HAVE_SPOTIFY
|
||||
QString spotify_username_;
|
||||
QString spotify_password_;
|
||||
QString spotify_access_token_;
|
||||
#endif
|
||||
|
||||
bool about_to_end_emitted_;
|
||||
|
||||
@@ -915,7 +915,7 @@ GstEnginePipelinePtr GstEngine::CreatePipeline() {
|
||||
pipeline->set_fading_enabled(fadeout_enabled_ || autocrossfade_enabled_ || fadeout_pause_enabled_);
|
||||
|
||||
#ifdef HAVE_SPOTIFY
|
||||
pipeline->set_spotify_login(spotify_username_, spotify_password_);
|
||||
pipeline->set_spotify_access_token(spotify_access_token_);
|
||||
#endif
|
||||
|
||||
pipeline->AddBufferConsumer(this);
|
||||
|
||||
@@ -277,13 +277,9 @@ void GstEnginePipeline::set_fading_enabled(const bool enabled) {
|
||||
}
|
||||
|
||||
#ifdef HAVE_SPOTIFY
|
||||
void GstEnginePipeline::set_spotify_login(const QString &spotify_username, const QString &spotify_password) {
|
||||
|
||||
spotify_username_ = spotify_username;
|
||||
spotify_password_ = spotify_password;
|
||||
|
||||
void GstEnginePipeline::set_spotify_access_token(const QString &spotify_access_token) {
|
||||
spotify_access_token_ = spotify_access_token;
|
||||
}
|
||||
|
||||
#endif // HAVE_SPOTIFY
|
||||
|
||||
QString GstEnginePipeline::GstStateText(const GstState state) {
|
||||
@@ -1052,16 +1048,13 @@ void GstEnginePipeline::SourceSetupCallback(GstElement *playbin, GstElement *sou
|
||||
#ifdef HAVE_SPOTIFY
|
||||
{
|
||||
QMutexLocker l(&instance->mutex_url_);
|
||||
if (instance->media_url_.scheme() == QStringLiteral("spotify")) {
|
||||
if (instance->media_url_.scheme() == u"spotify"_s) {
|
||||
if (g_object_class_find_property(G_OBJECT_GET_CLASS(source), "bitrate")) {
|
||||
g_object_set(source, "bitrate", 2, nullptr);
|
||||
}
|
||||
if (!instance->spotify_username_.isEmpty() &&
|
||||
!instance->spotify_password_.isEmpty() &&
|
||||
g_object_class_find_property(G_OBJECT_GET_CLASS(source), "username") &&
|
||||
g_object_class_find_property(G_OBJECT_GET_CLASS(source), "password")) {
|
||||
g_object_set(source, "username", instance->spotify_username_.toUtf8().constData(), nullptr);
|
||||
g_object_set(source, "password", instance->spotify_password_.toUtf8().constData(), nullptr);
|
||||
if (!instance->spotify_access_token_.isEmpty() && g_object_class_find_property(G_OBJECT_GET_CLASS(source), "access-token")) {
|
||||
const QByteArray access_token = instance->spotify_access_token_.toUtf8();
|
||||
g_object_set(source, "access-token", access_token.constData(), nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class GstEnginePipeline : public QObject {
|
||||
void set_strict_ssl_enabled(const bool enabled);
|
||||
void set_fading_enabled(const bool enabled);
|
||||
#ifdef HAVE_SPOTIFY
|
||||
void set_spotify_login(const QString &spotify_username, const QString &spotify_password);
|
||||
void set_spotify_access_token(const QString &spotify_access_token);
|
||||
#endif
|
||||
|
||||
bool Finish();
|
||||
@@ -259,8 +259,7 @@ class GstEnginePipeline : public QObject {
|
||||
|
||||
// Spotify
|
||||
#ifdef HAVE_SPOTIFY
|
||||
QString spotify_username_;
|
||||
QString spotify_password_;
|
||||
QString spotify_access_token_;
|
||||
#endif
|
||||
|
||||
// The URL that is currently playing, and the URL that is to be preloaded when the current track is close to finishing.
|
||||
|
||||
Reference in New Issue
Block a user