Rename filename to url, change album_id to string and recreate songs tables (#182)
This commit is contained in:
@@ -61,7 +61,7 @@ TidalBaseRequest::~TidalBaseRequest() {
|
||||
QNetworkReply *TidalBaseRequest::CreateRequest(const QString &ressource_name, const QList<Param> ¶ms_provided) {
|
||||
|
||||
ParamList params = ParamList() << params_provided
|
||||
<< Param("countryCode", country_code());
|
||||
<< Param("countryCode", country_code());
|
||||
|
||||
QUrlQuery url_query;
|
||||
for (const Param& param : params) {
|
||||
|
||||
@@ -109,8 +109,8 @@ void TidalFavoriteRequest::AddFavorites(const FavoriteType type, const SongList
|
||||
id = QString::number(song.artist_id());
|
||||
break;
|
||||
case FavoriteType_Albums:
|
||||
if (song.album_id() <= 0) continue;
|
||||
id = QString::number(song.album_id());
|
||||
if (song.album_id().isEmpty()) continue;
|
||||
id = song.album_id();
|
||||
break;
|
||||
case FavoriteType_Songs:
|
||||
if (song.song_id() <= 0) continue;
|
||||
@@ -201,18 +201,18 @@ void TidalFavoriteRequest::RemoveFavorites(const FavoriteType type, const SongLi
|
||||
|
||||
if (songs.isEmpty()) return;
|
||||
|
||||
QList<int> ids;
|
||||
QMultiMap<int, Song> songs_map;
|
||||
QList<qint64> ids;
|
||||
QMultiMap<qint64, Song> songs_map;
|
||||
for (const Song &song : songs) {
|
||||
int id = -1;
|
||||
qint64 id = -1;
|
||||
switch (type) {
|
||||
case FavoriteType_Artists:
|
||||
if (song.artist_id() <= 0) continue;
|
||||
id = song.artist_id();
|
||||
break;
|
||||
case FavoriteType_Albums:
|
||||
if (song.album_id() <= 0) continue;
|
||||
id = song.album_id();
|
||||
if (song.album_id().isEmpty()) continue;
|
||||
id = song.album_id().toLongLong();
|
||||
break;
|
||||
case FavoriteType_Songs:
|
||||
if (song.song_id() <= 0) continue;
|
||||
|
||||
@@ -1033,13 +1033,13 @@ void TidalRequest::FlushAlbumCoverRequests() {
|
||||
QNetworkRequest req(request.url);
|
||||
QNetworkReply *reply = network_->get(req);
|
||||
album_cover_replies_ << reply;
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumCoverReceived(QNetworkReply*, const qint64, const QUrl&)), reply, request.album_id, request.url);
|
||||
NewClosure(reply, SIGNAL(finished()), this, SLOT(AlbumCoverReceived(QNetworkReply*, const QString&, const QUrl&)), reply, request.album_id, request.url);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const qint64 album_id, const QUrl &url) {
|
||||
void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const QString &album_id, const QUrl &url) {
|
||||
|
||||
if (album_cover_replies_.contains(reply)) {
|
||||
album_cover_replies_.removeAll(reply);
|
||||
@@ -1083,7 +1083,7 @@ void TidalRequest::AlbumCoverReceived(QNetworkReply *reply, const qint64 album_i
|
||||
|
||||
QDir dir;
|
||||
if (dir.mkpath(service_->CoverCacheDir())) {
|
||||
QString filename(service_->CoverCacheDir() + "/" + QString::number(album_id) + "-" + url.fileName());
|
||||
QString filename(service_->CoverCacheDir() + "/" + album_id + "-" + url.fileName());
|
||||
if (image.save(filename, "JPG")) {
|
||||
while (album_covers_requests_sent_.contains(album_id)) {
|
||||
Song *song = album_covers_requests_sent_.take(album_id);
|
||||
|
||||
@@ -85,7 +85,7 @@ class TidalRequest : public TidalBaseRequest {
|
||||
|
||||
void ArtistAlbumsReplyReceived(QNetworkReply *reply, const qint64 artist_id, const int offset_requested);
|
||||
void AlbumSongsReplyReceived(QNetworkReply *reply, const qint64 artist_id, const qint64 album_id, const int offset_requested, const QString &album_artist);
|
||||
void AlbumCoverReceived(QNetworkReply *reply, const qint64 album_id, const QUrl &url);
|
||||
void AlbumCoverReceived(QNetworkReply *reply, const QString &album_id, const QUrl &url);
|
||||
|
||||
private:
|
||||
typedef QPair<QString, QString> Param;
|
||||
@@ -101,7 +101,7 @@ class TidalRequest : public TidalBaseRequest {
|
||||
};
|
||||
struct AlbumCoverRequest {
|
||||
qint64 artist_id = 0;
|
||||
qint64 album_id = 0;
|
||||
QString album_id = 0;
|
||||
QUrl url;
|
||||
};
|
||||
|
||||
@@ -176,7 +176,7 @@ class TidalRequest : public TidalBaseRequest {
|
||||
|
||||
QList<int> artist_albums_requests_pending_;
|
||||
QHash<int, Request> album_songs_requests_pending_;
|
||||
QMultiMap<int, Song*> album_covers_requests_sent_;
|
||||
QMultiMap<QString, Song*> album_covers_requests_sent_;
|
||||
|
||||
int artists_requests_active_;
|
||||
int artists_total_;
|
||||
|
||||
@@ -204,8 +204,6 @@ void TidalService::ReloadSettings() {
|
||||
if (client_id_.isEmpty()) client_id_ = QString::fromUtf8(QByteArray::fromBase64(kClientIdB64));
|
||||
api_token_ = s.value("api_token").toString();
|
||||
if (api_token_.isEmpty()) api_token_ = QString::fromUtf8(QByteArray::fromBase64(kApiTokenB64));
|
||||
user_id_ = s.value("user_id", 0).toInt();
|
||||
country_code_ = s.value("country_code", "US").toString();
|
||||
|
||||
username_ = s.value("username").toString();
|
||||
QByteArray password = s.value("password").toByteArray();
|
||||
@@ -222,6 +220,8 @@ void TidalService::ReloadSettings() {
|
||||
cache_album_covers_ = s.value("cachealbumcovers", true).toBool();
|
||||
stream_url_method_ = static_cast<TidalSettingsPage::StreamUrlMethod>(s.value("streamurl").toInt());
|
||||
|
||||
user_id_ = s.value("user_id").toInt();
|
||||
country_code_ = s.value("country_code", "US").toString();
|
||||
access_token_ = s.value("access_token").toString();
|
||||
refresh_token_ = s.value("refresh_token").toString();
|
||||
session_id_ = s.value("session_id").toString();
|
||||
@@ -559,12 +559,12 @@ void TidalService::HandleAuthReply(QNetworkReply *reply) {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(TidalSettingsPage::kSettingsGroup);
|
||||
s.setValue("user_id", user_id_);
|
||||
s.setValue("session_id", session_id_);
|
||||
s.setValue("country_code", country_code_);
|
||||
s.remove("access_token");
|
||||
s.remove("refresh_token");
|
||||
s.remove("expiry_time");
|
||||
s.setValue("user_id", user_id_);
|
||||
s.setValue("session_id", session_id_);
|
||||
s.setValue("country_code", country_code_);
|
||||
s.endGroup();
|
||||
|
||||
qLog(Debug) << "Tidal: Login successful" << "user id" << user_id_ << "session id" << session_id_ << "country code" << country_code_;
|
||||
@@ -585,6 +585,8 @@ void TidalService::Logout() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(TidalSettingsPage::kSettingsGroup);
|
||||
s.remove("user_id");
|
||||
s.remove("country_code");
|
||||
s.remove("access_token");
|
||||
s.remove("session_id");
|
||||
s.remove("expiry_time");
|
||||
|
||||
Reference in New Issue
Block a user