void CGUIWindowMusicBase::ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bShowInfo /* = true */) { bool saveDb = artist.idArtist != -1; if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser) saveDb = false; CMusicArtistInfo artistInfo; while (1) { if (!m_musicdatabase.HasArtistInfo(artist.idArtist) || !m_musicdatabase.GetArtistInfo(artist.idArtist, artistInfo.GetArtist())) { if (g_application.IsMusicScanning()) { CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0); break; } if (!FindArtistInfo(artist.strArtist, artistInfo, bShowInfo ? SELECTION_ALLOWED : SELECTION_AUTO)) break; if (!artistInfo.Loaded()) { // Failed to download album info CGUIDialogOK::ShowAndGetInput(21889, 0, 20199, 0); break; } if (saveDb) m_musicdatabase.SetArtistInfo(artist.idArtist, artistInfo.GetArtist()); } CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO); if (pDlgArtistInfo) { pDlgArtistInfo->SetArtist(artistInfo.GetArtist(), path); pDlgArtistInfo->DoModal(); if (pDlgArtistInfo->NeedRefresh()) { m_musicdatabase.DeleteArtistInfo(artist.idArtist); continue; } else if (pDlgArtistInfo->HasUpdatedThumb()) { Update(m_vecItems->GetPath()); } } break; } if (m_dlgProgress) m_dlgProgress->Close(); }
INFO_RET CMusicInfoScanner::UpdateDatabaseArtistInfo(CArtist& artist, const ADDON::ScraperPtr& scraper, bool bAllowSelection, CGUIDialogProgress* pDialog /* = NULL */) { if (!scraper) return INFO_ERROR; CMusicArtistInfo artistInfo; loop: CLog::Log(LOGDEBUG, "%s downloading info for: %s", __FUNCTION__, artist.strArtist.c_str()); INFO_RET artistDownloadStatus = DownloadArtistInfo(artist, scraper, artistInfo, pDialog); if (artistDownloadStatus == INFO_NOT_FOUND) { if (pDialog && bAllowSelection) { if (!CGUIKeyboardFactory::ShowAndGetInput(artist.strArtist, g_localizeStrings.Get(16025), false)) return INFO_CANCELLED; goto loop; } } else if (artistDownloadStatus == INFO_ADDED) { artist.MergeScrapedArtist(artistInfo.GetArtist(), CSettings::Get().GetBool("musiclibrary.overridetags")); m_musicDatabase.Open(); m_musicDatabase.UpdateArtist(artist); m_musicDatabase.GetArtistPath(artist.idArtist, artist.strPath); m_musicDatabase.SetArtForItem(artist.idArtist, MediaTypeArtist, GetArtistArtwork(artist)); m_musicDatabase.Close(); artistInfo.SetLoaded(); } return artistDownloadStatus; }
bool CGUIWindowMusicBase::FindArtistInfo(const CStdString& strArtist, CMusicArtistInfo& artist, 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(21889); m_dlgProgress->SetLine(0, strArtist); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, ""); m_dlgProgress->StartModal(); } CMusicInfoScanner scanner; CStdString strPath; long idArtist = m_musicdatabase.GetArtistByName(strArtist); strPath.Format("musicdb://2/%u/",idArtist); if (!scanner.DownloadArtistInfo(strPath,strArtist,m_dlgProgress)) { // no albums found CGUIDialogOK::ShowAndGetInput(21889, 0, 20198, 0); return false; } m_musicdatabase.GetArtistInfo(idArtist,artist.GetArtist()); artist.SetLoaded(true); return true; }
bool CGUIWindowMusicBase::FindArtistInfo(const CStdString& strArtist, CMusicArtistInfo& artist, ALLOW_SELECTION allowSelection) { // show dialog box indicating we're searching the album if (m_dlgProgress && allowSelection != SELECTION_AUTO) { m_dlgProgress->SetHeading(21889); m_dlgProgress->SetLine(0, strArtist); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, ""); m_dlgProgress->StartModal(); } CMusicInfoScanner scanner; CStdString strPath; CStdString strTempArtist(strArtist); long idArtist = m_musicdatabase.GetArtistByName(strArtist); strPath.Format("musicdb://2/%u/",idArtist); bool bCanceled(false); bool needsRefresh(true); do { if (!scanner.DownloadArtistInfo(strPath,strTempArtist,bCanceled,m_dlgProgress)) { if (bCanceled) return false; if (m_dlgProgress && allowSelection != SELECTION_AUTO) { if (!CGUIKeyboardFactory::ShowAndGetInput(strTempArtist, g_localizeStrings.Get(16025), false)) return false; } else needsRefresh = false; } else needsRefresh = false; } while (needsRefresh || bCanceled); if (!m_musicdatabase.GetArtistInfo(idArtist,artist.GetArtist())) return false; artist.SetLoaded(); return true; }
INFO_RET CMusicInfoScanner::UpdateDatabaseArtistInfo(CArtist& artist, const ADDON::ScraperPtr& scraper, bool bAllowSelection, CGUIDialogProgress* pDialog /* = NULL */) { if (!scraper) return INFO_ERROR; CMusicArtistInfo artistInfo; loop: CLog::Log(LOGDEBUG, "%s downloading info for: %s", __FUNCTION__, artist.strArtist.c_str()); INFO_RET artistDownloadStatus = DownloadArtistInfo(artist, scraper, artistInfo, pDialog); if (artistDownloadStatus == INFO_NOT_FOUND) { if (pDialog && bAllowSelection) { if (!CGUIKeyboardFactory::ShowAndGetInput(artist.strArtist, CVariant{g_localizeStrings.Get(16025)}, false)) return INFO_CANCELLED; goto loop; } else { CEventLog::GetInstance().Add(EventPtr(new CMediaLibraryEvent( MediaTypeArtist, artist.strPath, 24146, StringUtils::Format(g_localizeStrings.Get(24147).c_str(), MediaTypeArtist, artist.strArtist.c_str()), CScraperUrl::GetThumbURL(artist.thumbURL.GetFirstThumb()), CURL::GetRedacted(artist.strPath), EventLevel::Warning))); } } else if (artistDownloadStatus == INFO_ADDED) { artist.MergeScrapedArtist(artistInfo.GetArtist(), CServiceBroker::GetSettings().GetBool(CSettings::SETTING_MUSICLIBRARY_OVERRIDETAGS)); m_musicDatabase.Open(); m_musicDatabase.UpdateArtist(artist); m_musicDatabase.GetArtistPath(artist.idArtist, artist.strPath); m_musicDatabase.SetArtForItem(artist.idArtist, MediaTypeArtist, GetArtistArtwork(artist)); m_musicDatabase.Close(); artistInfo.SetLoaded(); } return artistDownloadStatus; }
void CGUIWindowMusicBase::ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bRefresh, bool bShowInfo) { bool saveDb = artist.idArtist != -1; if (!g_settings.GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser) saveDb = false; // check cache CArtist artistInfo; if (!bRefresh && m_musicdatabase.GetArtistInfo(artist.idArtist, artistInfo)) { if (!bShowInfo) return; CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO); if (pDlgArtistInfo) { pDlgArtistInfo->SetArtist(artistInfo, path); if (bShowInfo) pDlgArtistInfo->DoModal(); if (!pDlgArtistInfo->NeedRefresh()) { if (pDlgArtistInfo->HasUpdatedThumb()) Update(m_vecItems->GetPath()); return; } bRefresh = true; m_musicdatabase.DeleteArtistInfo(artistInfo.idArtist); } } // If we are scanning for music info in the background, // other writing access to the database is prohibited. if (g_application.IsMusicScanning()) { CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0); return; } CMusicArtistInfo info; if (FindArtistInfo(artist.strArtist, info, bShowInfo ? (bRefresh ? SELECTION_FORCED : SELECTION_ALLOWED) : SELECTION_AUTO)) { // download the album info if ( info.Loaded() ) { if (saveDb) { // save to database m_musicdatabase.SetArtistInfo(artist.idArtist, info.GetArtist()); } if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); // ok, show album info CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO); if (pDlgArtistInfo) { pDlgArtistInfo->SetArtist(info.GetArtist(), path); if (bShowInfo) pDlgArtistInfo->DoModal(); CArtist artistInfo = info.GetArtist(); artistInfo.idArtist = artist.idArtist; /* if (pDlgAlbumInfo->HasUpdatedThumb()) UpdateThumb(artistInfo, path); */ // just update for now Update(m_vecItems->GetPath()); if (pDlgArtistInfo->NeedRefresh()) { m_musicdatabase.DeleteArtistInfo(artistInfo.idArtist); ShowArtistInfo(artist, path, true, bShowInfo); return; } } } else { // failed 2 download album info CGUIDialogOK::ShowAndGetInput(21889, 0, 20199, 0); } } if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); }
void CGUIWindowMusicBase::ShowArtistInfo(const CFileItem *pItem, bool bShowInfo /* = true */) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params); CMusicArtistInfo artistInfo; while (1) { // Check if we have the information in the database first if (!m_musicdatabase.HasArtistInfo(params.GetArtistId()) || !m_musicdatabase.GetArtistInfo(params.GetArtistId(), artistInfo.GetArtist())) { if (!CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser) break; // should display a dialog saying no permissions if (g_application.IsMusicScanning()) { CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0); break; } // show dialog box indicating we're searching the album if (m_dlgProgress && bShowInfo) { m_dlgProgress->SetHeading(21889); m_dlgProgress->SetLine(0, pItem->GetMusicInfoTag()->GetArtist()); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, ""); m_dlgProgress->StartModal(); } CMusicInfoScanner scanner; if (scanner.UpdateDatabaseArtistInfo(pItem->GetPath(), artistInfo, bShowInfo) != INFO_ADDED || !artistInfo.Loaded()) { CGUIDialogOK::ShowAndGetInput(21889, 0, 20199, 0); break; } } if (m_dlgProgress) m_dlgProgress->Close(); CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO); if (pDlgArtistInfo) { CStdString strPath; m_musicdatabase.GetArtistPath(params.GetArtistId(), strPath); pDlgArtistInfo->SetArtist(artistInfo.GetArtist(), strPath); pDlgArtistInfo->DoModal(); if (pDlgArtistInfo->NeedRefresh()) { m_musicdatabase.DeleteArtistInfo(params.GetArtistId()); continue; } else if (pDlgArtistInfo->HasUpdatedThumb()) { Update(m_vecItems->GetPath()); } } break; } if (m_dlgProgress) m_dlgProgress->Close(); }
void CGUIWindowMusicBase::ShowArtistInfo(const CArtist& artist, const CStdString& path, bool bRefresh, bool bShowInfo) { bool saveDb = artist.idArtist != -1; if (!g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].canWriteDatabases() && !g_passwordManager.bMasterUser) saveDb = false; // check cache CArtist artistInfo; if (!bRefresh && m_musicdatabase.GetArtistInfo(artist.idArtist, artistInfo)) { if (!bShowInfo) return; CGUIWindowMusicInfo *pDlgAlbumInfo = (CGUIWindowMusicInfo*)m_gWindowManager.GetWindow(WINDOW_MUSIC_INFO); if (pDlgAlbumInfo) { pDlgAlbumInfo->SetArtist(artistInfo, path); if (bShowInfo) pDlgAlbumInfo->DoModal(); else pDlgAlbumInfo->RefreshThumb(); // downloads the thumb if we don't already have one if (!pDlgAlbumInfo->NeedRefresh()) { if (pDlgAlbumInfo->HasUpdatedThumb()) Update(m_vecItems->m_strPath); return; } bRefresh = true; m_musicdatabase.DeleteArtistInfo(artistInfo.idArtist); } } // If we are scanning for music info in the background, // other writing access to the database is prohibited. CGUIDialogMusicScan* dlgMusicScan = (CGUIDialogMusicScan*)m_gWindowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN); if (dlgMusicScan->IsDialogRunning()) { CGUIDialogOK::ShowAndGetInput(189, 14057, 0, 0); return; } // find album info SScraperInfo scraper; if (!m_musicdatabase.GetScraperForPath(path,scraper)) return; CMusicArtistInfo info; if (FindArtistInfo(artist.strArtist, info, scraper, bShowInfo ? (bRefresh ? SELECTION_FORCED : SELECTION_ALLOWED) : SELECTION_AUTO)) { // download the album info if ( info.Loaded() ) { if (saveDb) { // save to database m_musicdatabase.SetArtistInfo(artist.idArtist, info.GetArtist()); } if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); // ok, show album info CGUIWindowMusicInfo *pDlgAlbumInfo = (CGUIWindowMusicInfo*)m_gWindowManager.GetWindow(WINDOW_MUSIC_INFO); if (pDlgAlbumInfo) { pDlgAlbumInfo->SetArtist(info.GetArtist(), path); if (bShowInfo) pDlgAlbumInfo->DoModal(); else pDlgAlbumInfo->RefreshThumb(); // downloads the thumb if we don't already have one CArtist artistInfo = info.GetArtist(); artistInfo.idArtist = artist.idArtist; /* if (pDlgAlbumInfo->HasUpdatedThumb()) UpdateThumb(artistInfo, path); */ // just update for now Update(m_vecItems->m_strPath); if (pDlgAlbumInfo->NeedRefresh()) { m_musicdatabase.DeleteArtistInfo(artistInfo.idArtist); ShowArtistInfo(artist, path, true, bShowInfo); return; } } } else { // failed 2 download album info CGUIDialogOK::ShowAndGetInput(21889, 0, 20199, 0); } } if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); }