void CGUIWindowMusicBase::ShowArtistInfo(const CFileItem *pItem, bool bShowInfo /* = true */) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params); ADDON::ScraperPtr scraper; if (!m_musicdatabase.GetScraper(params.GetArtistId(), CONTENT_ARTISTS, scraper)) return; CArtist artist; if (!m_musicdatabase.GetArtist(params.GetArtistId(), artist)) return; // Get the *name* of the folder for this artist within the Artist Info folder (may not exist). // If there is no Artist Info folder specififed in settings this will be blank bool artistpathfound = m_musicdatabase.GetArtistPath(artist, artist.strPath); // Set up path for *item folder when browsing for art, by default this is in the Artist Info Folder std::string artistItemPath = artist.strPath; if (!artistpathfound || !CDirectory::Exists(artist.strPath)) // Fall back local to music files (historic location for those album artists with a unique folder) // although there may not be such a unique folder for the arist if (!m_musicdatabase.GetOldArtistPath(artist.idArtist, artistItemPath)) // Fall back further to browse the Artist Info Folder itself artistItemPath = CServiceBroker::GetSettings().GetString(CSettings::SETTING_MUSICLIBRARY_ARTISTSFOLDER); bool refresh = false; while (1) { // Check if the entry should be refreshed (Only happens if a user pressed refresh) if (refresh) { if (!CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser) break; // should display a dialog saying no permissions if (g_application.IsMusicScanning()) { HELPERS::ShowOKDialogText(CVariant{189}, CVariant{14057}); break; } // show dialog box indicating we're searching the album if (m_dlgProgress && bShowInfo) { m_dlgProgress->SetHeading(CVariant{21889}); m_dlgProgress->SetLine(0, CVariant{pItem->GetMusicInfoTag()->GetArtist()}); m_dlgProgress->SetLine(1, CVariant{""}); m_dlgProgress->SetLine(2, CVariant{""}); m_dlgProgress->Open(); } CMusicInfoScanner scanner; if (scanner.UpdateArtistInfo(artist, scraper, bShowInfo, m_dlgProgress) != INFO_ADDED) { HELPERS::ShowOKDialogText(CVariant{21889}, CVariant{20199}); break; } } if (m_dlgProgress) m_dlgProgress->Close(); CGUIDialogMusicInfo *pDlgArtistInfo = g_windowManager.GetWindow<CGUIDialogMusicInfo>(WINDOW_DIALOG_MUSIC_INFO); if (pDlgArtistInfo) { pDlgArtistInfo->SetArtist(artist, artistItemPath); pDlgArtistInfo->Open(); if (pDlgArtistInfo->NeedRefresh()) { m_musicdatabase.ClearArtistLastScrapedTime(params.GetArtistId()); refresh = true; continue; } else if (pDlgArtistInfo->HasUpdatedThumb()) { Update(m_vecItems->GetPath()); } } break; } if (m_dlgProgress) m_dlgProgress->Close(); }
// Refresh album/artist information including art types list bool DoWork() override { CGUIDialogMusicInfo *dialog = CServiceBroker::GetGUI()->GetWindowManager(). GetWindow<CGUIDialogMusicInfo>(WINDOW_DIALOG_MUSIC_INFO); if (!dialog) return false; if (dialog->IsCancelled()) return false; CFileItemPtr m_item = dialog->GetCurrentListItem(); CMusicInfoTag& tag = *m_item->GetMusicInfoTag(); CArtist& m_artist = dialog->GetArtist(); CAlbum& m_album = dialog->GetAlbum(); CGUIDialogProgress* dlgProgress = GetProgressDialog(); CMusicDatabase database; database.Open(); if (tag.GetType() == MediaTypeArtist) { ADDON::ScraperPtr scraper; if (!database.GetScraper(m_artist.idArtist, CONTENT_ARTISTS, scraper)) return false; if (dlgProgress->IsCanceled()) return false; database.ClearArtistLastScrapedTime(m_artist.idArtist); if (dlgProgress->IsCanceled()) return false; CMusicInfoScanner scanner; if (scanner.UpdateArtistInfo(m_artist, scraper, true, dlgProgress) != CInfoScanner::INFO_ADDED) return false; else // Tell info dialog, so can show message dialog->SetScrapedInfo(true); if (dlgProgress->IsCanceled()) return false; //That changed DB and m_artist, now update dialog item with new info and art tag.SetArtist(m_artist); CMusicDatabase::SetPropertiesFromArtist(*m_item, m_artist); // Fetch artist discography as scraped from online sources, but always // include all the albums in the music library dialog->SetDiscography(database); } else { // tag.GetType == MediaTypeAlbum ADDON::ScraperPtr scraper; if (!database.GetScraper(m_album.idAlbum, CONTENT_ALBUMS, scraper)) return false; if (dlgProgress->IsCanceled()) return false; database.ClearAlbumLastScrapedTime(m_album.idAlbum); if (dlgProgress->IsCanceled()) return false; CMusicInfoScanner scanner; if (scanner.UpdateAlbumInfo(m_album, scraper, true, GetProgressDialog()) != CInfoScanner::INFO_ADDED) return false; else // Tell info dialog, so can show message dialog->SetScrapedInfo(true); if (dlgProgress->IsCanceled()) return false; //That changed DB and m_album, now update dialog item with new info and art // Album songs are unchanged by refresh (even with Musicbrainz sync?) tag.SetAlbum(m_album); CMusicDatabase::SetPropertiesFromAlbum(*m_item, m_album); // Set the list of songs and related art dialog->SetSongs(m_album.songs); } database.Close(); if (dlgProgress->IsCanceled()) return false; /* Load current art (to CGUIListItem.m_art) For albums this includes related artist(s) art and artist fanart set as fallback album fanart. Clear item art first to ensure fresh not cached/partial art */ m_item->ClearArt(); CMusicThumbLoader loader; loader.LoadItem(m_item.get()); if (dlgProgress->IsCanceled()) return false; // Fill vector of possible art types with current art, when it exists, // for display on the art type selection dialog CFileItemList artlist; MUSIC_UTILS::FillArtTypesList(*m_item, artlist); dialog->SetArtTypeList(artlist); if (dialog->IsCancelled()) return false; // Tell waiting MusicDialog that job is complete MarkFinished(); return true; }