Skip to content

Commit

Permalink
Merge pull request xbmc#18051 from ronie/scraper-select
Browse files Browse the repository at this point in the history
[Album Scaper] provide detailed album selection dialog
  • Loading branch information
ronie authored Jun 20, 2020
2 parents bbce61b + a1f325d commit fe126ae
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 8 deletions.
14 changes: 10 additions & 4 deletions xbmc/addons/Scraper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,17 +617,23 @@ CMusicAlbumInfo FromFileItem<CMusicAlbumInfo>(const CFileItem &item)
else
sAlbumName = sTitle;

std::string sYear = item.GetProperty("album.year").asString();
if (!sYear.empty())
sAlbumName = StringUtils::Format("%s (%s)", sAlbumName.c_str(), sYear.c_str());

CScraperUrl url;
url.AppendUrl(CScraperUrl::SUrlEntry(item.GetDynPath()));

info = CMusicAlbumInfo(sTitle, sArtist, sAlbumName, url);
if (item.HasProperty("relevance"))
info.SetRelevance(item.GetProperty("relevance").asFloat());

if (item.HasProperty("album.releasestatus"))
info.GetAlbum().strReleaseStatus = item.GetProperty("album.releasestatus").asString();
if (item.HasProperty("album.type"))
info.GetAlbum().strType = item.GetProperty("album.type").asString();
if (item.HasProperty("album.year"))
info.GetAlbum().strReleaseDate = item.GetProperty("album.year").asString();
if (item.HasProperty("album.label"))
info.GetAlbum().strLabel = item.GetProperty("album.label").asString();
info.GetAlbum().art = item.GetArt();

return info;
}

Expand Down
25 changes: 21 additions & 4 deletions xbmc/music/infoscanner/MusicInfoScanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1564,8 +1564,10 @@ CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album,
pDlg->SetHeading(CVariant{g_localizeStrings.Get(181)});
pDlg->Reset();
pDlg->EnableButton(true, 413); // manual
pDlg->SetUseDetails(true);
}

CFileItemList items;
for (int i = 0; i < scraper.GetAlbumCount(); ++i)
{
CMusicAlbumInfo& info = scraper.GetAlbum(i);
Expand All @@ -1586,9 +1588,23 @@ CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album,
{
// set the label to [relevance] album - artist
std::string strTemp = StringUtils::Format("[%0.2f] %s", relevance, info.GetTitle2().c_str());
CFileItem item(strTemp);
item.m_idepth = i; // use this to hold the index of the album in the scraper
pDlg->Add(item);
CFileItemPtr item(new CFileItem("", false));
item->SetLabel(strTemp);

std::string strTemp2;
if (!scraper.GetAlbum(i).GetAlbum().strType.empty())
strTemp2 += scraper.GetAlbum(i).GetAlbum().strType;
if (!scraper.GetAlbum(i).GetAlbum().strReleaseDate.empty())
strTemp2 += " - " + scraper.GetAlbum(i).GetAlbum().strReleaseDate;
if (!scraper.GetAlbum(i).GetAlbum().strReleaseStatus.empty())
strTemp2 += " - " + scraper.GetAlbum(i).GetAlbum().strReleaseStatus;
if (!scraper.GetAlbum(i).GetAlbum().strLabel.empty())
strTemp2 += " - " + scraper.GetAlbum(i).GetAlbum().strLabel;
item->SetLabel2(strTemp2);

item->SetArt(scraper.GetAlbum(i).GetAlbum().art);

items.Add(item);
}
if (relevance > .99f) // we're so close, no reason to search further
break;
Expand All @@ -1597,6 +1613,7 @@ CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album,
if (pDialog && bestRelevance < THRESHOLD)
{
pDlg->Sort(false);
pDlg->SetItems(items);
pDlg->Open();

// and wait till user selects one
Expand Down Expand Up @@ -1626,7 +1643,7 @@ CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album,

return DownloadAlbumInfo(newAlbum, info, albumInfo, bUseScrapedMBID, pDialog);
}
iSelectedAlbum = pDlg->GetSelectedFileItem()->m_idepth;
iSelectedAlbum = pDlg->GetSelectedItem();
}
}
else
Expand Down

0 comments on commit fe126ae

Please sign in to comment.