From db7be219e5314e3d5701d6090ec9177de7c5b973 Mon Sep 17 00:00:00 2001 From: "kbuffington@gmail.com" Date: Sun, 16 Feb 2020 10:03:03 -0600 Subject: [PATCH] marc's TOC fix --- src/helpers.cpp | 18 +++++++++++++++++- src/helpers.h | 2 +- src/request_thread.cpp | 3 +-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/helpers.cpp b/src/helpers.cpp index 396bd72..67ae730 100644 --- a/src/helpers.cpp +++ b/src/helpers.cpp @@ -25,10 +25,11 @@ namespace mb { "―", "-" } }; - Release parser(json release, size_t handle_count) + Release parser(json release, size_t handle_count, pfc::stringp discid) { Release r; r.is_various = false; + r.discid = discid; get_artist_credit(release, r.album_artist, r.albumartistid); @@ -43,6 +44,21 @@ namespace mb json tracks = media.value("tracks", json::array()); if (complete || tracks.size() == handle_count) { + if (r.discid.get_length()) + { + bool found = false; + auto discs = media.value("discs", json::array()); + for (auto& disc : discs) + { + if (to_str(disc["id"]).equals(r.discid)) + { + found = true; + break; + } + } + if (!found) continue; + } + if (!complete) r.partial_lookup_matches++; str8 format = to_str(media["format"]); diff --git a/src/helpers.h b/src/helpers.h index 764d2e6..82058ed 100644 --- a/src/helpers.h +++ b/src/helpers.h @@ -65,7 +65,7 @@ namespace mb "Pseudo-Release" }; - Release parser(json release, size_t handle_count); + Release parser(json release, size_t handle_count, pfc::stringp discid = ""); bool is_uuid(pfc::stringp mbid); size_t get_status_index(pfc::stringp str); size_t get_type_index(pfc::stringp str); diff --git a/src/request_thread.cpp b/src/request_thread.cpp index 26b6876..a73db53 100644 --- a/src/request_thread.cpp +++ b/src/request_thread.cpp @@ -47,8 +47,7 @@ namespace mb json releases = j.value("releases", json::array()); for (const auto& release : releases) { - Release r = parser(release, handle_count); - r.discid = discid; + Release r = parser(release, handle_count, discid); if (r.tracks.size()) { m_release_list.emplace_back(r);