diff --git a/src/Release/foo_musicbrainz/foo_musicbrainz.pdb b/src/Release/foo_musicbrainz/foo_musicbrainz.pdb index a259c73..4d579d2 100644 Binary files a/src/Release/foo_musicbrainz/foo_musicbrainz.pdb and b/src/Release/foo_musicbrainz/foo_musicbrainz.pdb differ diff --git a/src/contextmenu.cpp b/src/contextmenu.cpp index 916772e..ad6bda9 100644 --- a/src/contextmenu.cpp +++ b/src/contextmenu.cpp @@ -7,11 +7,12 @@ namespace mb { - static constexpr std::array context_guids = + static constexpr std::array context_guids = { 0x3ca8395b, 0x694e, 0x4845, { 0xb5, 0xea, 0x56, 0x30, 0x5e, 0x7c, 0x24, 0x48 }, 0x77f1f5cd, 0xf295, 0x4ef4, { 0xba, 0x7b, 0xc7, 0x70, 0xaa, 0xc6, 0xd0, 0x1e }, 0xf453e537, 0x01e9, 0x4f2d, { 0x89, 0xdc, 0x42, 0x4d, 0x0e, 0xe5, 0x72, 0xfb }, + 0xd74ebc1b, 0x7529, 0x4c68, { 0xb8, 0x85, 0xbf, 0xb1, 0x34, 0x8c, 0xed, 0xc8 }, 0x4d5e632c, 0x34f3, 0x4fda, { 0x8f, 0x71, 0x35, 0xa4, 0xb2, 0x5b, 0xea, 0x94 } }; @@ -20,6 +21,7 @@ namespace mb { "Get tags from MusicBrainz (by TOC)", "Queries MusicBrainz server for tags for a complete CD using TOC." }, { "Get tags from MusicBrainz (by artist & album)","Queries MusicBrainz server for tags for a complete CD using Artist/Album." }, { "Get tags from MusicBrainz (by MusicBrainz album ID)","Queries MusicBrainz server for tags for a complete CD using MusicBrainz Album ID." }, + { "Get tags from MusicBrainz (by MusicBrainz release ID)","Queries MusicBrainz server for tags for a complete CD using MusicBrainz Release ID." }, { "Add TOC to MusicBrainz", "Opens MusicBrainz TOC lookup page." } }; @@ -46,9 +48,10 @@ namespace mb break; case 1: case 2: + case 3: result = true; break; - case 3: + case 4: result = check_count(handles) && check_lossless(handles); break; } @@ -188,10 +191,10 @@ namespace mb if (scope.can_create()) { scope.initialize(wnd); - dialog_mbid dlg(album_id); + dialog_mbid dlg(album_id, "MusicBrainz Album ID"); if (dlg.DoModal(wnd) == IDOK) { - auto q = std::make_unique("release", dlg.m_albumid_str); + auto q = std::make_unique("release", dlg.m_mbid_str); q->add_param("inc", "artists+labels+recordings+release-groups+artist-credits+isrcs"); auto cb = fb2k::service_new(request_thread::types::albumid, std::move(q), handles); threaded_process::get()->run_modeless(cb, flags, wnd, "Querying data from MusicBrainz"); @@ -200,6 +203,57 @@ namespace mb } break; case 3: + { + str8 relgroup_id; + for (size_t i = 0; i < count; i++) + { + const file_info_impl info = handles.get_item(i)->get_info_ref()->info(); + + auto current_relgroup_id = info.meta_get("MUSICBRAINZ_RELEASEGROUPID", 0); + if (current_relgroup_id == nullptr) current_relgroup_id = info.meta_get("MUSICBRAINZ RELEASEGROUPID", 0); + + if (current_relgroup_id == nullptr) + { + relgroup_id.reset(); + break; + } + else + { + if (i == 0) + { + if (is_uuid(current_relgroup_id)) + { + relgroup_id = current_relgroup_id; + } + else + { + break; + } + } + else if (strcmp(relgroup_id, current_relgroup_id) != 0) + { + relgroup_id.reset(); + break; + } + } + } + + modal_dialog_scope scope; + if (scope.can_create()) + { + scope.initialize(wnd); + dialog_mbid dlg(relgroup_id, "MusicBrainz Release Group ID"); + if (dlg.DoModal(wnd) == IDOK) + { + auto q = std::make_unique("release-group", dlg.m_mbid_str); + q->add_param("inc", "releases+media"); + auto cb = fb2k::service_new(request_thread::types::search, std::move(q), handles); + threaded_process::get()->run_modeless(cb, flags, wnd, "Querying data from MusicBrainz"); + } + } + } + break; + case 4: { if (!check_count(handles)) return popup_message::g_show("Please select no more than 99 tracks.", component_title, popup_message::icon_error); if (!check_lossless(handles)) return popup_message::g_show("Only lossless files with a sample rate of 44100Hz may be used for TOC submissions. Also, the number of samples must match CD frame boundaries.", component_title, popup_message::icon_error); diff --git a/src/dialog_mbid.h b/src/dialog_mbid.h index a1d7073..2a666fa 100644 --- a/src/dialog_mbid.h +++ b/src/dialog_mbid.h @@ -5,7 +5,9 @@ namespace mb class dialog_mbid : public CDialogImpl { public: - dialog_mbid(pfc::stringp albumid_str) : m_albumid_str(albumid_str) {} + dialog_mbid(pfc::stringp albumid_str, str8 group_title_str) + : m_mbid_str(albumid_str) + , m_group_title_str(group_title_str) {} BEGIN_MSG_MAP_EX(dialog_mbid) MSG_WM_INITDIALOG(OnInitDialog) @@ -18,30 +20,32 @@ namespace mb BOOL OnInitDialog(CWindow, LPARAM) { m_ok = GetDlgItem(IDOK); - m_albumid_edit = GetDlgItem(IDC_EDIT_MBID); + m_mbid_edit = GetDlgItem(IDC_EDIT_MBID); + CEdit m_mbid_title = GetDlgItem(IDC_STATIC); - uSetWindowText(m_albumid_edit, m_albumid_str); + uSetWindowText(m_mbid_edit, m_mbid_str); + uSetWindowText(m_mbid_title, m_group_title_str); CenterWindow(); return TRUE; } void OnCloseCmd(UINT, int nID, CWindow) { - uGetWindowText(m_albumid_edit, m_albumid_str); + uGetWindowText(m_mbid_edit, m_mbid_str); EndDialog(nID); } void OnUpdate(UINT, int, CWindow) { str8 t; - uGetWindowText(m_albumid_edit, t); + uGetWindowText(m_mbid_edit, t); str8 u = prefs::get_server(); u << "/release/"; const size_t l = u.get_length(); if (strncmp(t, u, l) == 0) { t.replace_string(u, ""); - uSetWindowText(m_albumid_edit, t); + uSetWindowText(m_mbid_edit, t); return; } @@ -49,7 +53,8 @@ namespace mb } CButton m_ok; - CEdit m_albumid_edit; - str8 m_albumid_str; + CEdit m_mbid_edit; + str8 m_mbid_str; + str8 m_group_title_str; }; } diff --git a/src/foo_musicbrainz.h b/src/foo_musicbrainz.h index 815b7b2..bb875d8 100644 --- a/src/foo_musicbrainz.h +++ b/src/foo_musicbrainz.h @@ -4,6 +4,6 @@ namespace mb { static constexpr const char* component_title = "MusicBrainz Tagger"; static constexpr const char* component_dll_name = "foo_musicbrainz.dll"; - static constexpr const char* component_version = "0.4.5b1"; + static constexpr const char* component_version = "0.4.5b2"; static constexpr const char* component_info = "Copyright (C) 2009-2012 Dremora\nCopyright (C) 2015-2020 marc2003\nCopyright (C) 2020 MordredKLB\n\nBuild: " __TIME__ ", " __DATE__; } diff --git a/src/query.cpp b/src/query.cpp index a648155..db165d3 100644 --- a/src/query.cpp +++ b/src/query.cpp @@ -50,4 +50,8 @@ namespace mb { url << "&" << param << "=" << value; } + + str8 query::get_url() { + return url; + } } diff --git a/src/query.h b/src/query.h index 98c0a94..af2e6b0 100644 --- a/src/query.h +++ b/src/query.h @@ -9,6 +9,7 @@ namespace mb json lookup(abort_callback& abort); void add_param(pfc::stringp param, pfc::stringp value); + str8 get_url(); private: str8 url; diff --git a/src/request_thread.cpp b/src/request_thread.cpp index be31bf8..84492c8 100644 --- a/src/request_thread.cpp +++ b/src/request_thread.cpp @@ -91,6 +91,9 @@ namespace mb const size_t handle_count = m_handles.get_count(); json j = m_query->lookup(abort); +#ifdef DEBUG + FB2K_console_formatter() << component_title << ": " << m_query->get_url(); +#endif if (!j.is_object()) { m_failed = true; @@ -124,11 +127,9 @@ namespace mb for (size_t i = 0; i < count; ++i) { + Sleep(1000); + status.set_title(PFC_string_formatter() << "Fetching release " << (i + 1) << " of " << count); status.set_progress(i + 1, count); - status.set_title(PFC_string_formatter() << "Fetching " << (i + 1) << " of " << count); - if (i > 0) { - Sleep(1000); - } /** * this was pre-existing logic which would abort when we didn't receive anything back @@ -146,7 +147,7 @@ namespace mb if (!simple_thread_pool::instance().enqueue(task)) delete task; } Sleep(10); // wait for last thread to start - while (m_release_list.size() < thread_counter) { + while (m_release_list.size() < thread_counter && !abort.is_aborting()) { // Is there a better way to wait for all the threads to complete? Sleep(10); }