Add setting for cover providers

This commit is contained in:
Jonas Kvinge
2020-05-09 01:48:08 +02:00
parent 40f9dafa44
commit 7bccc21878
32 changed files with 1276 additions and 33 deletions

View File

@@ -2,6 +2,7 @@
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* Copyright 2018-2020, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -72,12 +73,23 @@ void AlbumCoverFetcherSearch::TerminateSearch() {
void AlbumCoverFetcherSearch::Start(CoverProviders *cover_providers) {
for (CoverProvider *provider : cover_providers->List()) {
QList<CoverProvider*> cover_providers_sorted = cover_providers->List();
std::stable_sort(cover_providers_sorted.begin(), cover_providers_sorted.end(), ProviderCompareOrder);
// Skip provider if it does not have fetchall set, and we are doing fetchall - "Fetch Missing Covers".
for (CoverProvider *provider : cover_providers_sorted) {
if (!provider->is_enabled()) continue;
// Skip any provider that requires authentication but is not authenticated.
if (provider->AuthenticationRequired() && !provider->IsAuthenticated()) {
continue;
}
// Skip provider if it does not have fetchall set and we are doing fetchall - "Fetch Missing Covers".
if (!provider->fetchall() && request_.fetchall) {
continue;
}
// If album is missing, check if we can still use this provider by searching using artist + title.
if (!provider->allow_missing_album() && request_.album.isEmpty()) {
continue;
@@ -299,6 +311,10 @@ void AlbumCoverFetcherSearch::Cancel() {
}
bool AlbumCoverFetcherSearch::ProviderCompareOrder(CoverProvider *a, CoverProvider *b) {
return a->order() < b->order();
}
bool AlbumCoverFetcherSearch::CoverSearchResultCompareScore(const CoverSearchResult &a, const CoverSearchResult &b) {
return a.score > b.score;
}