bool CGUIWindowMusicBase::FindAlbumInfo(const CStdString& strAlbum, const CStdString& strArtist, CMusicAlbumInfo& album, const SScraperInfo& info, ALLOW_SELECTION allowSelection) { // quietly return if Internet lookups are disabled if (!g_guiSettings.GetBool("network.enableinternet")) return false; // show dialog box indicating we're searching the album if (m_dlgProgress && allowSelection != SELECTION_AUTO) { m_dlgProgress->SetHeading(185); m_dlgProgress->SetLine(0, strAlbum); m_dlgProgress->SetLine(1, strArtist); m_dlgProgress->SetLine(2, ""); m_dlgProgress->StartModal(); } CMusicInfoScanner scanner; CStdString strPath; CStdString strTempAlbum(strAlbum); CStdString strTempArtist(strArtist); long idAlbum = m_musicdatabase.GetAlbumByName(strAlbum,strArtist); strPath.Format("musicdb://3/%d/",idAlbum); bool bCanceled(false); bool needsRefresh(true); do { if (!scanner.DownloadAlbumInfo(strPath,strTempArtist,strTempAlbum,bCanceled,album,m_dlgProgress)) { if (m_dlgProgress && allowSelection != SELECTION_AUTO) { if (!CGUIDialogKeyboard::ShowAndGetInput(strTempAlbum, g_localizeStrings.Get(16011), false)) return false; if (!CGUIDialogKeyboard::ShowAndGetInput(strTempArtist, g_localizeStrings.Get(16025), false)) return false; } else needsRefresh = false; } else needsRefresh = false; } while (needsRefresh || bCanceled); // Read the album information from the database if we are dealing with a DB album. if (idAlbum != -1) m_musicdatabase.GetAlbumInfo(idAlbum,album.GetAlbum(),&album.GetAlbum().songs); album.SetLoaded(true); return true; }
INFO_RET CMusicInfoScanner::UpdateDatabaseAlbumInfo(CAlbum& album, const ADDON::ScraperPtr& scraper, bool bAllowSelection, CGUIDialogProgress* pDialog /* = NULL */) { if (!scraper) return INFO_ERROR; CMusicAlbumInfo albumInfo; loop: CLog::Log(LOGDEBUG, "%s downloading info for: %s", __FUNCTION__, album.strAlbum.c_str()); INFO_RET albumDownloadStatus = DownloadAlbumInfo(album, scraper, albumInfo, pDialog); if (albumDownloadStatus == INFO_NOT_FOUND) { if (pDialog && bAllowSelection) { if (!CGUIKeyboardFactory::ShowAndGetInput(album.strAlbum, CVariant{g_localizeStrings.Get(16011)}, false)) return INFO_CANCELLED; std::string strTempArtist(album.GetAlbumArtistString()); if (!CGUIKeyboardFactory::ShowAndGetInput(strTempArtist, CVariant{g_localizeStrings.Get(16025)}, false)) return INFO_CANCELLED; album.strArtistDesc = strTempArtist; goto loop; } else { CEventLog::GetInstance().Add(EventPtr(new CMediaLibraryEvent( MediaTypeAlbum, album.strPath, 24146, StringUtils::Format(g_localizeStrings.Get(24147).c_str(), MediaTypeAlbum, album.strAlbum.c_str()), CScraperUrl::GetThumbURL(album.thumbURL.GetFirstThumb()), CURL::GetRedacted(album.strPath), EventLevel::Warning))); } } else if (albumDownloadStatus == INFO_ADDED) { bool overridetags = CServiceBroker::GetSettings().GetBool(CSettings::SETTING_MUSICLIBRARY_OVERRIDETAGS); album.MergeScrapedAlbum(albumInfo.GetAlbum(), overridetags); m_musicDatabase.Open(); m_musicDatabase.UpdateAlbum(album, overridetags); GetAlbumArtwork(album.idAlbum, album); m_musicDatabase.Close(); albumInfo.SetLoaded(true); } return albumDownloadStatus; }
INFO_RET CMusicInfoScanner::UpdateDatabaseAlbumInfo(CAlbum& album, const ADDON::ScraperPtr& scraper, bool bAllowSelection, CGUIDialogProgress* pDialog /* = NULL */) { if (!scraper) return INFO_ERROR; CMusicAlbumInfo albumInfo; loop: CLog::Log(LOGDEBUG, "%s downloading info for: %s", __FUNCTION__, album.strAlbum.c_str()); INFO_RET albumDownloadStatus = DownloadAlbumInfo(album, scraper, albumInfo, pDialog); if (albumDownloadStatus == INFO_NOT_FOUND) { if (pDialog && bAllowSelection) { if (!CGUIKeyboardFactory::ShowAndGetInput(album.strAlbum, g_localizeStrings.Get(16011), false)) return INFO_CANCELLED; std::string strTempArtist(StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator)); if (!CGUIKeyboardFactory::ShowAndGetInput(strTempArtist, g_localizeStrings.Get(16025), false)) return INFO_CANCELLED; album.artist = StringUtils::Split(strTempArtist, g_advancedSettings.m_musicItemSeparator); goto loop; } } else if (albumDownloadStatus == INFO_ADDED) { album.MergeScrapedAlbum(albumInfo.GetAlbum(), CSettings::Get().GetBool("musiclibrary.overridetags")); m_musicDatabase.Open(); m_musicDatabase.UpdateAlbum(album); GetAlbumArtwork(album.idAlbum, album); m_musicDatabase.Close(); albumInfo.SetLoaded(true); } return albumDownloadStatus; }