diff --git a/Changelog b/Changelog index aae669d97..9cea3120d 100644 --- a/Changelog +++ b/Changelog @@ -22,7 +22,7 @@ Unreleased: * Added DSF and DSDIFF/DFF support * Fixed tagreader crash when saving tags to MP3 files * Added support for reading/writing lyrics to tags - * Fixed saving (APE) tags for WavPack files + * Fixed saving tags (APE) for WavPack files Version 0.2.1: diff --git a/src/core/song.cpp b/src/core/song.cpp index 8a6eb2d0d..66581443d 100644 --- a/src/core/song.cpp +++ b/src/core/song.cpp @@ -382,13 +382,12 @@ QString Song::TextForFiletype(FileType type) { case Song::Type_AIFF: return QObject::tr("AIFF"); case Song::Type_MPC: return QObject::tr("MPC"); case Song::Type_TrueAudio: return QObject::tr("TrueAudio"); - case Song::Type_CDDA: return QObject::tr("CDDA"); case Song::Type_DSF: return QObject::tr("DSF"); // .dsf case Song::Type_DSDIFF: return QObject::tr("DSDIFF"); // .dff + case Song::Type_CDDA: return QObject::tr("CDDA"); + case Song::Type_Stream: return QObject::tr("Stream"); case Song::Type_Unknown: - default: - return QObject::tr("Unknown"); - + default: return QObject::tr("Unknown"); } } @@ -406,6 +405,25 @@ bool Song::IsFileLossless() const { } } +Song::FileType Song::FiletypeByExtension(QString ext) { + + if (ext.toLower() == "wav" || ext.toLower() == "wave") return Song::Type_WAV; + else if (ext.toLower() == "flac") return Song::Type_FLAC; + else if (ext.toLower() == "wavpack" || ext.toLower() == "wv") return Song::Type_WavPack; + else if (ext.toLower() == "ogg" || ext.toLower() == "oga") return Song::Type_OggVorbis; + else if (ext.toLower() == "opus") return Song::Type_OggOpus; + else if (ext.toLower() == "speex" || ext.toLower() == "spx") return Song::Type_OggSpeex; + else if (ext.toLower() == "mp3") return Song::Type_MPEG; + else if (ext.toLower() == "mp4" || ext.toLower() == "m4a" || ext.toLower() == "aac") return Song::Type_MP4; + else if (ext.toLower() == "asf" || ext.toLower() == "wma") return Song::Type_ASF; + else if (ext.toLower() == "aiff" || ext.toLower() == "aif" || ext.toLower() == "aifc") return Song::Type_AIFF; + else if (ext.toLower() == "mpc" || ext.toLower() == "mp+" || ext.toLower() == "mpp") return Song::Type_MPC; + else if (ext.toLower() == "dsf") return Song::Type_DSF; + else if (ext.toLower() == "dsd" || ext.toLower() == "dff") return Song::Type_DSDIFF; + else return Song::Type_Unknown; + +} + int CompareSongsName(const Song &song1, const Song &song2) { return song1.PrettyTitleWithArtist().localeAwareCompare(song2.PrettyTitleWithArtist()) < 0; } diff --git a/src/core/song.h b/src/core/song.h index 81355f17e..e8b775af0 100644 --- a/src/core/song.h +++ b/src/core/song.h @@ -110,8 +110,8 @@ class Song { static QString TextForFiletype(FileType type); QString TextForFiletype() const { return TextForFiletype(filetype()); } - bool IsFileLossless() const; + static FileType FiletypeByExtension(QString ext); // Sort songs alphabetically using their pretty title static void SortSongsListAlphabetically(QList *songs); diff --git a/src/internet/internetplaylistitem.cpp b/src/internet/internetplaylistitem.cpp index 6ce03e3ce..51e955ad5 100644 --- a/src/internet/internetplaylistitem.cpp +++ b/src/internet/internetplaylistitem.cpp @@ -88,7 +88,7 @@ void InternetPlaylistItem::InitMetadata() { if (metadata_.title().isEmpty()) metadata_.set_title(metadata_.url().toString()); - metadata_.set_filetype(Song::Type_Stream); + if (metadata_.filetype() == Song::Type_Unknown) metadata_.set_filetype(Song::Type_Stream); metadata_.set_valid(true); } diff --git a/src/tidal/tidalsearch.cpp b/src/tidal/tidalsearch.cpp index b2d5bf7f8..ba0fb20a7 100644 --- a/src/tidal/tidalsearch.cpp +++ b/src/tidal/tidalsearch.cpp @@ -50,7 +50,7 @@ #include "settings/tidalsettingspage.h" const int TidalSearch::kDelayedSearchTimeoutMs = 200; -const int TidalSearch::kMaxResultsPerEmission = 1000; +const int TidalSearch::kMaxResultsPerEmission = 2000; const int TidalSearch::kArtHeight = 32; TidalSearch::TidalSearch(Application *app, QObject *parent) diff --git a/src/tidal/tidalsearchmodel.cpp b/src/tidal/tidalsearchmodel.cpp index c531bca75..edb62ad58 100644 --- a/src/tidal/tidalsearchmodel.cpp +++ b/src/tidal/tidalsearchmodel.cpp @@ -32,6 +32,7 @@ #include "core/mimedata.h" #include "core/iconloader.h" +#include "core/logging.h" #include "tidalsearch.h" #include "tidalsearchmodel.h" @@ -73,6 +74,7 @@ void TidalSearchModel::AddResults(const TidalSearch::ResultList &results) { item->setData(sort_index, Role_ProviderIndex); parent->appendRow(item); + } } diff --git a/src/tidal/tidalservice.cpp b/src/tidal/tidalservice.cpp index 46b33f942..49ad29277 100644 --- a/src/tidal/tidalservice.cpp +++ b/src/tidal/tidalservice.cpp @@ -517,7 +517,10 @@ void TidalService::SearchFinished(QNetworkReply *reply, int id) { else if (json_obj.contains("album")) { // This was a tracks search if (!fetchalbums_) { - ParseSong(0, value); + Song song = ParseSong(0, value); + requests_song_.insert(song.id(), song); + songs_requested_++; + GetStreamURL(0, song.id()); continue; } QJsonValue json_value_album = json_obj["album"]; @@ -624,7 +627,7 @@ void TidalService::GetAlbumFinished(QNetworkReply *reply, int search_id, int alb bool compilation = false; bool multidisc = false; Song first_song; - QList songs; + SongList songs; for (const QJsonValue &value : json_items) { Song song = ParseSong(album_id, value); if (!song.is_valid()) continue; @@ -641,6 +644,7 @@ void TidalService::GetAlbumFinished(QNetworkReply *reply, int search_id, int alb } requests_song_.insert(song.id(), song); songs_requested_++; + GetStreamURL(album_id, song.id()); } if (albums_requested_ <= albums_received_) { @@ -761,11 +765,8 @@ Song TidalService::ParseSong(const int album_id_requested, const QJsonValue &val cover = cover.replace("-", "/"); QUrl cover_url (QString("%1/images/%2/%3.jpg").arg(kResourcesUrl).arg(cover).arg(coversize_)); song.set_art_automatic(cover_url.toEncoded()); - song.set_valid(true); - GetStreamURL(album_id, song_id); - return song; } @@ -815,10 +816,15 @@ void TidalService::GetStreamURLFinished(QNetworkReply *reply, const int search_i } song.set_url(QUrl(json_obj["url"].toString())); + + QString codec = json_obj["codec"].toString().toLower(); + song.set_filetype(Song::FiletypeByExtension(codec)); + if (song.filetype() == Song::Type_Unknown) { + qLog(Debug) << "Tidal: Unknown codec" << codec; + song.set_filetype(Song::Type_Stream); + } + song.set_valid(true); - QString codec = json_obj["codec"].toString(); - if (codec == "AAC") song.set_filetype(Song::Type_MP4); - else qLog(Debug) << "Tidal codec" << codec; //qLog(Debug) << song.artist() << song.album() << song.title() << song.url() << song.filetype();