diff options
author | Arno <arno@disconnect.de> | 2017-12-01 04:53:20 +0100 |
---|---|---|
committer | Arno <arno@disconnect.de> | 2017-12-01 04:53:20 +0100 |
commit | bf229f2a7b20bbb1248f14b07bf2384e753381d4 (patch) | |
tree | 6f98fbb683013c64bd0478bb77c3f937bb783d1f | |
parent | 3cda8abf5e056b91a81497cf698470dfac607c6f (diff) | |
download | BeetPlayer-bf229f2a7b20bbb1248f14b07bf2384e753381d4.tar.gz BeetPlayer-bf229f2a7b20bbb1248f14b07bf2384e753381d4.tar.bz2 BeetPlayer-bf229f2a7b20bbb1248f14b07bf2384e753381d4.zip |
Improve Musicbrainz search
If we already have the album, use the release year from the database and
indicate presence by different bullets in the list.
-rw-r--r-- | playerwidget.cpp | 26 | ||||
-rw-r--r-- | webdownloader.h | 2 |
2 files changed, 22 insertions, 6 deletions
diff --git a/playerwidget.cpp b/playerwidget.cpp index 0fb97ed..4464479 100644 --- a/playerwidget.cpp +++ b/playerwidget.cpp @@ -1472,9 +1472,18 @@ void PlayerWidget::searchMusicbrainzLeft(){ mWebDownloader->fetchData(artist, album); } - void PlayerWidget::webDlDone(){ QString aId = mWebDownloader->artistId(); + QString artist = mWebDownloader->artist(); + QHash<QString, QString> dbAlbums; + QSqlDatabase db = QSqlDatabase::database("beetplayerdb"); + QSqlQuery aQ(db); + aQ.prepare("SELECT DISTINCT(albums.talbum_name), siyear FROM artists, albums, songs WHERE artists.tartists_name = :aname AND artists.iartists_id = songs.iartists_id AND songs.ialbums_id = albums.ialbums_id"); + aQ.bindValue(":aname", artist); + aQ.exec(); + while(aQ.next()){ + dbAlbums.insert(aQ.value(0).toString(), aQ.value(1).toString()); + } QString text; if(!aId.isEmpty()){ text.append(QString(tr("<b>Musicbrainz:</b><table style=\"margin-bottom: 20px\">"))); @@ -1487,18 +1496,27 @@ void PlayerWidget::webDlDone(){ std::sort(other.begin(), other.end(), [](auto a, auto b){ return a.at(2).toInt() < b.at(2).toInt(); }); - text.append(QString(tr("<b>All Albums (%1):</b><ul>")).arg(QString::number(other.count()))); + text.append(QString(tr("<b>All Albums (%1):</b><dl>")).arg(QString::number(other.count()))); foreach(const QVariant vl, other){ QVariantList cur = vl.toList(); QString id = cur.at(0).toString(); QString album = cur.at(1).toString(); QString year = cur.at(2).toString(); + bool present = false; if(year == "-1"){ year = "nota"; } - text.append(QString("<li>%1: <a href=\"https://musicbrainz.org/release-group/%2\">%3</a></li>").arg(year).arg(id).arg(album)); + if(dbAlbums.contains(album)){ + year = dbAlbums.value(album); + present = true; + } + if(present){ + text.append(QString("<dt>♂ %1: <a href=\"https://musicbrainz.org/release-group/%2\">%3</a></dt>").arg(year).arg(id).arg(album)); + }else{ + text.append(QString("<dt>♀ %1: <a href=\"https://musicbrainz.org/release-group/%2\">%3</a></dt>").arg(year).arg(id).arg(album)); + } } - text.append("</ul>"); + text.append("</dl>"); }else{ text.append(QString(tr("<b>Musicbrainz: No match!</b><br/>"))); const QMap<QString, QString> alt = mWebDownloader->alternateArtists(); diff --git a/webdownloader.h b/webdownloader.h index 353bd5a..9bbc1c9 100644 --- a/webdownloader.h +++ b/webdownloader.h @@ -34,6 +34,4 @@ class WebDownloader : public QObject { QMap<QString, QString> mAlternateArtists; }; - - #endif // WEBDOWNLOADER_H |