Use QString::compare with Qt::CaseInsensitive to reduce allocations
This commit is contained in:
parent
a87863229f
commit
68dbc29f2c
|
@ -401,7 +401,7 @@ void TagReaderTagLib::ReadFile(const QString &filename, spb::tagreader::SongMeta
|
|||
|
||||
if (compilation.isEmpty()) {
|
||||
// well, it wasn't set, but if the artist is VA assume it's a compilation
|
||||
if (QStringFromStdString(song->artist()).toLower() == "various artists" || QStringFromStdString(song->albumartist()).toLower() == "various artists") {
|
||||
if (QStringFromStdString(song->artist()).compare("various artists") == 0 || QStringFromStdString(song->albumartist()).compare("various artists") == 0) {
|
||||
song->set_compilation(true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -542,16 +542,16 @@ QString Song::DescriptionForSource(Source source) {
|
|||
|
||||
Song::Source Song::SourceFromText(const QString &source) {
|
||||
|
||||
if (source == "file") return Source_LocalFile;
|
||||
if (source == "collection") return Source_Collection;
|
||||
if (source == "cd") return Source_CDDA;
|
||||
if (source == "device") return Source_Device;
|
||||
if (source == "stream") return Source_Stream;
|
||||
if (source == "tidal") return Source_Tidal;
|
||||
if (source == "subsonic") return Source_Subsonic;
|
||||
if (source == "qobuz") return Source_Qobuz;
|
||||
if (source == "somafm") return Source_SomaFM;
|
||||
if (source == "radioparadise") return Source_RadioParadise;
|
||||
if (source.compare("file", Qt::CaseInsensitive) == 0) return Source_LocalFile;
|
||||
if (source.compare("collection", Qt::CaseInsensitive) == 0) return Source_Collection;
|
||||
if (source.compare("cd", Qt::CaseInsensitive) == 0) return Source_CDDA;
|
||||
if (source.compare("device", Qt::CaseInsensitive) == 0) return Source_Device;
|
||||
if (source.compare("stream", Qt::CaseInsensitive) == 0) return Source_Stream;
|
||||
if (source.compare("tidal", Qt::CaseInsensitive) == 0) return Source_Tidal;
|
||||
if (source.compare("subsonic", Qt::CaseInsensitive) == 0) return Source_Subsonic;
|
||||
if (source.compare("qobuz", Qt::CaseInsensitive) == 0) return Source_Qobuz;
|
||||
if (source.compare("somafm", Qt::CaseInsensitive) == 0) return Source_SomaFM;
|
||||
if (source.compare("radioparadise", Qt::CaseInsensitive) == 0) return Source_RadioParadise;
|
||||
|
||||
return Source_Unknown;
|
||||
|
||||
|
@ -678,61 +678,61 @@ bool Song::IsFileLossless() const {
|
|||
|
||||
Song::FileType Song::FiletypeByMimetype(const QString &mimetype) {
|
||||
|
||||
if (mimetype.toLower() == "audio/wav" || mimetype.toLower() == "audio/x-wav") return Song::FileType_WAV;
|
||||
else if (mimetype.toLower() == "audio/x-flac") return Song::FileType_FLAC;
|
||||
else if (mimetype.toLower() == "audio/x-wavpack") return Song::FileType_WavPack;
|
||||
else if (mimetype.toLower() == "audio/x-vorbis") return Song::FileType_OggVorbis;
|
||||
else if (mimetype.toLower() == "audio/x-opus") return Song::FileType_OggOpus;
|
||||
else if (mimetype.toLower() == "audio/x-speex") return Song::FileType_OggSpeex;
|
||||
if (mimetype.compare("audio/wav", Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-wav", Qt::CaseInsensitive) == 0) return Song::FileType_WAV;
|
||||
else if (mimetype.compare("audio/x-flac", Qt::CaseInsensitive) == 0) return Song::FileType_FLAC;
|
||||
else if (mimetype.compare("audio/x-wavpack", Qt::CaseInsensitive) == 0) return Song::FileType_WavPack;
|
||||
else if (mimetype.compare("audio/x-vorbis", Qt::CaseInsensitive) == 0) return Song::FileType_OggVorbis;
|
||||
else if (mimetype.compare("audio/x-opus", Qt::CaseInsensitive) == 0) return Song::FileType_OggOpus;
|
||||
else if (mimetype.compare("audio/x-speex", Qt::CaseInsensitive) == 0) return Song::FileType_OggSpeex;
|
||||
// Gstreamer returns audio/mpeg for both MP3 and MP4/AAC.
|
||||
// else if (mimetype.toLower() == "audio/mpeg") return Song::FileType_MPEG;
|
||||
else if (mimetype.toLower() == "audio/aac") return Song::FileType_MP4;
|
||||
else if (mimetype.toLower() == "audio/x-wma") return Song::FileType_ASF;
|
||||
else if (mimetype.toLower() == "audio/aiff" || mimetype.toLower() == "audio/x-aiff") return Song::FileType_AIFF;
|
||||
else if (mimetype.toLower() == "application/x-project") return Song::FileType_MPC;
|
||||
else if (mimetype.toLower() == "audio/x-dsf") return Song::FileType_DSF;
|
||||
else if (mimetype.toLower() == "audio/x-dsd") return Song::FileType_DSDIFF;
|
||||
else if (mimetype.toLower() == "audio/x-ape" || mimetype.toLower() == "application/x-ape" || mimetype.toLower() == "audio/x-ffmpeg-parsed-ape") return Song::FileType_APE;
|
||||
// else if (mimetype.compare("audio/mpeg", Qt::CaseInsensitive) == 0) return Song::FileType_MPEG;
|
||||
else if (mimetype.compare("audio/aac", Qt::CaseInsensitive) == 0) return Song::FileType_MP4;
|
||||
else if (mimetype.compare("audio/x-wma", Qt::CaseInsensitive) == 0) return Song::FileType_ASF;
|
||||
else if (mimetype.compare("audio/aiff", Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-aiff", Qt::CaseInsensitive) == 0) return Song::FileType_AIFF;
|
||||
else if (mimetype.compare("application/x-project", Qt::CaseInsensitive) == 0) return Song::FileType_MPC;
|
||||
else if (mimetype.compare("audio/x-dsf", Qt::CaseInsensitive) == 0) return Song::FileType_DSF;
|
||||
else if (mimetype.compare("audio/x-dsd", Qt::CaseInsensitive) == 0) return Song::FileType_DSDIFF;
|
||||
else if (mimetype.compare("audio/x-ape", Qt::CaseInsensitive) == 0 || mimetype.compare("application/x-ape", Qt::CaseInsensitive) == 0 || mimetype.compare("audio/x-ffmpeg-parsed-ape", Qt::CaseInsensitive) == 0) return Song::FileType_APE;
|
||||
else return Song::FileType_Unknown;
|
||||
|
||||
}
|
||||
|
||||
Song::FileType Song::FiletypeByDescription(const QString &text) {
|
||||
|
||||
if (text == "WAV") return Song::FileType_WAV;
|
||||
else if (text == "Free Lossless Audio Codec (FLAC)") return Song::FileType_FLAC;
|
||||
else if (text == "Wavpack") return Song::FileType_WavPack;
|
||||
else if (text == "Vorbis") return Song::FileType_OggVorbis;
|
||||
else if (text == "Opus") return Song::FileType_OggOpus;
|
||||
else if (text == "Speex") return Song::FileType_OggSpeex;
|
||||
else if (text == "MPEG-1 Layer 3 (MP3)") return Song::FileType_MPEG;
|
||||
else if (text == "MPEG-4 AAC") return Song::FileType_MP4;
|
||||
else if (text == "WMA") return Song::FileType_ASF;
|
||||
else if (text == "Audio Interchange File Format") return Song::FileType_AIFF;
|
||||
else if (text == "MPC") return Song::FileType_MPC;
|
||||
else if (text == "audio/x-dsf") return Song::FileType_DSF;
|
||||
else if (text == "audio/x-dsd") return Song::FileType_DSDIFF;
|
||||
else if (text == "audio/x-ffmpeg-parsed-ape") return Song::FileType_APE;
|
||||
if (text.compare("WAV", Qt::CaseInsensitive) == 0) return Song::FileType_WAV;
|
||||
else if (text.compare("Free Lossless Audio Codec (FLAC)", Qt::CaseInsensitive) == 0) return Song::FileType_FLAC;
|
||||
else if (text.compare("Wavpack", Qt::CaseInsensitive) == 0) return Song::FileType_WavPack;
|
||||
else if (text.compare("Vorbis", Qt::CaseInsensitive) == 0) return Song::FileType_OggVorbis;
|
||||
else if (text.compare("Opus", Qt::CaseInsensitive) == 0) return Song::FileType_OggOpus;
|
||||
else if (text.compare("Speex", Qt::CaseInsensitive) == 0) return Song::FileType_OggSpeex;
|
||||
else if (text.compare("MPEG-1 Layer 3 (MP3)", Qt::CaseInsensitive) == 0) return Song::FileType_MPEG;
|
||||
else if (text.compare("MPEG-4 AAC", Qt::CaseInsensitive) == 0) return Song::FileType_MP4;
|
||||
else if (text.compare("WMA", Qt::CaseInsensitive) == 0) return Song::FileType_ASF;
|
||||
else if (text.compare("Audio Interchange File Format", Qt::CaseInsensitive) == 0) return Song::FileType_AIFF;
|
||||
else if (text.compare("MPC", Qt::CaseInsensitive) == 0) return Song::FileType_MPC;
|
||||
else if (text.compare("audio/x-dsf", Qt::CaseInsensitive) == 0) return Song::FileType_DSF;
|
||||
else if (text.compare("audio/x-dsd", Qt::CaseInsensitive) == 0) return Song::FileType_DSDIFF;
|
||||
else if (text.compare("audio/x-ffmpeg-parsed-ape", Qt::CaseInsensitive) == 0) return Song::FileType_APE;
|
||||
else return Song::FileType_Unknown;
|
||||
|
||||
}
|
||||
|
||||
Song::FileType Song::FiletypeByExtension(const QString &ext) {
|
||||
|
||||
if (ext.toLower() == "wav" || ext.toLower() == "wave") return Song::FileType_WAV;
|
||||
else if (ext.toLower() == "flac") return Song::FileType_FLAC;
|
||||
else if (ext.toLower() == "wavpack" || ext.toLower() == "wv") return Song::FileType_WavPack;
|
||||
else if (ext.toLower() == "ogg" || ext.toLower() == "oga") return Song::FileType_OggVorbis;
|
||||
else if (ext.toLower() == "opus") return Song::FileType_OggOpus;
|
||||
else if (ext.toLower() == "speex" || ext.toLower() == "spx") return Song::FileType_OggSpeex;
|
||||
else if (ext.toLower() == "mp3") return Song::FileType_MPEG;
|
||||
else if (ext.toLower() == "mp4" || ext.toLower() == "m4a" || ext.toLower() == "aac") return Song::FileType_MP4;
|
||||
else if (ext.toLower() == "asf" || ext.toLower() == "wma") return Song::FileType_ASF;
|
||||
else if (ext.toLower() == "aiff" || ext.toLower() == "aif" || ext.toLower() == "aifc") return Song::FileType_AIFF;
|
||||
else if (ext.toLower() == "mpc" || ext.toLower() == "mp+" || ext.toLower() == "mpp") return Song::FileType_MPC;
|
||||
else if (ext.toLower() == "dsf") return Song::FileType_DSF;
|
||||
else if (ext.toLower() == "dsd" || ext.toLower() == "dff") return Song::FileType_DSDIFF;
|
||||
else if (ext.toLower() == "ape") return Song::FileType_APE;
|
||||
if (ext.compare("wav", Qt::CaseInsensitive) == 0 || ext.compare("wave", Qt::CaseInsensitive) == 0) return Song::FileType_WAV;
|
||||
else if (ext.compare("flac", Qt::CaseInsensitive) == 0) return Song::FileType_FLAC;
|
||||
else if (ext.compare("wavpack", Qt::CaseInsensitive) == 0 || ext.compare("wv", Qt::CaseInsensitive) == 0) return Song::FileType_WavPack;
|
||||
else if (ext.compare("ogg", Qt::CaseInsensitive) == 0 || ext.compare("oga", Qt::CaseInsensitive) == 0) return Song::FileType_OggVorbis;
|
||||
else if (ext.compare("opus", Qt::CaseInsensitive) == 0) return Song::FileType_OggOpus;
|
||||
else if (ext.compare("speex", Qt::CaseInsensitive) == 0 || ext.compare("spx", Qt::CaseInsensitive) == 0) return Song::FileType_OggSpeex;
|
||||
else if (ext.compare("mp3", Qt::CaseInsensitive) == 0) return Song::FileType_MPEG;
|
||||
else if (ext.compare("mp4", Qt::CaseInsensitive) == 0 || ext.compare("m4a", Qt::CaseInsensitive) == 0 || ext.compare("aac", Qt::CaseInsensitive) == 0) return Song::FileType_MP4;
|
||||
else if (ext.compare("asf", Qt::CaseInsensitive) == 0 || ext.compare("wma", Qt::CaseInsensitive) == 0) return Song::FileType_ASF;
|
||||
else if (ext.compare("aiff", Qt::CaseInsensitive) == 0 || ext.compare("aif", Qt::CaseInsensitive) == 0 || ext.compare("aifc", Qt::CaseInsensitive) == 0) return Song::FileType_AIFF;
|
||||
else if (ext.compare("mpc", Qt::CaseInsensitive) == 0 || ext.compare("mp+", Qt::CaseInsensitive) == 0 || ext.compare("mpp", Qt::CaseInsensitive) == 0) return Song::FileType_MPC;
|
||||
else if (ext.compare("dsf", Qt::CaseInsensitive) == 0) return Song::FileType_DSF;
|
||||
else if (ext.compare("dsd", Qt::CaseInsensitive) == 0 || ext.compare("dff", Qt::CaseInsensitive) == 0) return Song::FileType_DSDIFF;
|
||||
else if (ext.compare("ape", Qt::CaseInsensitive) == 0) return Song::FileType_APE;
|
||||
else return Song::FileType_Unknown;
|
||||
|
||||
}
|
||||
|
|
|
@ -249,7 +249,7 @@ void AlbumCoverChoiceController::SaveCoverToFileManual(const Song &song, const A
|
|||
fileinfo.setFile(save_filename);
|
||||
}
|
||||
|
||||
if (result.is_jpeg() && fileinfo.completeSuffix().toLower() == "jpg") {
|
||||
if (result.is_jpeg() && fileinfo.completeSuffix().compare("jpg") == 0) {
|
||||
QFile file(save_filename);
|
||||
if (file.open(QIODevice::WriteOnly)) {
|
||||
file.write(result.image_data);
|
||||
|
|
|
@ -86,7 +86,7 @@ void AlbumCoverFetcherSearch::TerminateSearch() {
|
|||
void AlbumCoverFetcherSearch::Start(CoverProviders *cover_providers) {
|
||||
|
||||
// Ignore Radio Paradise "commercial" break.
|
||||
if (request_.artist.toLower() == "commercial-free" && request_.title.toLower() == "listener-supported") {
|
||||
if (request_.artist.compare("commercial-free", Qt::CaseInsensitive) == 0 && request_.title.compare("listener-supported", Qt::CaseInsensitive) == 0) {
|
||||
TerminateSearch();
|
||||
return;
|
||||
}
|
||||
|
@ -147,22 +147,22 @@ void AlbumCoverFetcherSearch::ProviderSearchResults(CoverProvider *provider, con
|
|||
results_copy[i].provider = provider->name();
|
||||
results_copy[i].score_provider = provider->quality();
|
||||
|
||||
QString request_artist = request_.artist.toLower();
|
||||
QString request_album = request_.album.toLower();
|
||||
QString result_artist = results_copy[i].artist.toLower();
|
||||
QString result_album = results_copy[i].album.toLower();
|
||||
const QString &request_artist = request_.artist;
|
||||
const QString &request_album = request_.album;
|
||||
const QString &result_artist = results_copy[i].artist;
|
||||
const QString &result_album = results_copy[i].album;
|
||||
|
||||
if (result_artist == request_artist) {
|
||||
if (result_artist.compare(request_artist, Qt::CaseInsensitive) == 0) {
|
||||
results_copy[i].score_match += 0.5;
|
||||
}
|
||||
if (result_album == request_album) {
|
||||
if (result_album.compare(request_album, Qt::CaseInsensitive) == 0) {
|
||||
results_copy[i].score_match += 0.5;
|
||||
}
|
||||
if (result_artist != request_artist && result_album != request_album) {
|
||||
if (result_artist.compare(request_artist, Qt::CaseInsensitive) != 0 && result_album.compare(request_album, Qt::CaseInsensitive) != 0) {
|
||||
results_copy[i].score_match -= 1.5;
|
||||
}
|
||||
|
||||
if (request_album.isEmpty() && result_artist != request_artist) {
|
||||
if (request_album.isEmpty() && result_artist.compare(request_artist, Qt::CaseInsensitive) != 0) {
|
||||
results_copy[i].score_match -= 1;
|
||||
}
|
||||
|
||||
|
@ -170,51 +170,51 @@ void AlbumCoverFetcherSearch::ProviderSearchResults(CoverProvider *provider, con
|
|||
// This is done since we can't match the album titles, and we want to prevent compilation or live albums from being picked before studio albums for streams.
|
||||
// TODO: Make these regular expressions.
|
||||
if (request_album.isEmpty() && (
|
||||
result_album.contains("hits") ||
|
||||
result_album.contains("greatest") ||
|
||||
result_album.contains("best") ||
|
||||
result_album.contains("collection") ||
|
||||
result_album.contains("classics") ||
|
||||
result_album.contains("singles") ||
|
||||
result_album.contains("bootleg") ||
|
||||
result_album.contains("live") ||
|
||||
result_album.contains("concert") ||
|
||||
result_album.contains("essential") ||
|
||||
result_album.contains("ultimate") ||
|
||||
result_album.contains("karaoke") ||
|
||||
result_album.contains("mixtape") ||
|
||||
result_album.contains("country rock") ||
|
||||
result_album.contains("indie folk") ||
|
||||
result_album.contains("soft rock") ||
|
||||
result_album.contains("folk music") ||
|
||||
result_album.contains("60's rock") ||
|
||||
result_album.contains("60's romance") ||
|
||||
result_album.contains("60s music") ||
|
||||
result_album.contains("late 60s") ||
|
||||
result_album.contains("the 60s") ||
|
||||
result_album.contains("folk and blues") ||
|
||||
result_album.contains("60 from the 60's") ||
|
||||
result_album.contains("classic psychedelic") ||
|
||||
result_album.contains("playlist: acoustic") ||
|
||||
result_album.contains("90's rnb playlist") ||
|
||||
result_album.contains("rock 80s") ||
|
||||
result_album.contains("classic 80s") ||
|
||||
result_album.contains("rock anthems") ||
|
||||
result_album.contains("rock songs") ||
|
||||
result_album.contains("rock 2019") ||
|
||||
result_album.contains("guitar anthems") ||
|
||||
result_album.contains("driving anthems") ||
|
||||
result_album.contains("traffic jam jams") ||
|
||||
result_album.contains("perfect background music") ||
|
||||
result_album.contains("70's gold") ||
|
||||
result_album.contains("rockfluence") ||
|
||||
result_album.contains("acoustic dinner accompaniment") ||
|
||||
result_album.contains("complete studio albums") ||
|
||||
result_album.contains("mellow rock")
|
||||
result_album.contains("hits", Qt::CaseInsensitive) ||
|
||||
result_album.contains("greatest", Qt::CaseInsensitive) ||
|
||||
result_album.contains("best", Qt::CaseInsensitive) ||
|
||||
result_album.contains("collection", Qt::CaseInsensitive) ||
|
||||
result_album.contains("classics", Qt::CaseInsensitive) ||
|
||||
result_album.contains("singles", Qt::CaseInsensitive) ||
|
||||
result_album.contains("bootleg", Qt::CaseInsensitive) ||
|
||||
result_album.contains("live", Qt::CaseInsensitive) ||
|
||||
result_album.contains("concert", Qt::CaseInsensitive) ||
|
||||
result_album.contains("essential", Qt::CaseInsensitive) ||
|
||||
result_album.contains("ultimate", Qt::CaseInsensitive) ||
|
||||
result_album.contains("karaoke", Qt::CaseInsensitive) ||
|
||||
result_album.contains("mixtape", Qt::CaseInsensitive) ||
|
||||
result_album.contains("country rock", Qt::CaseInsensitive) ||
|
||||
result_album.contains("indie folk", Qt::CaseInsensitive) ||
|
||||
result_album.contains("soft rock", Qt::CaseInsensitive) ||
|
||||
result_album.contains("folk music", Qt::CaseInsensitive) ||
|
||||
result_album.contains("60's rock", Qt::CaseInsensitive) ||
|
||||
result_album.contains("60's romance", Qt::CaseInsensitive) ||
|
||||
result_album.contains("60s music", Qt::CaseInsensitive) ||
|
||||
result_album.contains("late 60s", Qt::CaseInsensitive) ||
|
||||
result_album.contains("the 60s", Qt::CaseInsensitive) ||
|
||||
result_album.contains("folk and blues", Qt::CaseInsensitive) ||
|
||||
result_album.contains("60 from the 60's", Qt::CaseInsensitive) ||
|
||||
result_album.contains("classic psychedelic", Qt::CaseInsensitive) ||
|
||||
result_album.contains("playlist: acoustic", Qt::CaseInsensitive) ||
|
||||
result_album.contains("90's rnb playlist", Qt::CaseInsensitive) ||
|
||||
result_album.contains("rock 80s", Qt::CaseInsensitive) ||
|
||||
result_album.contains("classic 80s", Qt::CaseInsensitive) ||
|
||||
result_album.contains("rock anthems", Qt::CaseInsensitive) ||
|
||||
result_album.contains("rock songs", Qt::CaseInsensitive) ||
|
||||
result_album.contains("rock 2019", Qt::CaseInsensitive) ||
|
||||
result_album.contains("guitar anthems", Qt::CaseInsensitive) ||
|
||||
result_album.contains("driving anthems", Qt::CaseInsensitive) ||
|
||||
result_album.contains("traffic jam jams", Qt::CaseInsensitive) ||
|
||||
result_album.contains("perfect background music", Qt::CaseInsensitive) ||
|
||||
result_album.contains("70's gold", Qt::CaseInsensitive) ||
|
||||
result_album.contains("rockfluence", Qt::CaseInsensitive) ||
|
||||
result_album.contains("acoustic dinner accompaniment", Qt::CaseInsensitive) ||
|
||||
result_album.contains("complete studio albums", Qt::CaseInsensitive) ||
|
||||
result_album.contains("mellow rock", Qt::CaseInsensitive)
|
||||
)) {
|
||||
results_copy[i].score_match -= 1;
|
||||
}
|
||||
else if (request_album.isEmpty() && result_album.contains("soundtrack")) {
|
||||
else if (request_album.isEmpty() && result_album.contains("soundtrack", Qt::CaseInsensitive)) {
|
||||
results_copy[i].score_match -= 0.5;
|
||||
}
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ void DiscogsCoverProvider::HandleSearchReply(QNetworkReply *reply, const int id)
|
|||
if (title_splitted.count() == 2) {
|
||||
QString artist = title_splitted.first();
|
||||
title = title_splitted.last();
|
||||
if (artist.toLower() != search->artist.toLower() && title.toLower() != search->album.toLower()) continue;
|
||||
if (artist.compare(search->artist, Qt::CaseInsensitive) != 0 && title.compare(search->album, Qt::CaseInsensitive) != 0) continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,19 +62,19 @@ bool MusixmatchCoverProvider::StartSearch(const QString &artist, const QString &
|
|||
QString artist_stripped = artist;
|
||||
QString album_stripped = album;
|
||||
|
||||
artist_stripped = artist_stripped.replace('/', '-');
|
||||
artist_stripped = artist_stripped.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption));
|
||||
artist_stripped = artist_stripped.simplified();
|
||||
artist_stripped = artist_stripped.replace(' ', '-');
|
||||
artist_stripped = artist_stripped.replace(QRegularExpression("(-)\\1+"), "-");
|
||||
artist_stripped = artist_stripped.toLower();
|
||||
artist_stripped = artist_stripped.replace('/', '-')
|
||||
.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption))
|
||||
.simplified()
|
||||
.replace(' ', '-')
|
||||
.replace(QRegularExpression("(-)\\1+"), "-")
|
||||
.toLower();
|
||||
|
||||
album_stripped = album_stripped.replace('/', '-');
|
||||
album_stripped = album_stripped.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption));
|
||||
album_stripped = album_stripped.simplified();
|
||||
album_stripped = album_stripped.replace(' ', '-').toLower();
|
||||
album_stripped = album_stripped.replace(QRegularExpression("(-)\\1+"), "-");
|
||||
album_stripped = album_stripped.toLower();
|
||||
album_stripped = album_stripped.replace('/', '-')
|
||||
.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption))
|
||||
.simplified()
|
||||
.replace(' ', '-')
|
||||
.replace(QRegularExpression("(-)\\1+"), "-")
|
||||
.toLower();
|
||||
|
||||
if (artist_stripped.isEmpty() || album_stripped.isEmpty()) return false;
|
||||
|
||||
|
@ -201,7 +201,7 @@ void MusixmatchCoverProvider::HandleSearchReply(QNetworkReply *reply, const int
|
|||
result.artist = obj_album["artistName"].toString();
|
||||
result.album = obj_album["name"].toString();
|
||||
|
||||
if (artist.toLower() != result.artist.toLower() && album.toLower() != result.album.toLower()) {
|
||||
if (result.artist.compare(artist, Qt::CaseInsensitive) != 0 && result.album.compare(album, Qt::CaseInsensitive) != 0) {
|
||||
emit SearchFinished(id, results);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ void AuddLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64 i
|
|||
LyricsSearchResult result;
|
||||
result.artist = json_obj["artist"].toString();
|
||||
result.title = json_obj["title"].toString();
|
||||
if (result.artist.toLower() != artist.toLower() && result.title.toLower() != title.toLower()) continue;
|
||||
if (result.artist.compare(artist, Qt::CaseInsensitive) != 0 && result.title.compare(title, Qt::CaseInsensitive) != 0) continue;
|
||||
result.lyrics = json_obj["lyrics"].toString();
|
||||
if (result.lyrics.isEmpty() || result.lyrics.length() > kMaxLength || result.lyrics == "error") continue;
|
||||
result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics);
|
||||
|
|
|
@ -126,7 +126,7 @@ void ChartLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64
|
|||
}
|
||||
else if (type == QXmlStreamReader::EndElement) {
|
||||
if (name == "GetLyricResult") {
|
||||
if (!result.artist.isEmpty() && !result.title.isEmpty() && !result.lyrics.isEmpty() && (result.artist.toLower() == artist.toLower() || result.title.toLower() == title.toLower())) {
|
||||
if (!result.artist.isEmpty() && !result.title.isEmpty() && !result.lyrics.isEmpty() && (result.artist.compare(artist, Qt::CaseInsensitive) == 0 || result.title.compare(title, Qt::CaseInsensitive) == 0)) {
|
||||
result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics);
|
||||
results << result;
|
||||
}
|
||||
|
|
|
@ -432,7 +432,7 @@ void GeniusLyricsProvider::HandleSearchReply(QNetworkReply *reply, const quint64
|
|||
QString title = obj_result["title"].toString();
|
||||
|
||||
// Ignore results where both the artist and title don't match.
|
||||
if (artist.toLower() != search->artist.toLower() && title.toLower() != search->title.toLower()) continue;
|
||||
if (artist.compare(search->artist, Qt::CaseInsensitive) != 0 && title.compare(search->title, Qt::CaseInsensitive) != 0) continue;
|
||||
|
||||
QUrl url(obj_result["url"].toString());
|
||||
if (!url.isValid()) continue;
|
||||
|
|
|
@ -58,7 +58,7 @@ void LyricsFetcherSearch::TerminateSearch() {
|
|||
void LyricsFetcherSearch::Start(LyricsProviders *lyrics_providers) {
|
||||
|
||||
// Ignore Radio Paradise "commercial" break.
|
||||
if (request_.artist.toLower() == "commercial-free" && request_.title.toLower() == "listener-supported") {
|
||||
if (request_.artist.compare("commercial-free", Qt::CaseInsensitive) == 0 && request_.title.compare("listener-supported", Qt::CaseInsensitive) == 0) {
|
||||
TerminateSearch();
|
||||
return;
|
||||
}
|
||||
|
@ -88,16 +88,16 @@ void LyricsFetcherSearch::ProviderSearchFinished(const quint64 id, const LyricsS
|
|||
for (int i = 0 ; i < results_copy.count() ; ++i) {
|
||||
results_copy[i].provider = provider->name();
|
||||
results_copy[i].score = 0.0;
|
||||
if (results_copy[i].artist.toLower() == request_.artist.toLower()) {
|
||||
if (results_copy[i].artist.compare(request_.artist, Qt::CaseInsensitive) == 0) {
|
||||
results_copy[i].score += 0.5;
|
||||
}
|
||||
if (results_copy[i].album.toLower() == request_.album.toLower()) {
|
||||
if (results_copy[i].album.compare(request_.album, Qt::CaseInsensitive) == 0) {
|
||||
results_copy[i].score += 0.5;
|
||||
}
|
||||
if (results_copy[i].title.toLower() == request_.title.toLower()) {
|
||||
if (results_copy[i].title.compare(request_.title, Qt::CaseInsensitive) == 0) {
|
||||
results_copy[i].score += 0.5;
|
||||
}
|
||||
if (results_copy[i].artist.toLower() != request_.artist.toLower() && results_copy[i].title.toLower() != request_.title.toLower()) {
|
||||
if (results_copy[i].artist.compare(request_.artist, Qt::CaseInsensitive) != 0 && results_copy[i].title.compare(request_.title, Qt::CaseInsensitive) != 0) {
|
||||
results_copy[i].score -= 1.5;
|
||||
}
|
||||
if (results_copy[i].lyrics.length() > kGoodLyricsLength) results_copy[i].score += 1.0;
|
||||
|
|
|
@ -58,19 +58,19 @@ bool MusixmatchLyricsProvider::StartSearch(const QString &artist, const QString
|
|||
QString artist_stripped = artist;
|
||||
QString title_stripped = title;
|
||||
|
||||
artist_stripped = artist_stripped.replace('/', '-');
|
||||
artist_stripped = artist_stripped.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption));
|
||||
artist_stripped = artist_stripped.simplified();
|
||||
artist_stripped = artist_stripped.replace(' ', '-');
|
||||
artist_stripped = artist_stripped.replace(QRegularExpression("(-)\\1+"), "-");
|
||||
artist_stripped = artist_stripped.toLower();
|
||||
artist_stripped = artist_stripped.replace('/', '-')
|
||||
.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption))
|
||||
.simplified()
|
||||
.replace(' ', '-')
|
||||
.replace(QRegularExpression("(-)\\1+"), "-")
|
||||
.toLower();
|
||||
|
||||
title_stripped = title_stripped.replace('/', '-');
|
||||
title_stripped = title_stripped.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption));
|
||||
title_stripped = title_stripped.simplified();
|
||||
title_stripped = title_stripped.replace(' ', '-').toLower();
|
||||
title_stripped = title_stripped.replace(QRegularExpression("(-)\\1+"), "-");
|
||||
title_stripped = title_stripped.toLower();
|
||||
title_stripped = title_stripped.replace('/', '-')
|
||||
.remove(QRegularExpression("[^\\w0-9\\- ]", QRegularExpression::UseUnicodePropertiesOption))
|
||||
.simplified()
|
||||
.replace(' ', '-')
|
||||
.replace(QRegularExpression("(-)\\1+"), "-")
|
||||
.toLower();
|
||||
|
||||
if (artist_stripped.isEmpty() || title_stripped.isEmpty()) return false;
|
||||
|
||||
|
@ -199,7 +199,7 @@ void MusixmatchLyricsProvider::HandleSearchReply(QNetworkReply *reply, const qui
|
|||
result.title = obj_track["name"].toString();
|
||||
result.lyrics = obj_lyrics["body"].toString();
|
||||
|
||||
if (!result.lyrics.isEmpty() && (artist.toLower() == result.artist.toLower() || title.toLower() == result.title.toLower())) {
|
||||
if (!result.lyrics.isEmpty() && (result.artist.compare(artist, Qt::CaseInsensitive) == 0 || result.title.compare(title, Qt::CaseInsensitive) == 0)) {
|
||||
result.lyrics = Utilities::DecodeHtmlEntities(result.lyrics);
|
||||
results.append(result);
|
||||
}
|
||||
|
|
|
@ -91,40 +91,40 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
|
|||
if (splitted.size() < 2) {
|
||||
continue;
|
||||
}
|
||||
QString line_name = splitted[0].toLower();
|
||||
QString line_value = splitted[1];
|
||||
QString &line_name = splitted[0];
|
||||
QString &line_value = splitted[1];
|
||||
|
||||
if (line_name == kPerformer) {
|
||||
if (line_name.compare(kPerformer, Qt::CaseInsensitive) == 0) {
|
||||
album_artist = line_value;
|
||||
}
|
||||
else if (line_name == kTitle) {
|
||||
else if (line_name.compare(kTitle, Qt::CaseInsensitive) == 0) {
|
||||
album = line_value;
|
||||
}
|
||||
else if (line_name == kSongWriter) {
|
||||
else if (line_name.compare(kSongWriter, Qt::CaseInsensitive) == 0) {
|
||||
album_composer = line_value;
|
||||
}
|
||||
else if (line_name == kFile) {
|
||||
else if (line_name.compare(kFile, Qt::CaseInsensitive) == 0) {
|
||||
file = QDir::isAbsolutePath(line_value) ? line_value : dir.absoluteFilePath(line_value);
|
||||
if (splitted.size() > 2) {
|
||||
file_type = splitted[2];
|
||||
}
|
||||
}
|
||||
else if (line_name == kRem) {
|
||||
else if (line_name.compare(kRem, Qt::CaseInsensitive) == 0) {
|
||||
if (splitted.size() < 3) {
|
||||
break;
|
||||
}
|
||||
if (line_value.toLower() == kGenre) {
|
||||
if (line_value.compare(kGenre, Qt::CaseInsensitive) == 0) {
|
||||
album_genre = splitted[2];
|
||||
}
|
||||
else if (line_value.toLower() == kDate) {
|
||||
else if (line_value.compare(kDate, Qt::CaseInsensitive) == 0) {
|
||||
album_date = splitted[2];
|
||||
}
|
||||
else if (line_value.toLower() == kDisc) {
|
||||
else if (line_value.compare(kDisc, Qt::CaseInsensitive) == 0) {
|
||||
disc = splitted[2];
|
||||
}
|
||||
}
|
||||
// end of the header -> go into the track mode
|
||||
else if (line_name == kTrack) {
|
||||
else if (line_name.compare(kTrack, Qt::CaseInsensitive) == 0) {
|
||||
files++;
|
||||
break;
|
||||
}
|
||||
|
@ -156,15 +156,15 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
|
|||
continue;
|
||||
}
|
||||
|
||||
QString line_name = splitted[0].toLower();
|
||||
QString line_value = splitted[1];
|
||||
QString &line_name = splitted[0];
|
||||
QString &line_value = splitted[1];
|
||||
QString line_additional = splitted.size() > 2 ? splitted[2].toLower() : "";
|
||||
|
||||
if (line_name == kTrack) {
|
||||
if (line_name.compare(kTrack, Qt::CaseInsensitive) == 0) {
|
||||
|
||||
// the beginning of another track's definition - we're saving the current one for later (if it's valid of course)
|
||||
// please note that the same code is repeated just after this 'do-while' loop
|
||||
if (valid_file && !index.isEmpty() && (track_type.isEmpty() || track_type == kAudioTrackType)) {
|
||||
if (valid_file && !index.isEmpty() && (track_type.isEmpty() || track_type.compare(kAudioTrackType, Qt::CaseInsensitive) == 0)) {
|
||||
entries.append(CueEntry(file, index, title, artist, album_artist, album, composer, album_composer, (genre.isEmpty() ? album_genre : genre), (date.isEmpty() ? album_date : date), disc));
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
|
|||
}
|
||||
|
||||
}
|
||||
else if (line_name == kIndex) {
|
||||
else if (line_name.compare(kIndex, Qt::CaseInsensitive) == 0) {
|
||||
|
||||
// We need the index's position field
|
||||
if (!line_additional.isEmpty()) {
|
||||
|
@ -188,28 +188,28 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (line_name == kTitle) {
|
||||
else if (line_name.compare(kTitle, Qt::CaseInsensitive) == 0) {
|
||||
title = line_value;
|
||||
}
|
||||
else if (line_name == kDate) {
|
||||
else if (line_name.compare(kDate, Qt::CaseInsensitive) == 0) {
|
||||
date = line_value;
|
||||
}
|
||||
else if (line_name == kPerformer) {
|
||||
else if (line_name.compare(kPerformer, Qt::CaseInsensitive) == 0) {
|
||||
artist = line_value;
|
||||
}
|
||||
else if (line_name == kSongWriter) {
|
||||
else if (line_name.compare(kSongWriter, Qt::CaseInsensitive) == 0) {
|
||||
composer = line_value;
|
||||
// End of track's for the current file -> parse next one
|
||||
}
|
||||
else if (line_name == kRem && splitted.size() >= 3) {
|
||||
if (line_value.toLower() == kGenre) {
|
||||
else if (line_name.compare(kRem, Qt::CaseInsensitive) == 0 && splitted.size() >= 3) {
|
||||
if (line_value.compare(kGenre, Qt::CaseInsensitive) == 0) {
|
||||
genre = splitted[2];
|
||||
}
|
||||
else if (line_value.toLower() == kDate) {
|
||||
else if (line_value.compare(kDate, Qt::CaseInsensitive) == 0) {
|
||||
date = splitted[2];
|
||||
}
|
||||
}
|
||||
else if (line_name == kFile) {
|
||||
else if (line_name.compare(kFile, Qt::CaseInsensitive) == 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -217,7 +217,7 @@ SongList CueParser::Load(QIODevice *device, const QString &playlist_path, const
|
|||
} while (!(line = text_stream.readLine()).isNull());
|
||||
|
||||
// We didn't add the last song yet...
|
||||
if (valid_file && !index.isEmpty() && (track_type.isEmpty() || track_type == kAudioTrackType)) {
|
||||
if (valid_file && !index.isEmpty() && (track_type.isEmpty() || track_type.compare(kAudioTrackType, Qt::CaseInsensitive) == 0)) {
|
||||
entries.append(CueEntry(file, index, title, artist, album_artist, album, composer, album_composer, (genre.isEmpty() ? album_genre : genre), (date.isEmpty() ? album_date : date), disc));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -434,7 +434,7 @@ void ListenBrainzScrobbler::UpdateNowPlaying(const Song &song) {
|
|||
title = title.remove(Song::kTitleRemoveMisc);
|
||||
|
||||
QJsonObject object_track_metadata;
|
||||
if (song.albumartist().isEmpty() || song.albumartist().toLower() == Song::kVariousArtists) {
|
||||
if (song.albumartist().isEmpty() || song.albumartist().compare(Song::kVariousArtists, Qt::CaseInsensitive) == 0) {
|
||||
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(song.artist()));
|
||||
}
|
||||
else {
|
||||
|
@ -492,7 +492,7 @@ void ListenBrainzScrobbler::UpdateNowPlayingRequestFinished(QNetworkReply *reply
|
|||
}
|
||||
|
||||
QString status = json_obj["status"].toString();
|
||||
if (status.toLower() != "ok") {
|
||||
if (status.compare("ok", Qt::CaseInsensitive) != 0) {
|
||||
Error(status);
|
||||
}
|
||||
|
||||
|
@ -562,13 +562,16 @@ void ListenBrainzScrobbler::Submit() {
|
|||
QJsonObject object_listen;
|
||||
object_listen.insert("listened_at", QJsonValue::fromVariant(item->timestamp_));
|
||||
QJsonObject object_track_metadata;
|
||||
if (item->albumartist_.isEmpty() || item->albumartist_.toLower() == Song::kVariousArtists)
|
||||
if (item->albumartist_.isEmpty() || item->albumartist_.compare(Song::kVariousArtists, Qt::CaseInsensitive) == 0) {
|
||||
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(item->artist_));
|
||||
else
|
||||
}
|
||||
else {
|
||||
object_track_metadata.insert("artist_name", QJsonValue::fromVariant(item->albumartist_));
|
||||
}
|
||||
|
||||
if (!item->album_.isEmpty())
|
||||
if (!item->album_.isEmpty()) {
|
||||
object_track_metadata.insert("release_name", QJsonValue::fromVariant(item->album_));
|
||||
}
|
||||
|
||||
object_track_metadata.insert("track_name", QJsonValue::fromVariant(item->song_));
|
||||
object_listen.insert("track_metadata", object_track_metadata);
|
||||
|
|
|
@ -36,7 +36,7 @@ class ScrobblerCacheItem : public QObject {
|
|||
public:
|
||||
explicit ScrobblerCacheItem(const QString &artist, const QString &album, const QString &song, const QString &albumartist, const int track, const qint64 duration, const quint64 timestamp, QObject *parent = nullptr);
|
||||
|
||||
QString effective_albumartist() const { return albumartist_.isEmpty() || albumartist_.toLower() == Song::kVariousArtists ? artist_ : albumartist_; }
|
||||
QString effective_albumartist() const { return albumartist_.isEmpty() || albumartist_.compare(Song::kVariousArtists, Qt::CaseInsensitive) == 0 ? artist_ : albumartist_; }
|
||||
|
||||
public:
|
||||
QString artist_;
|
||||
|
|
|
@ -474,11 +474,13 @@ void ScrobblingAPI20::UpdateNowPlaying(const Song &song) {
|
|||
<< Param("artist", prefer_albumartist_ && song.effective_albumartist() != Song::kVariousArtists ? song.effective_albumartist() : song.artist())
|
||||
<< Param("track", title);
|
||||
|
||||
if (!album.isEmpty())
|
||||
if (!album.isEmpty()) {
|
||||
params << Param("album", album);
|
||||
}
|
||||
|
||||
if (!prefer_albumartist_ && !song.albumartist().isEmpty() && song.albumartist().toLower() != Song::kVariousArtists)
|
||||
if (!prefer_albumartist_ && !song.albumartist().isEmpty() && song.albumartist().compare(Song::kVariousArtists, Qt::CaseInsensitive) != 0) {
|
||||
params << Param("albumArtist", song.albumartist());
|
||||
}
|
||||
|
||||
QNetworkReply *reply = CreateRequest(params);
|
||||
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply]() { UpdateNowPlayingRequestFinished(reply); });
|
||||
|
@ -592,12 +594,15 @@ void ScrobblingAPI20::Submit() {
|
|||
params << Param(QString("%1[%2]").arg("track").arg(i), item->song_);
|
||||
params << Param(QString("%1[%2]").arg("timestamp").arg(i), QString::number(item->timestamp_));
|
||||
params << Param(QString("%1[%2]").arg("duration").arg(i), QString::number(item->duration_ / kNsecPerSec));
|
||||
if (!item->album_.isEmpty())
|
||||
if (!item->album_.isEmpty()) {
|
||||
params << Param(QString("%1[%2]").arg("album").arg(i), item->album_);
|
||||
if (!prefer_albumartist_ && !item->albumartist_.isEmpty() && item->albumartist_.toLower() != Song::kVariousArtists)
|
||||
}
|
||||
if (!prefer_albumartist_ && !item->albumartist_.isEmpty() && item->albumartist_.compare(Song::kVariousArtists, Qt::CaseInsensitive) != 0) {
|
||||
params << Param(QString("%1[%2]").arg("albumArtist").arg(i), item->albumartist_);
|
||||
if (item->track_ > 0)
|
||||
}
|
||||
if (item->track_ > 0) {
|
||||
params << Param(QString("%1[%2]").arg("trackNumber").arg(i), QString::number(item->track_));
|
||||
}
|
||||
++i;
|
||||
if (i >= kScrobblesPerRequest) break;
|
||||
}
|
||||
|
@ -790,12 +795,15 @@ void ScrobblingAPI20::SendSingleScrobble(ScrobblerCacheItemPtr item) {
|
|||
<< Param("timestamp", QString::number(item->timestamp_))
|
||||
<< Param("duration", QString::number(item->duration_ / kNsecPerSec));
|
||||
|
||||
if (!item->album_.isEmpty())
|
||||
if (!item->album_.isEmpty()) {
|
||||
params << Param("album", item->album_);
|
||||
if (!prefer_albumartist_ && !item->albumartist_.isEmpty() && item->albumartist_.toLower() != Song::kVariousArtists)
|
||||
}
|
||||
if (!prefer_albumartist_ && !item->albumartist_.isEmpty() && item->albumartist_.compare(Song::kVariousArtists, Qt::CaseInsensitive) != 0) {
|
||||
params << Param("albumArtist", item->albumartist_);
|
||||
if (item->track_ > 0)
|
||||
}
|
||||
if (item->track_ > 0) {
|
||||
params << Param("trackNumber", QString::number(item->track_));
|
||||
}
|
||||
|
||||
QNetworkReply *reply = CreateRequest(params);
|
||||
QObject::connect(reply, &QNetworkReply::finished, this, [this, reply, item]() { SingleScrobbleRequestFinished(reply, item->timestamp_); });
|
||||
|
@ -945,7 +953,7 @@ void ScrobblingAPI20::Love() {
|
|||
if (!song_playing_.album().isEmpty())
|
||||
params << Param("album", song_playing_.album());
|
||||
|
||||
if (!prefer_albumartist_ && !song_playing_.albumartist().isEmpty() && song_playing_.albumartist().toLower() != Song::kVariousArtists)
|
||||
if (!prefer_albumartist_ && !song_playing_.albumartist().isEmpty() && song_playing_.albumartist().compare(Song::kVariousArtists, Qt::CaseInsensitive) != 0)
|
||||
params << Param("albumArtist", song_playing_.albumartist());
|
||||
|
||||
QNetworkReply *reply = CreateRequest(params);
|
||||
|
|
|
@ -459,7 +459,7 @@ FancyTabWidget::FancyTabWidget(QWidget *parent)
|
|||
setMovable(true);
|
||||
setElideMode(Qt::ElideNone);
|
||||
setUsesScrollButtons(true);
|
||||
if (QApplication::style() && QApplication::style()->objectName().toLower().contains(QRegularExpression("^adwaita.*$"))) {
|
||||
if (QApplication::style() && QApplication::style()->objectName().contains(QRegularExpression("^adwaita.*$", QRegularExpression::CaseInsensitiveOption))) {
|
||||
style_ = new FancyTabWidgetProxyStyle(style());
|
||||
setStyle(style_);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue