mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2025-01-31 09:44:50 +01:00
Qobuz: Add option for base64 app secret
This commit is contained in:
parent
5711eef2be
commit
f06218f8e3
@ -230,6 +230,8 @@ void QobuzService::ReloadSettings() {
|
||||
app_id_ = s.value("app_id").toString();
|
||||
app_secret_ = s.value("app_secret").toString();
|
||||
|
||||
const bool base64_secret = s.value("base64secret", false).toBool();;
|
||||
|
||||
username_ = s.value("username").toString();
|
||||
QByteArray password = s.value("password").toByteArray();
|
||||
if (password.isEmpty()) password_.clear();
|
||||
@ -248,6 +250,29 @@ void QobuzService::ReloadSettings() {
|
||||
|
||||
s.endGroup();
|
||||
|
||||
if (base64_secret) {
|
||||
app_secret_ = DecodeAppSecret(app_secret_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QString QobuzService::DecodeAppSecret(const QString &app_secret_base64) {
|
||||
|
||||
const QByteArray appid = app_id().toUtf8();
|
||||
const QByteArray app_secret_binary = QByteArray::fromBase64(app_secret_base64.toUtf8());
|
||||
QString app_secret_decoded;
|
||||
|
||||
for (int x = 0, y = 0; x < app_secret_binary.length(); ++x , ++y) {
|
||||
if (y == appid.length()) y = 0;
|
||||
const uint rc = app_secret_binary[x] ^ appid[y];
|
||||
if (rc > 0xFFFF) {
|
||||
return app_secret_base64;
|
||||
}
|
||||
app_secret_decoded.append(QChar(rc));
|
||||
}
|
||||
|
||||
return app_secret_decoded;
|
||||
|
||||
}
|
||||
|
||||
void QobuzService::SendLogin() {
|
||||
|
@ -145,6 +145,7 @@ class QobuzService : public InternetService {
|
||||
using Param = QPair<QString, QString>;
|
||||
using ParamList = QList<Param>;
|
||||
|
||||
QString DecodeAppSecret(const QString &app_secret_encoded);
|
||||
void SendSearch();
|
||||
void LoginError(const QString &error = QString(), const QVariant &debug = QVariant());
|
||||
|
||||
|
@ -112,17 +112,6 @@ void QobuzStreamURLRequest::GetStreamURL() {
|
||||
reply_->deleteLater();
|
||||
}
|
||||
|
||||
#if 0
|
||||
QByteArray appid = app_id().toUtf8();
|
||||
QByteArray secret_decoded = QByteArray::fromBase64(app_secret().toUtf8());
|
||||
QString secret;
|
||||
for (int x = 0, y = 0; x < secret_decoded.length(); ++x , ++y) {
|
||||
if (y == appid.length()) y = 0;
|
||||
secret.append(QChar(secret_decoded[x] ^ appid[y]));
|
||||
}
|
||||
#endif
|
||||
|
||||
QString secret = app_secret();
|
||||
quint64 timestamp = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
|
||||
ParamList params_to_sign = ParamList() << Param("format_id", QString::number(format()))
|
||||
@ -136,7 +125,7 @@ void QobuzStreamURLRequest::GetStreamURL() {
|
||||
data_to_sign += param.first + param.second;
|
||||
}
|
||||
data_to_sign += QString::number(timestamp);
|
||||
data_to_sign += secret.toUtf8();
|
||||
data_to_sign += app_secret().toUtf8();
|
||||
|
||||
QByteArray const digest = QCryptographicHash::hash(data_to_sign.toUtf8(), QCryptographicHash::Md5);
|
||||
QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, '0').toLower();
|
||||
|
@ -89,6 +89,7 @@ void QobuzSettingsPage::Load() {
|
||||
ui_->artistssearchlimit->setValue(s.value("artistssearchlimit", 4).toInt());
|
||||
ui_->albumssearchlimit->setValue(s.value("albumssearchlimit", 10).toInt());
|
||||
ui_->songssearchlimit->setValue(s.value("songssearchlimit", 10).toInt());
|
||||
ui_->checkbox_base64_secret->setChecked(s.value("base64secret", false).toBool());
|
||||
ui_->checkbox_download_album_covers->setChecked(s.value("downloadalbumcovers", true).toBool());
|
||||
|
||||
s.endGroup();
|
||||
@ -117,6 +118,7 @@ void QobuzSettingsPage::Save() {
|
||||
s.setValue("artistssearchlimit", ui_->artistssearchlimit->value());
|
||||
s.setValue("albumssearchlimit", ui_->albumssearchlimit->value());
|
||||
s.setValue("songssearchlimit", ui_->songssearchlimit->value());
|
||||
s.setValue("base64secret", ui_->checkbox_base64_secret->isChecked());
|
||||
s.setValue("downloadalbumcovers", ui_->checkbox_download_album_covers->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
|
@ -62,28 +62,28 @@
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="app_id"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_username">
|
||||
<property name="text">
|
||||
<string>Username</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="username"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_password">
|
||||
<property name="text">
|
||||
<string>Password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QLineEdit" name="password">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
@ -119,24 +119,24 @@
|
||||
<string>Preferences</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="layout_preferences">
|
||||
<item row="0" column="0">
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_format">
|
||||
<property name="text">
|
||||
<string>Audio format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<item row="2" column="1">
|
||||
<widget class="QComboBox" name="format"/>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_searchdelay">
|
||||
<property name="text">
|
||||
<string>Search delay</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<item row="3" column="1">
|
||||
<widget class="QSpinBox" name="searchdelay">
|
||||
<property name="suffix">
|
||||
<string>ms</string>
|
||||
@ -155,14 +155,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_artistssearchlimit">
|
||||
<property name="text">
|
||||
<string>Artists search limit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<item row="4" column="1">
|
||||
<widget class="QSpinBox" name="artistssearchlimit">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
@ -175,14 +175,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_albumssearchlimit">
|
||||
<property name="text">
|
||||
<string>Albums search limit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QSpinBox" name="albumssearchlimit">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
@ -195,14 +195,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_songssearchlimit">
|
||||
<property name="text">
|
||||
<string>Songs search limit</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QSpinBox" name="songssearchlimit">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
@ -215,13 +215,20 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QCheckBox" name="checkbox_download_album_covers">
|
||||
<property name="text">
|
||||
<string>Download album covers</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkbox_base64_secret">
|
||||
<property name="text">
|
||||
<string>Base64 encoded secret</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
@ -299,7 +306,6 @@
|
||||
<tabstop>checkbox_download_album_covers</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../data/data.qrc"/>
|
||||
<include location="../../data/icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
|
Loading…
x
Reference in New Issue
Block a user