bool CGUIWindowMusicBase::GetDirectory(const std::string &strDirectory, CFileItemList &items) { items.SetArt("thumb", ""); bool bResult = CGUIMediaWindow::GetDirectory(strDirectory, items); if (bResult) { CMusicThumbLoader loader; loader.FillThumb(items); } CQueryParams params; map<string, string> art; CDirectoryNode::GetDatabaseInfo(items.GetPath(), params); if (params.GetAlbumId() && m_musicdatabase.GetArtistArtForItem(params.GetAlbumId(), MediaTypeAlbum, art)) items.AppendArt(art, MediaTypeAlbum); if (params.GetArtistId() && m_musicdatabase.GetArtForItem(params.GetArtistId(), MediaTypeArtist, art)) items.AppendArt(art, MediaTypeArtist); // add in the "New Playlist" item if we're in the playlists folder if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://")) { CFileItemPtr newPlaylist(new CFileItem(CProfilesManager::Get().GetUserDataItem("PartyMode.xsp"),false)); newPlaylist->SetLabel(g_localizeStrings.Get(16035)); newPlaylist->SetLabelPreformated(true); newPlaylist->m_bIsFolder = true; items.Add(newPlaylist); newPlaylist.reset(new CFileItem("newplaylist://", false)); newPlaylist->SetLabel(g_localizeStrings.Get(525)); newPlaylist->SetLabelPreformated(true); newPlaylist->SetSpecialSort(SortSpecialOnBottom); newPlaylist->SetCanQueue(false); items.Add(newPlaylist); newPlaylist.reset(new CFileItem("newsmartplaylist://music", false)); newPlaylist->SetLabel(g_localizeStrings.Get(21437)); newPlaylist->SetLabelPreformated(true); newPlaylist->SetSpecialSort(SortSpecialOnBottom); newPlaylist->SetCanQueue(false); items.Add(newPlaylist); } return bResult; }
bool CDirectoryNodeSong::GetContent(CFileItemList& items) const { CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return false; CQueryParams params; CollectQueryParams(params); CStdString strBaseDir = BuildPath(); bool bSuccess = musicdatabase.GetSongsNav(strBaseDir, items, params.GetGenreId(), params.GetArtistId(), params.GetAlbumId()); //spotify //TODO scan through all addons that provide songs, also create a better naming system for addon sources bSuccess = g_spotify->GetTracks(items, strBaseDir,musicdatabase.GetArtistById(params.GetArtistId()),params.GetAlbumId()); musicdatabase.Close(); return bSuccess; }
bool CDirectoryNodeAlbum::GetContent(CFileItemList& items) const { CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return false; CQueryParams params; CollectQueryParams(params); bool bSuccess=musicdatabase.GetAlbumsNav(BuildPath(), items, params.GetGenreId(), params.GetArtistId()); musicdatabase.Close(); return bSuccess; }
bool CDirectoryNodeSong::GetContent(CFileItemList& items) { CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return false; CQueryParams params; CollectQueryParams(params); CStdString strBaseDir=BuildPath(); bool bSuccess=musicdatabase.GetSongsNav(strBaseDir, items, params.GetGenreId(), params.GetArtistId(), params.GetAlbumId()); musicdatabase.Close(); return bSuccess; }
void CGUIDialogMusicInfo::ShowFor(CFileItem* pItem) { if (pItem->IsParentFolder() || URIUtils::IsSpecial(pItem->GetPath()) || StringUtils::StartsWithNoCase(pItem->GetPath(), "musicsearch://")) return; // nothing to do if (!pItem->m_bIsFolder) { // Show Song information dialog CGUIDialogSongInfo::ShowFor(pItem); return; } // We have a folder album/artist info dialog only shown for db items if (pItem->IsMusicDb()) { if (!pItem->HasMusicInfoTag() || pItem->GetMusicInfoTag()->GetDatabaseId() < 1) { // Maybe only path is set, then set MusicInfoTag CQueryParams params; CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params); if (params.GetAlbumId() == -1) pItem->GetMusicInfoTag()->SetDatabaseId(params.GetArtistId(), MediaTypeArtist); else pItem->GetMusicInfoTag()->SetDatabaseId(params.GetAlbumId(), MediaTypeAlbum); } CGUIDialogMusicInfo *pDlgMusicInfo = CServiceBroker::GetGUI()->GetWindowManager(). GetWindow<CGUIDialogMusicInfo>(WINDOW_DIALOG_MUSIC_INFO); if (pDlgMusicInfo) { if (pDlgMusicInfo->SetItem(pItem)) { pDlgMusicInfo->Open(); if (pItem->GetMusicInfoTag()->GetType() == MediaTypeAlbum && pDlgMusicInfo->HasUpdatedUserrating()) { auto window = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIWindowMusicBase>(WINDOW_MUSIC_NAV); if (window) window->RefreshContent("albums"); } } } } }
void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo) { if ((pItem->IsMusicDb() && !pItem->HasMusicInfoTag()) || pItem->IsParentFolder() || URIUtils::IsSpecial(pItem->GetPath()) || pItem->GetPath().Left(14).Equals("musicsearch://")) return; // nothing to do if (!pItem->m_bIsFolder) { // song lookup ShowSongInfo(pItem); return; } CStdString strPath = pItem->GetPath(); // 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->GetPath(), params); if (params.GetAlbumId() == -1) { // artist lookup artist.idArtist = params.GetArtistId(); artist.strArtist = StringUtils::Join(pItem->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator); } else { // album lookup album.idAlbum = params.GetAlbumId(); album.strAlbum = pItem->GetMusicInfoTag()->GetAlbum(); album.artist = 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.artist = tag->GetAlbumArtist().empty() ? 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->GetPath(), false, bShowInfo); else ShowAlbumInfo(album, strPath, false, bShowInfo); }
bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); switch (button) { case CONTEXT_BUTTON_INFO: { if (!item->IsVideoDb()) return CGUIWindowMusicBase::OnContextButton(itemNumber,button); // music videos - artists if (item->GetPath().Left(14).Equals("videodb://3/4/")) { long idArtist = m_musicdatabase.GetArtistByName(item->GetLabel()); if (idArtist == -1) return false; CStdString path; path.Format("musicdb://2/%ld/", idArtist); item->SetPath(path); CGUIWindowMusicBase::OnContextButton(itemNumber,button); Update(m_vecItems->GetPath()); m_viewControl.SetSelectedItem(itemNumber); return true; } // music videos - albums if (item->GetPath().Left(14).Equals("videodb://3/5/")) { long idAlbum = m_musicdatabase.GetAlbumByName(item->GetLabel()); if (idAlbum == -1) return false; CStdString path; path.Format("musicdb://3/%ld/", idAlbum); item->SetPath(path); CGUIWindowMusicBase::OnContextButton(itemNumber,button); Update(m_vecItems->GetPath()); m_viewControl.SetSelectedItem(itemNumber); return true; } if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strTitle.IsEmpty()) { CGUIWindowVideoNav* pWindow = (CGUIWindowVideoNav*)g_windowManager.GetWindow(WINDOW_VIDEO_NAV); if (pWindow) { ADDON::ScraperPtr info; pWindow->OnInfo(item.get(),info); Update(m_vecItems->GetPath()); } } return true; } case CONTEXT_BUTTON_INFO_ALL: OnInfoAll(itemNumber); return true; case CONTEXT_BUTTON_UPDATE_LIBRARY: { CGUIDialogMusicScan *scanner = (CGUIDialogMusicScan *)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN); if (scanner) scanner->StartScanning(""); return true; } case CONTEXT_BUTTON_SET_DEFAULT: g_settings.m_defaultMusicLibSource = GetQuickpathName(item->GetPath()); g_settings.Save(); return true; case CONTEXT_BUTTON_CLEAR_DEFAULT: g_settings.m_defaultMusicLibSource.Empty(); g_settings.Save(); return true; case CONTEXT_BUTTON_GO_TO_ARTIST: { CStdString strPath; CVideoDatabase database; database.Open(); strPath.Format("videodb://3/4/%ld/",database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtist())); g_windowManager.ActivateWindow(WINDOW_VIDEO_NAV,strPath); return true; } case CONTEXT_BUTTON_PLAY_OTHER: { CVideoDatabase database; database.Open(); CVideoInfoTag details; database.GetMusicVideoInfo("",details,database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtist(),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle())); g_application.getApplicationMessenger().PlayFile(CFileItem(details)); return true; } case CONTEXT_BUTTON_MARK_WATCHED: CGUIWindowVideoBase::MarkWatched(item,true); CUtil::DeleteVideoDatabaseDirectoryCache(); Update(m_vecItems->GetPath()); return true; case CONTEXT_BUTTON_MARK_UNWATCHED: CGUIWindowVideoBase::MarkWatched(item,false); CUtil::DeleteVideoDatabaseDirectoryCache(); Update(m_vecItems->GetPath()); return true; case CONTEXT_BUTTON_RENAME: CGUIWindowVideoBase::UpdateVideoTitle(item.get()); CUtil::DeleteVideoDatabaseDirectoryCache(); Update(m_vecItems->GetPath()); return true; case CONTEXT_BUTTON_DELETE: if (item->IsPlayList() || item->IsSmartPlayList()) { item->m_bIsFolder = false; CFileUtils::DeleteItem(item); } else { CGUIWindowVideoNav::DeleteItem(item.get()); CUtil::DeleteVideoDatabaseDirectoryCache(); } Update(m_vecItems->GetPath()); return true; case CONTEXT_BUTTON_SET_CONTENT: { bool bScan=false; ADDON::ScraperPtr scraper; CStdString path(item->GetPath()); CQueryParams params; CDirectoryNode::GetDatabaseInfo(item->GetPath(), params); CONTENT_TYPE content = CONTENT_ALBUMS; if (params.GetAlbumId() != -1) path.Format("musicdb://3/%i/",params.GetAlbumId()); else if (params.GetArtistId() != -1) { path.Format("musicdb://2/%i/",params.GetArtistId()); content = CONTENT_ARTISTS; } if (m_vecItems->GetPath().Equals("musicdb://1/") || item->GetPath().Equals("musicdb://2/")) { content = CONTENT_ARTISTS; } if (!m_musicdatabase.GetScraperForPath(path, scraper, ADDON::ScraperTypeFromContent(content))) { ADDON::AddonPtr defaultScraper; if (ADDON::CAddonMgr::Get().GetDefault(ADDON::ScraperTypeFromContent(content), defaultScraper)) { scraper = boost::dynamic_pointer_cast<ADDON::CScraper>(defaultScraper->Clone(defaultScraper)); } } if (CGUIDialogContentSettings::Show(scraper, bScan, content)) { m_musicdatabase.SetScraperForPath(path,scraper); if (bScan) OnInfoAll(itemNumber,true); } return true; } default: break; } return CGUIWindowMusicBase::OnContextButton(itemNumber, button); }
void CGUIWindowMusicBase::ShowArtistInfo(const CFileItem *pItem, bool bShowInfo /* = true */) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(pItem->GetPath(), params); ADDON::ScraperPtr scraper; if (!m_musicdatabase.GetScraperForPath(pItem->GetPath(), scraper, ADDON::ADDON_SCRAPER_ARTISTS)) return; CArtist artist; if (!m_musicdatabase.GetArtist(params.GetArtistId(), artist)) return; m_musicdatabase.GetArtistPath(params.GetArtistId(), artist.strPath); while (1) { // Check if we have the information in the database first if (!m_musicdatabase.HasArtistBeenScraped(params.GetArtistId())) { if (!CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() && !g_passwordManager.bMasterUser) break; // should display a dialog saying no permissions if (g_application.IsMusicScanning()) { CGUIDialogOK::ShowAndGetInput(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.UpdateDatabaseArtistInfo(artist, scraper, bShowInfo, m_dlgProgress) != INFO_ADDED) { CGUIDialogOK::ShowAndGetInput(CVariant{21889}, CVariant{20199}); break; } } if (m_dlgProgress) m_dlgProgress->Close(); CGUIDialogMusicInfo *pDlgArtistInfo = (CGUIDialogMusicInfo*)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_INFO); if (pDlgArtistInfo) { pDlgArtistInfo->SetArtist(artist, artist.strPath); pDlgArtistInfo->Open(); if (pDlgArtistInfo->NeedRefresh()) { m_musicdatabase.ClearArtistLastScrapedTime(params.GetArtistId()); continue; } else if (pDlgArtistInfo->HasUpdatedThumb()) { Update(m_vecItems->GetPath()); } } break; } if (m_dlgProgress) m_dlgProgress->Close(); }
bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); switch (button) { case CONTEXT_BUTTON_INFO: { if (!item->IsVideoDb()) return CGUIWindowMusicBase::OnContextButton(itemNumber,button); // music videos - artists if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/artists/")) { long idArtist = m_musicdatabase.GetArtistByName(item->GetLabel()); if (idArtist == -1) return false; CStdString path = StringUtils::Format("musicdb://artists/%ld/", idArtist); CArtist artist; m_musicdatabase.GetArtistInfo(idArtist,artist,false); *item = CFileItem(artist); item->SetPath(path); CGUIWindowMusicBase::OnContextButton(itemNumber,button); Refresh(); m_viewControl.SetSelectedItem(itemNumber); return true; } // music videos - albums if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/albums/")) { long idAlbum = m_musicdatabase.GetAlbumByName(item->GetLabel()); if (idAlbum == -1) return false; CStdString path = StringUtils::Format("musicdb://albums/%ld/", idAlbum); CAlbum album; m_musicdatabase.GetAlbumInfo(idAlbum,album,NULL); *item = CFileItem(path,album); item->SetPath(path); CGUIWindowMusicBase::OnContextButton(itemNumber,button); Refresh(); m_viewControl.SetSelectedItem(itemNumber); return true; } if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strTitle.empty()) { CGUIWindowVideoNav* pWindow = (CGUIWindowVideoNav*)g_windowManager.GetWindow(WINDOW_VIDEO_NAV); if (pWindow) { ADDON::ScraperPtr info; pWindow->OnInfo(item.get(),info); Refresh(); } } return true; } case CONTEXT_BUTTON_INFO_ALL: OnInfoAll(itemNumber); return true; case CONTEXT_BUTTON_SET_DEFAULT: CSettings::Get().SetString("mymusic.defaultlibview", GetQuickpathName(item->GetPath())); CSettings::Get().Save(); return true; case CONTEXT_BUTTON_CLEAR_DEFAULT: CSettings::Get().SetString("mymusic.defaultlibview", ""); CSettings::Get().Save(); return true; case CONTEXT_BUTTON_GO_TO_ARTIST: { CStdString strPath; CVideoDatabase database; database.Open(); strPath = StringUtils::Format("videodb://musicvideos/artists/%ld/", database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator))); g_windowManager.ActivateWindow(WINDOW_VIDEO_NAV,strPath); return true; } case CONTEXT_BUTTON_PLAY_OTHER: { CVideoDatabase database; database.Open(); CVideoInfoTag details; database.GetMusicVideoInfo("",details,database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle())); CApplicationMessenger::Get().PlayFile(CFileItem(details)); return true; } case CONTEXT_BUTTON_MARK_WATCHED: CGUIDialogVideoInfo::MarkWatched(item, true); CUtil::DeleteVideoDatabaseDirectoryCache(); Refresh(); return true; case CONTEXT_BUTTON_MARK_UNWATCHED: CGUIDialogVideoInfo::MarkWatched(item, false); CUtil::DeleteVideoDatabaseDirectoryCache(); Refresh(); return true; case CONTEXT_BUTTON_RENAME: CGUIDialogVideoInfo::UpdateVideoItemTitle(item); CUtil::DeleteVideoDatabaseDirectoryCache(); Refresh(); return true; case CONTEXT_BUTTON_DELETE: if (item->IsPlayList() || item->IsSmartPlayList()) { item->m_bIsFolder = false; CFileUtils::DeleteItem(item); } else { CGUIDialogVideoInfo::DeleteVideoItemFromDatabase(item); CUtil::DeleteVideoDatabaseDirectoryCache(); } Refresh(); return true; case CONTEXT_BUTTON_SET_CONTENT: { ADDON::ScraperPtr scraper; CStdString path(item->GetPath()); CQueryParams params; CDirectoryNode::GetDatabaseInfo(item->GetPath(), params); CONTENT_TYPE content = CONTENT_ALBUMS; if (params.GetAlbumId() != -1) path = StringUtils::Format("musicdb://albums/%i/",params.GetAlbumId()); else if (params.GetArtistId() != -1) { path = StringUtils::Format("musicdb://artists/%i/",params.GetArtistId()); content = CONTENT_ARTISTS; } if (m_vecItems->GetPath().Equals("musicdb://genres/") || item->GetPath().Equals("musicdb://artists/")) { content = CONTENT_ARTISTS; } if (!m_musicdatabase.GetScraperForPath(path, scraper, ADDON::ScraperTypeFromContent(content))) { ADDON::AddonPtr defaultScraper; if (ADDON::CAddonMgr::Get().GetDefault(ADDON::ScraperTypeFromContent(content), defaultScraper)) { scraper = boost::dynamic_pointer_cast<ADDON::CScraper>(defaultScraper->Clone()); } } if (CGUIDialogContentSettings::Show(scraper, content)) { m_musicdatabase.SetScraperForPath(path,scraper); if (CGUIDialogYesNo::ShowAndGetInput(20442,20443,20444,20022)) { OnInfoAll(itemNumber,true,true); } } return true; } default: break; } return CGUIWindowMusicBase::OnContextButton(itemNumber, button); }
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(); }
bool CGUIWindowMusicBase::GetDirectory(const std::string &strDirectory, CFileItemList &items) { items.ClearArt(); bool bResult = CGUIMediaWindow::GetDirectory(strDirectory, items); if (bResult) { CMusicThumbLoader loader; loader.FillThumb(items); CQueryParams params; CDirectoryNode::GetDatabaseInfo(items.GetPath(), params); if (params.GetAlbumId() > 0) { std::map<std::string, std::string> artistArt; if (m_musicdatabase.GetArtistArtForItem(params.GetAlbumId(), MediaTypeAlbum, artistArt)) items.AppendArt(artistArt, MediaTypeArtist); std::map<std::string, std::string> albumArt; if (m_musicdatabase.GetArtForItem(params.GetAlbumId(), MediaTypeAlbum, albumArt)) items.AppendArt(albumArt, MediaTypeAlbum); } if (params.GetArtistId() > 0) { std::map<std::string, std::string> artistArt; if (m_musicdatabase.GetArtForItem(params.GetArtistId(), "artist", artistArt)) items.AppendArt(artistArt, MediaTypeArtist); } // add in the "New Playlist" item if we're in the playlists folder if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://")) { CFileItemPtr newPlaylist(new CFileItem(CProfilesManager::GetInstance().GetUserDataItem("PartyMode.xsp"),false)); newPlaylist->SetLabel(g_localizeStrings.Get(16035)); newPlaylist->SetLabelPreformated(true); newPlaylist->m_bIsFolder = true; items.Add(newPlaylist); newPlaylist.reset(new CFileItem("newplaylist://", false)); newPlaylist->SetLabel(g_localizeStrings.Get(525)); newPlaylist->SetLabelPreformated(true); newPlaylist->SetSpecialSort(SortSpecialOnBottom); newPlaylist->SetCanQueue(false); items.Add(newPlaylist); newPlaylist.reset(new CFileItem("newsmartplaylist://music", false)); newPlaylist->SetLabel(g_localizeStrings.Get(21437)); newPlaylist->SetLabelPreformated(true); newPlaylist->SetSpecialSort(SortSpecialOnBottom); newPlaylist->SetCanQueue(false); items.Add(newPlaylist); } // check for .CUE files here. items.FilterCueItems(); std::string label; if (items.GetLabel().empty() && m_rootDir.IsSource(items.GetPath(), CMediaSourceSettings::GetInstance().GetSources("music"), &label)) items.SetLabel(label); } return bResult; }
void CMusicInfoScanner::Process() { ANNOUNCEMENT::CAnnouncementManager::Get().Announce(ANNOUNCEMENT::AudioLibrary, "xbmc", "OnScanStarted"); try { if (m_bClean) { CleanDatabase(false); m_bRunning = false; return; } unsigned int tick = XbmcThreads::SystemClockMillis(); m_musicDatabase.Open(); if (m_showDialog && !CSettings::Get().GetBool("musiclibrary.backgroundupdate")) { CGUIDialogExtendedProgressBar* dialog = (CGUIDialogExtendedProgressBar*)g_windowManager.GetWindow(WINDOW_DIALOG_EXT_PROGRESS); if (dialog) m_handle = dialog->GetHandle(g_localizeStrings.Get(314)); } m_bClean = g_advancedSettings.m_bMusicLibraryCleanOnUpdate; m_bCanInterrupt = true; if (m_scanType == 0) // load info from files { CLog::Log(LOGDEBUG, "%s - Starting scan", __FUNCTION__); if (m_handle) m_handle->SetTitle(g_localizeStrings.Get(505)); // Reset progress vars m_currentItem=0; m_itemCount=-1; // Create the thread to count all files to be scanned SetPriority( GetMinPriority() ); if (m_handle) m_fileCountReader.Create(); // Database operations should not be canceled // using Interupt() while scanning as it could // result in unexpected behaviour. m_bCanInterrupt = false; m_needsCleanup = false; bool commit = true; for (std::set<std::string>::const_iterator it = m_pathsToScan.begin(); it != m_pathsToScan.end(); it++) { if (!CDirectory::Exists(*it) && !m_bClean) { /* * Note that this will skip scanning (if m_bClean is disabled) if the directory really * doesn't exist. Since the music scanner is fed with a list of existing paths from the DB * and cleans out all songs under that path as its first step before re-adding files, if * the entire source is offline we totally empty the music database in one go. */ CLog::Log(LOGWARNING, "%s directory '%s' does not exist - skipping scan.", __FUNCTION__, it->c_str()); m_seenPaths.insert(*it); continue; } else if (!DoScan(*it)) { commit = false; break; } } if (commit) { g_infoManager.ResetLibraryBools(); if (m_needsCleanup) { if (m_handle) { m_handle->SetTitle(g_localizeStrings.Get(700)); m_handle->SetText(""); } m_musicDatabase.CleanupOrphanedItems(); if (m_handle) m_handle->SetTitle(g_localizeStrings.Get(331)); m_musicDatabase.Compress(false); } } m_fileCountReader.StopThread(); m_musicDatabase.EmptyCache(); tick = XbmcThreads::SystemClockMillis() - tick; CLog::Log(LOGNOTICE, "My Music: Scanning for music info using worker thread, operation took %s", StringUtils::SecondsToTimeString(tick / 1000).c_str()); } if (m_scanType == 1) // load album info { for (std::set<std::string>::const_iterator it = m_pathsToScan.begin(); it != m_pathsToScan.end(); ++it) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(*it, params); if (m_musicDatabase.HasAlbumBeenScraped(params.GetAlbumId())) // should this be here? continue; CAlbum album; m_musicDatabase.GetAlbum(params.GetAlbumId(), album); if (m_handle) { float percentage = (float) std::distance(it, m_pathsToScan.end()) / m_pathsToScan.size(); m_handle->SetText(StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator) + " - " + album.strAlbum); m_handle->SetPercentage(percentage); } // find album info ADDON::ScraperPtr scraper; if (!m_musicDatabase.GetScraperForPath(*it, scraper, ADDON::ADDON_SCRAPER_ALBUMS)) continue; UpdateDatabaseAlbumInfo(album, scraper, false); if (m_bStop) break; } } if (m_scanType == 2) // load artist info { for (std::set<std::string>::const_iterator it = m_pathsToScan.begin(); it != m_pathsToScan.end(); ++it) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(*it, params); if (m_musicDatabase.HasArtistBeenScraped(params.GetArtistId())) // should this be here? continue; CArtist artist; m_musicDatabase.GetArtist(params.GetArtistId(), artist); m_musicDatabase.GetArtistPath(params.GetArtistId(), artist.strPath); if (m_handle) { float percentage = (float) (std::distance(m_pathsToScan.begin(), it) / m_pathsToScan.size()) * 100; m_handle->SetText(artist.strArtist); m_handle->SetPercentage(percentage); } // find album info ADDON::ScraperPtr scraper; if (!m_musicDatabase.GetScraperForPath(*it, scraper, ADDON::ADDON_SCRAPER_ARTISTS) || !scraper) continue; UpdateDatabaseArtistInfo(artist, scraper, false); if (m_bStop) break; } } } catch (...) { CLog::Log(LOGERROR, "MusicInfoScanner: Exception while scanning."); } m_musicDatabase.Close(); CLog::Log(LOGDEBUG, "%s - Finished scan", __FUNCTION__); m_bRunning = false; ANNOUNCEMENT::CAnnouncementManager::Get().Announce(ANNOUNCEMENT::AudioLibrary, "xbmc", "OnScanFinished"); // we need to clear the musicdb cache and update any active lists CUtil::DeleteMusicDatabaseDirectoryCache(); CGUIMessage msg(GUI_MSG_SCAN_FINISHED, 0, 0, 0); g_windowManager.SendThreadMessage(msg); if (m_handle) m_handle->MarkFinished(); m_handle = NULL; }
bool CMusicDatabaseDirectory::GetLabel(const CStdString& strDirectory, CStdString& strLabel) { strLabel = ""; CStdString path = CLegacyPathTranslation::TranslateMusicDbPath(strDirectory); auto_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path)); if (!pNode.get()) return false; // first see if there's any filter criteria CQueryParams params; CDirectoryNode::GetDatabaseInfo(path, params); CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return false; // get genre if (params.GetGenreId() >= 0) strLabel += musicdatabase.GetGenreById(params.GetGenreId()); // get artist if (params.GetArtistId() >= 0) { if (!strLabel.empty()) strLabel += " / "; strLabel += musicdatabase.GetArtistById(params.GetArtistId()); } // get album if (params.GetAlbumId() >= 0) { if (!strLabel.empty()) strLabel += " / "; strLabel += musicdatabase.GetAlbumById(params.GetAlbumId()); } if (strLabel.empty()) { switch (pNode->GetChildType()) { case NODE_TYPE_TOP100: strLabel = g_localizeStrings.Get(271); // Top 100 break; case NODE_TYPE_GENRE: strLabel = g_localizeStrings.Get(135); // Genres break; case NODE_TYPE_ARTIST: strLabel = g_localizeStrings.Get(133); // Artists break; case NODE_TYPE_ALBUM: strLabel = g_localizeStrings.Get(132); // Albums break; case NODE_TYPE_ALBUM_RECENTLY_ADDED: case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS: strLabel = g_localizeStrings.Get(359); // Recently Added Albums break; case NODE_TYPE_ALBUM_RECENTLY_PLAYED: case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS: strLabel = g_localizeStrings.Get(517); // Recently Played Albums break; case NODE_TYPE_ALBUM_TOP100: case NODE_TYPE_ALBUM_TOP100_SONGS: strLabel = g_localizeStrings.Get(10505); // Top 100 Albums break; case NODE_TYPE_SINGLES: strLabel = g_localizeStrings.Get(1050); // Singles break; case NODE_TYPE_SONG: strLabel = g_localizeStrings.Get(134); // Songs break; case NODE_TYPE_SONG_TOP100: strLabel = g_localizeStrings.Get(10504); // Top 100 Songs break; case NODE_TYPE_YEAR: case NODE_TYPE_YEAR_ALBUM: case NODE_TYPE_YEAR_SONG: strLabel = g_localizeStrings.Get(652); // Years break; case NODE_TYPE_ALBUM_COMPILATIONS: case NODE_TYPE_ALBUM_COMPILATIONS_SONGS: strLabel = g_localizeStrings.Get(521); break; case NODE_TYPE_OVERVIEW: strLabel = ""; break; default: CLog::Log(LOGWARNING, "%s - Unknown nodetype requested %d", __FUNCTION__, pNode->GetChildType()); return false; } } return true; }
bool CGUIWindowMusicNav::ManageInfoProvider(const CFileItemPtr item) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(item->GetPath(), params); // Management of Info provider only valid for specific artist or album items if (params.GetAlbumId() == -1 && params.GetArtistId() == -1) return false; // Set things up for processing artist or albums CONTENT_TYPE content = CONTENT_ALBUMS; int id = params.GetAlbumId(); if (id == -1) { content = CONTENT_ARTISTS; id = params.GetArtistId(); } ADDON::ScraperPtr scraper; // Get specific scraper and settings for current item or use default if (!m_musicdatabase.GetScraper(id, content, scraper)) { ADDON::AddonPtr defaultScraper; if (ADDON::CAddonSystemSettings::GetInstance().GetActive( ADDON::ScraperTypeFromContent(content), defaultScraper)) { scraper = std::dynamic_pointer_cast<ADDON::CScraper>(defaultScraper); } } // Set Information provider and settings int applyto = CGUIDialogInfoProviderSettings::Show(scraper); if (applyto >= 0) { bool result = false; CVariant msgctxt; switch (applyto) { case INFOPROVIDERAPPLYOPTIONS::INFOPROVIDER_THISITEM: // Change information provider for specific item result = m_musicdatabase.SetScraper(id, content, scraper); break; case INFOPROVIDERAPPLYOPTIONS::INFOPROVIDER_ALLVIEW: // Change information provider for the filtered items shown on this node { msgctxt = 38069; if (content == CONTENT_ARTISTS) msgctxt = 38068; if (CGUIDialogYesNo::ShowAndGetInput(CVariant{ 20195 }, msgctxt)) // Change information provider, confirm for all shown { // Set scraper for all items on curent view. std::string strPath = "musicdb://"; if (content == CONTENT_ARTISTS) strPath += "artists"; else strPath += "albums"; URIUtils::AddSlashAtEnd(strPath); // Items on view could be limited by navigation criteria, smart playlist rules or a filter. // Get these options, except ID, from item path CURL musicUrl(item->GetPath()); //Use CURL, as CMusicDbUrl removes "filter" option if (content == CONTENT_ARTISTS) musicUrl.RemoveOption("artistid"); else musicUrl.RemoveOption("albumid"); strPath += musicUrl.GetOptions(); result = m_musicdatabase.SetScraperAll(strPath, scraper); } } break; case INFOPROVIDERAPPLYOPTIONS::INFOPROVIDER_DEFAULT: // Change information provider for all items { msgctxt = 38071; if (content == CONTENT_ARTISTS) msgctxt = 38070; if (CGUIDialogYesNo::ShowAndGetInput(CVariant{20195}, msgctxt)) // Change information provider, confirm default and clear { // Save scraper addon default setting values scraper->SaveSettings(); // Set default scraper if (content == CONTENT_ARTISTS) CServiceBroker::GetSettings()->SetString(CSettings::SETTING_MUSICLIBRARY_ARTISTSSCRAPER, scraper->ID()); else CServiceBroker::GetSettings()->SetString(CSettings::SETTING_MUSICLIBRARY_ALBUMSSCRAPER, scraper->ID()); CServiceBroker::GetSettings()->Save(); // Clear all item specifc settings if (content == CONTENT_ARTISTS) result = m_musicdatabase.SetScraperAll("musicdb://artists/", nullptr); else result = m_musicdatabase.SetScraperAll("musicdb://albums/", nullptr); } } default: break; } if (!result) return false; // Refresh additional information using the new settings if (applyto == INFOPROVIDERAPPLYOPTIONS::INFOPROVIDER_ALLVIEW || applyto == INFOPROVIDERAPPLYOPTIONS::INFOPROVIDER_DEFAULT) { // Change information provider, all artists or albums if (CGUIDialogYesNo::ShowAndGetInput(CVariant{20195}, CVariant{38072})) OnItemInfoAll(m_vecItems->GetPath(), true); } else { // Change information provider, selected artist or album if (CGUIDialogYesNo::ShowAndGetInput(CVariant{20195}, CVariant{38073})) { std::string itempath = StringUtils::Format("musicdb://albums/%li/", id); if (content == CONTENT_ARTISTS) itempath = StringUtils::Format("musicdb://artists/%li/", id); OnItemInfoAll(itempath, true); } } } return true; }
bool CGUIWindowMusicNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); switch (button) { case CONTEXT_BUTTON_INFO: { if (!item->IsVideoDb()) return CGUIWindowMusicBase::OnContextButton(itemNumber,button); // music videos - artists if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/artists/")) { long idArtist = m_musicdatabase.GetArtistByName(item->GetLabel()); if (idArtist == -1) return false; std::string path = StringUtils::Format("musicdb://artists/%ld/", idArtist); CArtist artist; m_musicdatabase.GetArtist(idArtist, artist, false); *item = CFileItem(artist); item->SetPath(path); CGUIWindowMusicBase::OnContextButton(itemNumber,button); Refresh(); m_viewControl.SetSelectedItem(itemNumber); return true; } // music videos - albums if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/albums/")) { long idAlbum = m_musicdatabase.GetAlbumByName(item->GetLabel()); if (idAlbum == -1) return false; std::string path = StringUtils::Format("musicdb://albums/%ld/", idAlbum); CAlbum album; m_musicdatabase.GetAlbum(idAlbum, album, false); *item = CFileItem(path,album); item->SetPath(path); CGUIWindowMusicBase::OnContextButton(itemNumber,button); Refresh(); m_viewControl.SetSelectedItem(itemNumber); return true; } if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strTitle.empty()) { CGUIDialogVideoInfo::ShowFor(*item); Refresh(); } return true; } case CONTEXT_BUTTON_INFO_ALL: OnItemInfoAll(itemNumber); return true; case CONTEXT_BUTTON_SET_DEFAULT: CSettings::GetInstance().SetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW, GetQuickpathName(item->GetPath())); CSettings::GetInstance().Save(); return true; case CONTEXT_BUTTON_CLEAR_DEFAULT: CSettings::GetInstance().SetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW, ""); CSettings::GetInstance().Save(); return true; case CONTEXT_BUTTON_GO_TO_ARTIST: { std::string strPath; CVideoDatabase database; database.Open(); strPath = StringUtils::Format("videodb://musicvideos/artists/%i/", database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtistString())); g_windowManager.ActivateWindow(WINDOW_VIDEO_NAV,strPath); return true; } case CONTEXT_BUTTON_PLAY_OTHER: { CVideoDatabase database; database.Open(); CVideoInfoTag details; database.GetMusicVideoInfo("", details, database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtistString(), item->GetMusicInfoTag()->GetAlbum(), item->GetMusicInfoTag()->GetTitle())); CApplicationMessenger::GetInstance().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(details))); return true; } case CONTEXT_BUTTON_RENAME: if (!item->IsVideoDb() && !item->IsReadOnly()) OnRenameItem(itemNumber); CGUIDialogVideoInfo::UpdateVideoItemTitle(item); CUtil::DeleteVideoDatabaseDirectoryCache(); Refresh(); return true; case CONTEXT_BUTTON_DELETE: if (item->IsPlayList() || item->IsSmartPlayList()) { item->m_bIsFolder = false; CFileUtils::DeleteItem(item); } else if (!item->IsVideoDb()) OnDeleteItem(itemNumber); else { CGUIDialogVideoInfo::DeleteVideoItemFromDatabase(item); CUtil::DeleteVideoDatabaseDirectoryCache(); } Refresh(); return true; case CONTEXT_BUTTON_SET_CONTENT: { ADDON::ScraperPtr scraper; std::string path(item->GetPath()); CQueryParams params; CDirectoryNode::GetDatabaseInfo(item->GetPath(), params); CONTENT_TYPE content = CONTENT_ALBUMS; if (params.GetAlbumId() != -1) path = StringUtils::Format("musicdb://albums/%li/",params.GetAlbumId()); else if (params.GetArtistId() != -1) { path = StringUtils::Format("musicdb://artists/%li/",params.GetArtistId()); content = CONTENT_ARTISTS; } if (m_vecItems->IsPath("musicdb://genres/") || item->IsPath("musicdb://artists/")) { content = CONTENT_ARTISTS; } if (!m_musicdatabase.GetScraperForPath(path, scraper, ADDON::ScraperTypeFromContent(content))) { ADDON::AddonPtr defaultScraper; if (ADDON::CAddonMgr::GetInstance().GetDefault(ADDON::ScraperTypeFromContent(content), defaultScraper)) { scraper = std::dynamic_pointer_cast<ADDON::CScraper>(defaultScraper); } } if (CGUIDialogContentSettings::Show(scraper, content)) { m_musicdatabase.SetScraperForPath(path,scraper); if (CGUIDialogYesNo::ShowAndGetInput(CVariant{20442}, CVariant{20443})) { OnItemInfoAll(itemNumber,true,true); } } return true; } default: break; } return CGUIWindowMusicBase::OnContextButton(itemNumber, button); }
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); }
void CGUIWindowMusicBase::OnInfo(CFileItem *pItem, bool bShowInfo) { if (pItem->m_bIsFolder && pItem->IsParentFolder()) return; if (pItem->IsVideoDb()) { OnContextButton(m_viewControl.GetSelectedItem(), CONTEXT_BUTTON_INFO); // nasty but it is the same item i promise :) 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; if (pItem->IsMusicDb()) { CQueryParams params; CDirectoryNode::GetDatabaseInfo(pItem->m_strPath, params); if (params.GetAlbumId() == -1) { artist.idArtist = params.GetArtistId(); artist.strArtist = pItem->GetMusicInfoTag()->GetArtist(); } else { // 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; } 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 { // lookup is done on a folder - find the albums in the folder CFileItemList items; GetDirectory(strPath, items); // check the first song we find in the folder, and grab it's album info for (int i = 0; i < items.Size() && !foundAlbum; i++) { CFileItem* 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(); } } 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); }
bool CMusicDbUrl::parse() { // the URL must start with musicdb:// if (m_url.GetProtocol() != "musicdb" || m_url.GetFileName().empty()) return false; CStdString path = m_url.Get(); NODE_TYPE dirType = CMusicDatabaseDirectory::GetDirectoryType(path); NODE_TYPE childType = CMusicDatabaseDirectory::GetDirectoryChildType(path); switch (dirType) { case NODE_TYPE_ARTIST: m_type = "artists"; break; case NODE_TYPE_ALBUM: case NODE_TYPE_ALBUM_RECENTLY_ADDED: case NODE_TYPE_ALBUM_RECENTLY_PLAYED: case NODE_TYPE_ALBUM_TOP100: case NODE_TYPE_ALBUM_COMPILATIONS: case NODE_TYPE_YEAR_ALBUM: m_type = "albums"; break; case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS: case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS: case NODE_TYPE_ALBUM_TOP100_SONGS: case NODE_TYPE_ALBUM_COMPILATIONS_SONGS: case NODE_TYPE_SONG: case NODE_TYPE_SONG_TOP100: case NODE_TYPE_YEAR_SONG: case NODE_TYPE_SINGLES: m_type = "songs"; break; default: break; } switch (childType) { case NODE_TYPE_ARTIST: m_type = "artists"; break; case NODE_TYPE_ALBUM: case NODE_TYPE_ALBUM_RECENTLY_ADDED: case NODE_TYPE_ALBUM_RECENTLY_PLAYED: case NODE_TYPE_ALBUM_TOP100: case NODE_TYPE_YEAR_ALBUM: m_type = "albums"; break; case NODE_TYPE_SONG: case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS: case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS: case NODE_TYPE_ALBUM_TOP100_SONGS: case NODE_TYPE_ALBUM_COMPILATIONS_SONGS: case NODE_TYPE_SONG_TOP100: case NODE_TYPE_YEAR_SONG: case NODE_TYPE_SINGLES: m_type = "songs"; break; case NODE_TYPE_GENRE: m_type = "genres"; break; case NODE_TYPE_YEAR: m_type = "years"; break; case NODE_TYPE_ALBUM_COMPILATIONS: m_type = "albums"; break; case NODE_TYPE_TOP100: m_type = "top100"; break; case NODE_TYPE_ROOT: case NODE_TYPE_OVERVIEW: default: return false; } if (m_type.empty()) return false; // parse query params CQueryParams queryParams; CDirectoryNode::GetDatabaseInfo(path, queryParams); // retrieve and parse all options AddOptions(m_url.GetOptions()); // add options based on the node type if (dirType == NODE_TYPE_SINGLES || childType == NODE_TYPE_SINGLES) AddOption("singles", true); // add options based on the QueryParams if (queryParams.GetArtistId() != -1) AddOption("artistid", (int)queryParams.GetArtistId()); if (queryParams.GetAlbumId() != -1) AddOption("albumid", (int)queryParams.GetAlbumId()); if (queryParams.GetGenreId() != -1) AddOption("genreid", (int)queryParams.GetGenreId()); if (queryParams.GetSongId() != -1) AddOption("songid", (int)queryParams.GetSongId()); if (queryParams.GetYear() != -1) AddOption("year", (int)queryParams.GetYear()); return true; }
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(); }