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*)g_windowManager.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*)g_windowManager.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*)g_windowManager.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(); }
void CGUIWindowMusicBase::ShowAlbumInfo(const CAlbum& album, const CStdString& path, bool bRefresh, bool bShowInfo) { bool saveDb = album.idAlbum != -1; if (!g_settings.m_vecProfiles[g_settings.m_iLastLoadedProfileIndex].canWriteDatabases() && !g_passwordManager.bMasterUser) saveDb = false; // check cache CAlbum albumInfo; if (!bRefresh && m_musicdatabase.GetAlbumInfo(album.idAlbum, albumInfo, &albumInfo.songs)) { if (!bShowInfo) return; CGUIWindowMusicInfo *pDlgAlbumInfo = (CGUIWindowMusicInfo*)m_gWindowManager.GetWindow(WINDOW_MUSIC_INFO); if (pDlgAlbumInfo) { pDlgAlbumInfo->SetAlbum(albumInfo, path); if (bShowInfo) pDlgAlbumInfo->DoModal(); else pDlgAlbumInfo->RefreshThumb(); // downloads the thumb if we don't already have one if (!pDlgAlbumInfo->NeedRefresh()) { if (pDlgAlbumInfo->HasUpdatedThumb()) UpdateThumb(albumInfo, path); return; } bRefresh = true; m_musicdatabase.DeleteAlbumInfo(albumInfo.idAlbum); } } // 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; CMusicAlbumInfo info; if (FindAlbumInfo(album.strAlbum, album.strArtist, info, scraper, bShowInfo ? (bRefresh ? SELECTION_FORCED : SELECTION_ALLOWED) : SELECTION_AUTO)) { // download the album info if ( info.Loaded() ) { // set album title from musicinfotag, not the one we got from allmusic.com info.SetTitle(album.strAlbum); UpdateThumb(album, path); if (saveDb) { // save to database m_musicdatabase.SetAlbumInfo(album.idAlbum, info.GetAlbum(), info.GetSongs()); } if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); // ok, show album info CGUIWindowMusicInfo *pDlgAlbumInfo = (CGUIWindowMusicInfo*)m_gWindowManager.GetWindow(WINDOW_MUSIC_INFO); if (pDlgAlbumInfo) { pDlgAlbumInfo->SetAlbum(info.GetAlbum(), path); if (bShowInfo) pDlgAlbumInfo->DoModal(); else pDlgAlbumInfo->RefreshThumb(); // downloads the thumb if we don't already have one CAlbum albumInfo = info.GetAlbum(); albumInfo.idAlbum = album.idAlbum; if (pDlgAlbumInfo->HasUpdatedThumb()) UpdateThumb(albumInfo, path); if (pDlgAlbumInfo->NeedRefresh()) { m_musicdatabase.DeleteAlbumInfo(albumInfo.idAlbum); ShowAlbumInfo(album, path, true, bShowInfo); return; } } } else { // failed 2 download album info CGUIDialogOK::ShowAndGetInput(185, 0, 500, 0); } } if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); }
void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo) { // Boxee if (bShowInfo) { g_application.CurrentFileItem() = *pItem; if (pItem->IsLastFM() || pItem->IsRSS() || pItem->IsPlugin() || pItem->IsShoutCast()) { CGUIDialogBoxeeAppCtx *pContext = (CGUIDialogBoxeeAppCtx*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_APP_CTX); pContext->SetItem(*pItem); pContext->DoModal(); } else { if (pItem->HasMusicInfoTag() && !pItem->GetPropertyBOOL("IsArtist")) { CGUIDialogBoxeeMusicCtx *pContext = (CGUIDialogBoxeeMusicCtx*)g_windowManager.GetWindow(WINDOW_DIALOG_BOXEE_MUSIC_CTX); pContext->SetItem(*pItem); pContext->OnMoreInfo(); } else { CGUIWindowMusicInfo* pDlgInfo = (CGUIWindowMusicInfo*)g_windowManager.GetWindow(WINDOW_MUSIC_INFO); if (pDlgInfo) { *(pDlgInfo->GetCurrentListItem()) = *pItem; pDlgInfo->DoModal(); } } } return; } // end boxee section if (pItem->m_bIsFolder && pItem->IsParentFolder()) return; if (!pItem->m_bIsFolder) { // song lookup ShowSongInfo(pItem); return; } CStdString strPath = pItem->m_strPath; // Try to find an album to lookup from the current item CAlbum album; CArtist artist; bool foundAlbum = false; album.idAlbum = -1; // we have a folder if (pItem->IsMusicDb()) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(pItem->m_strPath, params); if (params.GetAlbumId() == -1) { // artist lookup artist.idArtist = params.GetArtistId(); artist.strArtist = pItem->GetMusicInfoTag()->GetArtist(); } else { // album lookup album.idAlbum = params.GetAlbumId(); album.strAlbum = pItem->GetMusicInfoTag()->GetAlbum(); album.strArtist = pItem->GetMusicInfoTag()->GetArtist(); // we're going to need it's path as well (we assume that there's only one) - this is for // assigning thumbs to folders, and obtaining the local folder.jpg m_musicdatabase.GetAlbumPath(album.idAlbum, strPath); } } else { // from filemode, so find the albums in the folder CFileItemList items; GetDirectory(strPath, items); // show dialog box indicating we're searching the album name if (m_dlgProgress && bShowInfo) { m_dlgProgress->SetHeading(185); m_dlgProgress->SetLine(0, 501); m_dlgProgress->SetLine(1, ""); m_dlgProgress->SetLine(2, ""); m_dlgProgress->StartModal(); m_dlgProgress->Progress(); if (m_dlgProgress->IsCanceled()) return; } // check the first song we find in the folder, and grab it's album info for (int i = 0; i < items.Size() && !foundAlbum; i++) { CFileItemPtr pItem = items[i]; pItem->LoadMusicTag(); if (pItem->HasMusicInfoTag() && pItem->GetMusicInfoTag()->Loaded() && !pItem->GetMusicInfoTag()->GetAlbum().IsEmpty()) { // great, have a song - use it. CSong song(*pItem->GetMusicInfoTag()); // this function won't be needed if/when the tag has idSong information if (!m_musicdatabase.GetAlbumFromSong(song, album)) { // album isn't in the database - construct it from the tag info we have CMusicInfoTag *tag = pItem->GetMusicInfoTag(); album.strAlbum = tag->GetAlbum(); album.strArtist = tag->GetAlbumArtist().IsEmpty() ? tag->GetArtist() : tag->GetAlbumArtist(); album.idAlbum = -1; // the -1 indicates it's not in the database } foundAlbum = true; } } if (!foundAlbum) { CLog::Log(LOGINFO, "%s called on a folder containing no songs with tag info - nothing can be done", __FUNCTION__); if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); return; } if (m_dlgProgress && bShowInfo) m_dlgProgress->Close(); } if (album.idAlbum == -1 && foundAlbum == false) ShowArtistInfo(artist, pItem->m_strPath, false, bShowInfo); else ShowAlbumInfo(album, strPath, false, bShowInfo); }