Replace Spotify username/password with access token
This commit is contained in:
@@ -246,10 +246,7 @@ void EngineBase::ReloadSettings() {
|
|||||||
|
|
||||||
#ifdef HAVE_SPOTIFY
|
#ifdef HAVE_SPOTIFY
|
||||||
s.beginGroup(SpotifySettingsPage::kSettingsGroup);
|
s.beginGroup(SpotifySettingsPage::kSettingsGroup);
|
||||||
spotify_username_ = s.value("username").toString();
|
spotify_access_token_ = s.value("access_token").toString();
|
||||||
QByteArray password = s.value("password").toByteArray();
|
|
||||||
if (password.isEmpty()) spotify_password_.clear();
|
|
||||||
else spotify_password_ = QString::fromUtf8(QByteArray::fromBase64(password));
|
|
||||||
s.endGroup();
|
s.endGroup();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -249,8 +249,7 @@ class EngineBase : public QObject {
|
|||||||
|
|
||||||
// Spotify
|
// Spotify
|
||||||
#ifdef HAVE_SPOTIFY
|
#ifdef HAVE_SPOTIFY
|
||||||
QString spotify_username_;
|
QString spotify_access_token_;
|
||||||
QString spotify_password_;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool about_to_end_emitted_;
|
bool about_to_end_emitted_;
|
||||||
|
|||||||
@@ -915,7 +915,7 @@ GstEnginePipelinePtr GstEngine::CreatePipeline() {
|
|||||||
pipeline->set_fading_enabled(fadeout_enabled_ || autocrossfade_enabled_ || fadeout_pause_enabled_);
|
pipeline->set_fading_enabled(fadeout_enabled_ || autocrossfade_enabled_ || fadeout_pause_enabled_);
|
||||||
|
|
||||||
#ifdef HAVE_SPOTIFY
|
#ifdef HAVE_SPOTIFY
|
||||||
pipeline->set_spotify_login(spotify_username_, spotify_password_);
|
pipeline->set_spotify_access_token(spotify_access_token_);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pipeline->AddBufferConsumer(this);
|
pipeline->AddBufferConsumer(this);
|
||||||
|
|||||||
@@ -277,13 +277,9 @@ void GstEnginePipeline::set_fading_enabled(const bool enabled) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_SPOTIFY
|
#ifdef HAVE_SPOTIFY
|
||||||
void GstEnginePipeline::set_spotify_login(const QString &spotify_username, const QString &spotify_password) {
|
void GstEnginePipeline::set_spotify_access_token(const QString &spotify_access_token) {
|
||||||
|
spotify_access_token_ = spotify_access_token;
|
||||||
spotify_username_ = spotify_username;
|
|
||||||
spotify_password_ = spotify_password;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // HAVE_SPOTIFY
|
#endif // HAVE_SPOTIFY
|
||||||
|
|
||||||
QString GstEnginePipeline::GstStateText(const GstState state) {
|
QString GstEnginePipeline::GstStateText(const GstState state) {
|
||||||
@@ -1052,16 +1048,13 @@ void GstEnginePipeline::SourceSetupCallback(GstElement *playbin, GstElement *sou
|
|||||||
#ifdef HAVE_SPOTIFY
|
#ifdef HAVE_SPOTIFY
|
||||||
{
|
{
|
||||||
QMutexLocker l(&instance->mutex_url_);
|
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")) {
|
if (g_object_class_find_property(G_OBJECT_GET_CLASS(source), "bitrate")) {
|
||||||
g_object_set(source, "bitrate", 2, nullptr);
|
g_object_set(source, "bitrate", 2, nullptr);
|
||||||
}
|
}
|
||||||
if (!instance->spotify_username_.isEmpty() &&
|
if (!instance->spotify_access_token_.isEmpty() && g_object_class_find_property(G_OBJECT_GET_CLASS(source), "access-token")) {
|
||||||
!instance->spotify_password_.isEmpty() &&
|
const QByteArray access_token = instance->spotify_access_token_.toUtf8();
|
||||||
g_object_class_find_property(G_OBJECT_GET_CLASS(source), "username") &&
|
g_object_set(source, "access-token", access_token.constData(), nullptr);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ class GstEnginePipeline : public QObject {
|
|||||||
void set_strict_ssl_enabled(const bool enabled);
|
void set_strict_ssl_enabled(const bool enabled);
|
||||||
void set_fading_enabled(const bool enabled);
|
void set_fading_enabled(const bool enabled);
|
||||||
#ifdef HAVE_SPOTIFY
|
#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
|
#endif
|
||||||
|
|
||||||
bool Finish();
|
bool Finish();
|
||||||
@@ -259,8 +259,7 @@ class GstEnginePipeline : public QObject {
|
|||||||
|
|
||||||
// Spotify
|
// Spotify
|
||||||
#ifdef HAVE_SPOTIFY
|
#ifdef HAVE_SPOTIFY
|
||||||
QString spotify_username_;
|
QString spotify_access_token_;
|
||||||
QString spotify_password_;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// The URL that is currently playing, and the URL that is to be preloaded when the current track is close to finishing.
|
// The URL that is currently playing, and the URL that is to be preloaded when the current track is close to finishing.
|
||||||
|
|||||||
@@ -87,11 +87,6 @@ void SpotifySettingsPage::Load() {
|
|||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
ui_->enable->setChecked(s.value("enabled", false).toBool());
|
||||||
|
|
||||||
ui_->username->setText(s.value("username").toString());
|
|
||||||
QByteArray password = s.value("password").toByteArray();
|
|
||||||
if (password.isEmpty()) ui_->password->clear();
|
|
||||||
else ui_->password->setText(QString::fromUtf8(QByteArray::fromBase64(password)));
|
|
||||||
|
|
||||||
ui_->searchdelay->setValue(s.value("searchdelay", 1500).toInt());
|
ui_->searchdelay->setValue(s.value("searchdelay", 1500).toInt());
|
||||||
ui_->artistssearchlimit->setValue(s.value("artistssearchlimit", 4).toInt());
|
ui_->artistssearchlimit->setValue(s.value("artistssearchlimit", 4).toInt());
|
||||||
ui_->albumssearchlimit->setValue(s.value("albumssearchlimit", 10).toInt());
|
ui_->albumssearchlimit->setValue(s.value("albumssearchlimit", 10).toInt());
|
||||||
@@ -114,10 +109,6 @@ void SpotifySettingsPage::Save() {
|
|||||||
Settings s;
|
Settings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
s.setValue("enabled", ui_->enable->isChecked());
|
s.setValue("enabled", ui_->enable->isChecked());
|
||||||
|
|
||||||
s.setValue("username", ui_->username->text());
|
|
||||||
s.setValue("password", QString::fromUtf8(ui_->password->text().toUtf8().toBase64()));
|
|
||||||
|
|
||||||
s.setValue("searchdelay", ui_->searchdelay->value());
|
s.setValue("searchdelay", ui_->searchdelay->value());
|
||||||
s.setValue("artistssearchlimit", ui_->artistssearchlimit->value());
|
s.setValue("artistssearchlimit", ui_->artistssearchlimit->value());
|
||||||
s.setValue("albumssearchlimit", ui_->albumssearchlimit->value());
|
s.setValue("albumssearchlimit", ui_->albumssearchlimit->value());
|
||||||
|
|||||||
@@ -40,52 +40,6 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
|
||||||
<widget class="QGroupBox" name="group_device_credentials">
|
|
||||||
<property name="sizePolicy">
|
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Maximum">
|
|
||||||
<horstretch>0</horstretch>
|
|
||||||
<verstretch>0</verstretch>
|
|
||||||
</sizepolicy>
|
|
||||||
</property>
|
|
||||||
<property name="title">
|
|
||||||
<string>Device credentials</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QFormLayout" name="layout_credential_group">
|
|
||||||
<item row="1" column="0">
|
|
||||||
<widget class="QLabel" name="label_username">
|
|
||||||
<property name="text">
|
|
||||||
<string>Username</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="0">
|
|
||||||
<widget class="QLabel" name="label_password">
|
|
||||||
<property name="text">
|
|
||||||
<string>Password</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="2" column="1">
|
|
||||||
<widget class="QLineEdit" name="password">
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
<property name="echoMode">
|
|
||||||
<enum>QLineEdit::EchoMode::Password</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QLineEdit" name="username">
|
|
||||||
<property name="text">
|
|
||||||
<string notr="true"/>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="widget_warning" native="true">
|
<widget class="QWidget" name="widget_warning" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
@@ -312,7 +266,6 @@
|
|||||||
</customwidgets>
|
</customwidgets>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>enable</tabstop>
|
<tabstop>enable</tabstop>
|
||||||
<tabstop>password</tabstop>
|
|
||||||
<tabstop>searchdelay</tabstop>
|
<tabstop>searchdelay</tabstop>
|
||||||
<tabstop>artistssearchlimit</tabstop>
|
<tabstop>artistssearchlimit</tabstop>
|
||||||
<tabstop>albumssearchlimit</tabstop>
|
<tabstop>albumssearchlimit</tabstop>
|
||||||
|
|||||||
@@ -4410,9 +4410,6 @@ msgstr ""
|
|||||||
msgid "Authenticate"
|
msgid "Authenticate"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
msgid "Device credentials"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"<html><head/><body><p>The GStreamer Spotify plugin is not detected, you will "
|
"<html><head/><body><p>The GStreamer Spotify plugin is not detected, you will "
|
||||||
"not be able to stream songs from Spotify without it. See <a href=\"https://"
|
"not be able to stream songs from Spotify without it. See <a href=\"https://"
|
||||||
|
|||||||
Reference in New Issue
Block a user