Show filetype for Tidal
This commit is contained in:
parent
28c685dcd8
commit
19b645d731
|
@ -22,7 +22,7 @@ Unreleased:
|
||||||
* Added DSF and DSDIFF/DFF support
|
* Added DSF and DSDIFF/DFF support
|
||||||
* Fixed tagreader crash when saving tags to MP3 files
|
* Fixed tagreader crash when saving tags to MP3 files
|
||||||
* Added support for reading/writing lyrics to tags
|
* 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:
|
Version 0.2.1:
|
||||||
|
|
||||||
|
|
|
@ -382,13 +382,12 @@ QString Song::TextForFiletype(FileType type) {
|
||||||
case Song::Type_AIFF: return QObject::tr("AIFF");
|
case Song::Type_AIFF: return QObject::tr("AIFF");
|
||||||
case Song::Type_MPC: return QObject::tr("MPC");
|
case Song::Type_MPC: return QObject::tr("MPC");
|
||||||
case Song::Type_TrueAudio: return QObject::tr("TrueAudio");
|
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_DSF: return QObject::tr("DSF"); // .dsf
|
||||||
case Song::Type_DSDIFF: return QObject::tr("DSDIFF"); // .dff
|
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:
|
case Song::Type_Unknown:
|
||||||
default:
|
default: return QObject::tr("Unknown");
|
||||||
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) {
|
int CompareSongsName(const Song &song1, const Song &song2) {
|
||||||
return song1.PrettyTitleWithArtist().localeAwareCompare(song2.PrettyTitleWithArtist()) < 0;
|
return song1.PrettyTitleWithArtist().localeAwareCompare(song2.PrettyTitleWithArtist()) < 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,8 +110,8 @@ class Song {
|
||||||
|
|
||||||
static QString TextForFiletype(FileType type);
|
static QString TextForFiletype(FileType type);
|
||||||
QString TextForFiletype() const { return TextForFiletype(filetype()); }
|
QString TextForFiletype() const { return TextForFiletype(filetype()); }
|
||||||
|
|
||||||
bool IsFileLossless() const;
|
bool IsFileLossless() const;
|
||||||
|
static FileType FiletypeByExtension(QString ext);
|
||||||
|
|
||||||
// Sort songs alphabetically using their pretty title
|
// Sort songs alphabetically using their pretty title
|
||||||
static void SortSongsListAlphabetically(QList<Song> *songs);
|
static void SortSongsListAlphabetically(QList<Song> *songs);
|
||||||
|
|
|
@ -88,7 +88,7 @@ void InternetPlaylistItem::InitMetadata() {
|
||||||
|
|
||||||
if (metadata_.title().isEmpty())
|
if (metadata_.title().isEmpty())
|
||||||
metadata_.set_title(metadata_.url().toString());
|
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);
|
metadata_.set_valid(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
#include "settings/tidalsettingspage.h"
|
#include "settings/tidalsettingspage.h"
|
||||||
|
|
||||||
const int TidalSearch::kDelayedSearchTimeoutMs = 200;
|
const int TidalSearch::kDelayedSearchTimeoutMs = 200;
|
||||||
const int TidalSearch::kMaxResultsPerEmission = 1000;
|
const int TidalSearch::kMaxResultsPerEmission = 2000;
|
||||||
const int TidalSearch::kArtHeight = 32;
|
const int TidalSearch::kArtHeight = 32;
|
||||||
|
|
||||||
TidalSearch::TidalSearch(Application *app, QObject *parent)
|
TidalSearch::TidalSearch(Application *app, QObject *parent)
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
#include "core/mimedata.h"
|
#include "core/mimedata.h"
|
||||||
#include "core/iconloader.h"
|
#include "core/iconloader.h"
|
||||||
|
#include "core/logging.h"
|
||||||
#include "tidalsearch.h"
|
#include "tidalsearch.h"
|
||||||
#include "tidalsearchmodel.h"
|
#include "tidalsearchmodel.h"
|
||||||
|
|
||||||
|
@ -73,6 +74,7 @@ void TidalSearchModel::AddResults(const TidalSearch::ResultList &results) {
|
||||||
item->setData(sort_index, Role_ProviderIndex);
|
item->setData(sort_index, Role_ProviderIndex);
|
||||||
|
|
||||||
parent->appendRow(item);
|
parent->appendRow(item);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -517,7 +517,10 @@ void TidalService::SearchFinished(QNetworkReply *reply, int id) {
|
||||||
else if (json_obj.contains("album")) {
|
else if (json_obj.contains("album")) {
|
||||||
// This was a tracks search
|
// This was a tracks search
|
||||||
if (!fetchalbums_) {
|
if (!fetchalbums_) {
|
||||||
ParseSong(0, value);
|
Song song = ParseSong(0, value);
|
||||||
|
requests_song_.insert(song.id(), song);
|
||||||
|
songs_requested_++;
|
||||||
|
GetStreamURL(0, song.id());
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QJsonValue json_value_album = json_obj["album"];
|
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 compilation = false;
|
||||||
bool multidisc = false;
|
bool multidisc = false;
|
||||||
Song first_song;
|
Song first_song;
|
||||||
QList<Song> songs;
|
SongList songs;
|
||||||
for (const QJsonValue &value : json_items) {
|
for (const QJsonValue &value : json_items) {
|
||||||
Song song = ParseSong(album_id, value);
|
Song song = ParseSong(album_id, value);
|
||||||
if (!song.is_valid()) continue;
|
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);
|
requests_song_.insert(song.id(), song);
|
||||||
songs_requested_++;
|
songs_requested_++;
|
||||||
|
GetStreamURL(album_id, song.id());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (albums_requested_ <= albums_received_) {
|
if (albums_requested_ <= albums_received_) {
|
||||||
|
@ -761,11 +765,8 @@ Song TidalService::ParseSong(const int album_id_requested, const QJsonValue &val
|
||||||
cover = cover.replace("-", "/");
|
cover = cover.replace("-", "/");
|
||||||
QUrl cover_url (QString("%1/images/%2/%3.jpg").arg(kResourcesUrl).arg(cover).arg(coversize_));
|
QUrl cover_url (QString("%1/images/%2/%3.jpg").arg(kResourcesUrl).arg(cover).arg(coversize_));
|
||||||
song.set_art_automatic(cover_url.toEncoded());
|
song.set_art_automatic(cover_url.toEncoded());
|
||||||
|
|
||||||
song.set_valid(true);
|
song.set_valid(true);
|
||||||
|
|
||||||
GetStreamURL(album_id, song_id);
|
|
||||||
|
|
||||||
return song;
|
return song;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -815,10 +816,15 @@ void TidalService::GetStreamURLFinished(QNetworkReply *reply, const int search_i
|
||||||
}
|
}
|
||||||
|
|
||||||
song.set_url(QUrl(json_obj["url"].toString()));
|
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);
|
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();
|
//qLog(Debug) << song.artist() << song.album() << song.title() << song.url() << song.filetype();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue