Make tidal token configurable
This commit is contained in:
parent
f33609bbf8
commit
7cc9c75d15
@ -50,7 +50,6 @@
|
||||
|
||||
const char *TidalCoverProvider::kApiUrl = "https://api.tidalhifi.com/v1";
|
||||
const char *TidalCoverProvider::kResourcesUrl = "http://resources.tidal.com";
|
||||
const char *TidalCoverProvider::kApiTokenB64 = "UDVYYmVvNUxGdkVTZUR5Ng==";
|
||||
const int TidalCoverProvider::kLimit = 10;
|
||||
|
||||
TidalCoverProvider::TidalCoverProvider(Application *app, QObject *parent) :
|
||||
|
@ -45,25 +45,26 @@ TidalSettingsPage::TidalSettingsPage(SettingsDialog *parent)
|
||||
connect(ui_->button_login, SIGNAL(clicked()), SLOT(LoginClicked()));
|
||||
connect(ui_->login_state, SIGNAL(LogoutClicked()), SLOT(LogoutClicked()));
|
||||
|
||||
connect(this, SIGNAL(Login(QString, QString)), service_, SLOT(SendLogin(QString, QString)));
|
||||
connect(this, SIGNAL(Login(QString, QString, QString)), service_, SLOT(SendLogin(QString, QString, QString)));
|
||||
|
||||
connect(service_, SIGNAL(LoginFailure(QString)), SLOT(LoginFailure(QString)));
|
||||
connect(service_, SIGNAL(LoginSuccess()), SLOT(LoginSuccess()));
|
||||
|
||||
dialog()->installEventFilter(this);
|
||||
|
||||
ui_->combobox_quality->addItem("Low", "LOW");
|
||||
ui_->combobox_quality->addItem("High", "HIGH");
|
||||
ui_->combobox_quality->addItem("Lossless", "LOSSLESS");
|
||||
ui_->quality->addItem("Low", "LOW");
|
||||
ui_->quality->addItem("High", "HIGH");
|
||||
ui_->quality->addItem("Lossless", "LOSSLESS");
|
||||
|
||||
ui_->combobox_streamurl->addItem("HTTP", "http");
|
||||
ui_->combobox_streamurl->addItem("HTTPS", "https");
|
||||
ui_->streamurl->addItem("Default", "default");
|
||||
ui_->streamurl->addItem("HTTP", "http");
|
||||
ui_->streamurl->addItem("HTTPS", "https");
|
||||
|
||||
ui_->combobox_coversize->addItem("160x160", "160x160");
|
||||
ui_->combobox_coversize->addItem("320x320", "320x320");
|
||||
ui_->combobox_coversize->addItem("640x640", "640x640");
|
||||
ui_->combobox_coversize->addItem("750x750", "750x750");
|
||||
ui_->combobox_coversize->addItem("1280x1280", "1280x1280");
|
||||
ui_->coversize->addItem("160x160", "160x160");
|
||||
ui_->coversize->addItem("320x320", "320x320");
|
||||
ui_->coversize->addItem("640x640", "640x640");
|
||||
ui_->coversize->addItem("750x750", "750x750");
|
||||
ui_->coversize->addItem("1280x1280", "1280x1280");
|
||||
|
||||
}
|
||||
|
||||
@ -79,14 +80,15 @@ void TidalSettingsPage::Load() {
|
||||
QByteArray password = s.value("password").toByteArray();
|
||||
if (password.isEmpty()) ui_->password->clear();
|
||||
else ui_->password->setText(QString::fromUtf8(QByteArray::fromBase64(password)));
|
||||
dialog()->ComboBoxLoadFromSettings(s, ui_->combobox_quality, "quality", "HIGH");
|
||||
ui_->spinbox_searchdelay->setValue(s.value("searchdelay", 1500).toInt());
|
||||
ui_->spinbox_artistssearchlimit->setValue(s.value("artistssearchlimit", 5).toInt());
|
||||
ui_->spinbox_albumssearchlimit->setValue(s.value("albumssearchlimit", 100).toInt());
|
||||
ui_->spinbox_songssearchlimit->setValue(s.value("songssearchlimit", 100).toInt());
|
||||
ui_->token->setText(s.value("token").toString());
|
||||
dialog()->ComboBoxLoadFromSettings(s, ui_->quality, "quality", "HIGH");
|
||||
ui_->searchdelay->setValue(s.value("searchdelay", 1500).toInt());
|
||||
ui_->artistssearchlimit->setValue(s.value("artistssearchlimit", 5).toInt());
|
||||
ui_->albumssearchlimit->setValue(s.value("albumssearchlimit", 100).toInt());
|
||||
ui_->songssearchlimit->setValue(s.value("songssearchlimit", 100).toInt());
|
||||
ui_->checkbox_fetchalbums->setChecked(s.value("fetchalbums", false).toBool());
|
||||
dialog()->ComboBoxLoadFromSettings(s, ui_->combobox_coversize, "coversize", "320x320");
|
||||
dialog()->ComboBoxLoadFromSettings(s, ui_->combobox_streamurl, "streamurl", "http");
|
||||
dialog()->ComboBoxLoadFromSettings(s, ui_->coversize, "coversize", "320x320");
|
||||
dialog()->ComboBoxLoadFromSettings(s, ui_->streamurl, "streamurl", "http");
|
||||
s.endGroup();
|
||||
|
||||
if (service_->authenticated()) ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn);
|
||||
@ -100,14 +102,15 @@ void TidalSettingsPage::Save() {
|
||||
s.setValue("enabled", ui_->checkbox_enable->isChecked());
|
||||
s.setValue("username", ui_->username->text());
|
||||
s.setValue("password", QString::fromUtf8(ui_->password->text().toUtf8().toBase64()));
|
||||
s.setValue("quality", ui_->combobox_quality->itemData(ui_->combobox_quality->currentIndex()));
|
||||
s.setValue("searchdelay", ui_->spinbox_searchdelay->value());
|
||||
s.setValue("artistssearchlimit", ui_->spinbox_artistssearchlimit->value());
|
||||
s.setValue("albumssearchlimit", ui_->spinbox_albumssearchlimit->value());
|
||||
s.setValue("songssearchlimit", ui_->spinbox_songssearchlimit->value());
|
||||
s.setValue("token", ui_->token->text());
|
||||
s.setValue("quality", ui_->quality->itemData(ui_->quality->currentIndex()));
|
||||
s.setValue("searchdelay", ui_->searchdelay->value());
|
||||
s.setValue("artistssearchlimit", ui_->artistssearchlimit->value());
|
||||
s.setValue("albumssearchlimit", ui_->albumssearchlimit->value());
|
||||
s.setValue("songssearchlimit", ui_->songssearchlimit->value());
|
||||
s.setValue("fetchalbums", ui_->checkbox_fetchalbums->isChecked());
|
||||
s.setValue("coversize", ui_->combobox_coversize->itemData(ui_->combobox_coversize->currentIndex()));
|
||||
s.setValue("streamurl", ui_->combobox_streamurl->itemData(ui_->combobox_streamurl->currentIndex()));
|
||||
s.setValue("coversize", ui_->coversize->itemData(ui_->coversize->currentIndex()));
|
||||
s.setValue("streamurl", ui_->streamurl->itemData(ui_->streamurl->currentIndex()));
|
||||
s.endGroup();
|
||||
|
||||
service_->ReloadSettings();
|
||||
@ -115,7 +118,7 @@ void TidalSettingsPage::Save() {
|
||||
}
|
||||
|
||||
void TidalSettingsPage::LoginClicked() {
|
||||
emit Login(ui_->username->text(), ui_->password->text());
|
||||
emit Login(ui_->username->text(), ui_->password->text(), ui_->token->text());
|
||||
ui_->button_login->setEnabled(false);
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,8 @@ class TidalSettingsPage : public SettingsPage {
|
||||
|
||||
bool eventFilter(QObject *object, QEvent *event);
|
||||
|
||||
signals:
|
||||
void Login(const QString &username, const QString &password);
|
||||
signals:
|
||||
void Login(const QString &username, const QString &password, const QString &token);
|
||||
|
||||
private slots:
|
||||
void LoginClicked();
|
||||
|
@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>715</width>
|
||||
<height>594</height>
|
||||
<height>650</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -95,7 +95,47 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="layout_preferences">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="quality">
|
||||
<layout class="QHBoxLayout" name="layout_token">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_token">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Token</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="token">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>200</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_token">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_quality">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_quality">
|
||||
<property name="minimumSize">
|
||||
@ -110,7 +150,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="combobox_quality"/>
|
||||
<widget class="QComboBox" name="quality"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_quality">
|
||||
@ -128,7 +168,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="searchdelay">
|
||||
<layout class="QHBoxLayout" name="layout_searchdelay">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_searchdelay">
|
||||
<property name="minimumSize">
|
||||
@ -143,7 +183,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinbox_searchdelay">
|
||||
<widget class="QSpinBox" name="searchdelay">
|
||||
<property name="suffix">
|
||||
<string>ms</string>
|
||||
</property>
|
||||
@ -177,7 +217,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="artistssearchlimit">
|
||||
<layout class="QHBoxLayout" name="layout_artistssearchlimit">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_artistssearchlimit">
|
||||
<property name="minimumSize">
|
||||
@ -192,7 +232,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinbox_artistssearchlimit">
|
||||
<widget class="QSpinBox" name="artistssearchlimit">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
@ -220,7 +260,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="albumssearchlimit">
|
||||
<layout class="QHBoxLayout" name="layout_albumssearchlimit">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_albumssearchlimit">
|
||||
<property name="minimumSize">
|
||||
@ -235,7 +275,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinbox_albumssearchlimit">
|
||||
<widget class="QSpinBox" name="albumssearchlimit">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
@ -263,7 +303,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="songssearchlimit">
|
||||
<layout class="QHBoxLayout" name="layout_songssearchlimit">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_songssearchlimit">
|
||||
<property name="minimumSize">
|
||||
@ -278,7 +318,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QSpinBox" name="spinbox_songssearchlimit">
|
||||
<widget class="QSpinBox" name="songssearchlimit">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
@ -313,7 +353,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="coversize">
|
||||
<layout class="QHBoxLayout" name="layout_coversize">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_coversize">
|
||||
<property name="minimumSize">
|
||||
@ -328,7 +368,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="combobox_coversize"/>
|
||||
<widget class="QComboBox" name="coversize"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="spacer_coversize">
|
||||
@ -346,7 +386,7 @@
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="streamurl">
|
||||
<layout class="QHBoxLayout" name="layout_streamurl">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_streamurl">
|
||||
<property name="minimumSize">
|
||||
@ -361,10 +401,10 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="combobox_streamurl"/>
|
||||
<widget class="QComboBox" name="streamurl"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<spacer name="spacer_streamurl">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
@ -118,14 +118,16 @@ void TidalService::ReloadSettings() {
|
||||
QByteArray password = s.value("password").toByteArray();
|
||||
if (password.isEmpty()) password_.clear();
|
||||
else password_ = QString::fromUtf8(QByteArray::fromBase64(password));
|
||||
quality_ = s.value("quality").toString();
|
||||
token_ = s.value("token").toString();
|
||||
if (token_.isEmpty()) token_ = QString::fromUtf8(QByteArray::fromBase64(kApiTokenB64));
|
||||
quality_ = s.value("quality", "LOSSLESS").toString();
|
||||
search_delay_ = s.value("searchdelay", 1500).toInt();
|
||||
artistssearchlimit_ = s.value("artistssearchlimit", 5).toInt();
|
||||
albumssearchlimit_ = s.value("albumssearchlimit", 100).toInt();
|
||||
songssearchlimit_ = s.value("songssearchlimit", 100).toInt();
|
||||
fetchalbums_ = s.value("fetchalbums", false).toBool();
|
||||
coversize_ = s.value("coversize", "320x320").toString();
|
||||
streamurl_ = s.value("streamurl", "http").toString();
|
||||
streamurl_ = s.value("streamurl", "default").toString();
|
||||
s.endGroup();
|
||||
|
||||
}
|
||||
@ -144,10 +146,10 @@ void TidalService::LoadSessionID() {
|
||||
}
|
||||
|
||||
void TidalService::SendLogin() {
|
||||
SendLogin(username_, password_);
|
||||
SendLogin(username_, password_, token_);
|
||||
}
|
||||
|
||||
void TidalService::SendLogin(const QString &username, const QString &password) {
|
||||
void TidalService::SendLogin(const QString &username, const QString &password, const QString &token) {
|
||||
|
||||
if (search_id_ != 0) emit UpdateStatus(tr("Authenticating..."));
|
||||
|
||||
@ -163,7 +165,7 @@ void TidalService::SendLogin(const QString &username, const QString &password) {
|
||||
typedef QPair<QByteArray, QByteArray> EncodedArg;
|
||||
typedef QList<EncodedArg> EncodedArgList;
|
||||
|
||||
ArgList args = ArgList() << Arg("token", QByteArray::fromBase64(kApiTokenB64))
|
||||
ArgList args = ArgList() << Arg("token", token_)
|
||||
<< Arg("username", username)
|
||||
<< Arg("password", password)
|
||||
<< Arg("clientVersion", "2.2.1--7");
|
||||
@ -180,7 +182,7 @@ void TidalService::SendLogin(const QString &username, const QString &password) {
|
||||
QNetworkRequest req(url);
|
||||
|
||||
req.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded");
|
||||
req.setRawHeader("X-Tidal-Token", QByteArray::fromBase64(kApiTokenB64));
|
||||
req.setRawHeader("X-Tidal-Token", token_.toUtf8());
|
||||
|
||||
QNetworkReply *reply = network_->post(req, url_query.toString(QUrl::FullyEncoded).toUtf8());
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(HandleAuthReply(QNetworkReply*)), reply);
|
||||
@ -1037,7 +1039,7 @@ void TidalService::StreamURLReceived(QNetworkReply *reply, const int song_id, co
|
||||
filetype = Song::FileType_Stream;
|
||||
}
|
||||
|
||||
if (new_url.scheme() != streamurl_) new_url.setScheme(streamurl_);
|
||||
if (new_url.scheme() != streamurl_ && streamurl_.toLower() != "default") new_url.setScheme(streamurl_);
|
||||
|
||||
emit StreamURLFinished(original_url, new_url, filetype);
|
||||
|
||||
|
@ -62,6 +62,7 @@ class TidalService : public InternetService {
|
||||
const bool login_sent() { return login_sent_; }
|
||||
const bool authenticated() { return (!session_id_.isEmpty() && !country_code_.isEmpty()); }
|
||||
|
||||
QString token() { return token_; }
|
||||
QString session_id() { return session_id_; }
|
||||
QString country_code() { return country_code_; }
|
||||
|
||||
@ -81,7 +82,7 @@ class TidalService : public InternetService {
|
||||
|
||||
public slots:
|
||||
void ShowConfig();
|
||||
void SendLogin(const QString &username, const QString &password);
|
||||
void SendLogin(const QString &username, const QString &password, const QString &token);
|
||||
|
||||
private slots:
|
||||
void SendLogin();
|
||||
@ -128,6 +129,7 @@ class TidalService : public InternetService {
|
||||
QTimer *timer_search_delay_;
|
||||
QTimer *timer_login_attempt_;
|
||||
|
||||
QString token_;
|
||||
QString username_;
|
||||
QString password_;
|
||||
QString quality_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user