bool CMusicAlbumInfo::Load(XFILE::CCurlFile& http, const ADDON::ScraperPtr& scraper) { bool fSuccess = scraper->GetAlbumDetails(http, m_albumURL, m_album); if (fSuccess && m_strTitle2.empty()) m_strTitle2 = m_album.strAlbum; SetLoaded(fSuccess); return fSuccess; }
int CGUIDialogInfoProviderSettings::Show(ADDON::ScraperPtr& scraper) { CGUIDialogInfoProviderSettings *dialog = CServiceBroker::GetGUI()->GetWindowManager().GetWindow<CGUIDialogInfoProviderSettings>(WINDOW_DIALOG_INFOPROVIDER_SETTINGS); if (!dialog || !scraper) return -1; if (scraper->Content() != CONTENT_ARTISTS && scraper->Content() != CONTENT_ALBUMS) return -1; dialog->m_showSingleScraper = true; dialog->m_singleScraperType = scraper->Content(); if (dialog->m_singleScraperType == CONTENT_ALBUMS) dialog->SetAlbumScraper(scraper); else dialog->SetArtistScraper(scraper); // toast selected but disabled scrapers if (CServiceBroker::GetAddonMgr().IsAddonDisabled(scraper->ID())) CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(24024), scraper->Name(), 2000, true); dialog->Open(); bool confirmed = dialog->IsConfirmed(); unsigned int applyToItems = dialog->m_applyToItems; if (confirmed) { if (dialog->m_singleScraperType == CONTENT_ALBUMS) scraper = dialog->GetAlbumScraper(); else { scraper = dialog->GetArtistScraper(); // Save artist information folder (here not in the caller) when applying setting as default for all artists if (applyToItems == INFOPROVIDERAPPLYOPTIONS::INFOPROVIDER_DEFAULT) CServiceBroker::GetSettings().SetString(CSettings::SETTING_MUSICLIBRARY_ARTISTSFOLDER, dialog->m_strArtistInfoPath); } if (scraper) scraper->SetPathSettings(dialog->m_singleScraperType, ""); } dialog->ResetDefaults(); if (confirmed) return applyToItems; else return -1; }
void CGUIWindowVideoNav::OnItemInfo(const CFileItem& fileItem, ADDON::ScraperPtr& scraper) { if (!scraper || scraper->Content() == CONTENT_NONE) { m_database.Open(); // since we can be called from the music library without being inited if (fileItem.IsVideoDb()) scraper = m_database.GetScraperForPath(fileItem.GetVideoInfoTag()->m_strPath); else { std::string strPath,strFile; URIUtils::Split(fileItem.GetPath(),strPath,strFile); scraper = m_database.GetScraperForPath(strPath); } m_database.Close(); } CGUIWindowVideoBase::OnItemInfo(fileItem, scraper); }
bool CVideoLibraryRefreshingJob::Work(CVideoDatabase &db) { if (m_item == nullptr) return false; // determine the scraper for the item's path VIDEO::SScanSettings scanSettings; ADDON::ScraperPtr scraper = db.GetScraperForPath(m_item->GetPath(), scanSettings); if (scraper == nullptr) return false; // copy the scraper in case we need it again ADDON::ScraperPtr originalScraper(scraper); // get the item's correct title std::string itemTitle = m_searchTitle; if (itemTitle.empty()) itemTitle = m_item->GetMovieName(scanSettings.parent_name); CScraperUrl scraperUrl; VIDEO::CVideoInfoScanner scanner; bool needsRefresh = m_forceRefresh; bool hasDetails = false; bool ignoreNfo = m_ignoreNfo; // run this in a loop in case we need to refresh again bool failure = false; do { if (!ignoreNfo) { // check if there's an NFO for the item CNfoFile::NFOResult nfoResult = scanner.CheckForNFOFile(m_item.get(), scanSettings.parent_name_root, scraper, scraperUrl); // if there's no NFO remember it in case we have to refresh again if (nfoResult == CNfoFile::ERROR_NFO) ignoreNfo = true; else if (nfoResult != CNfoFile::NO_NFO) hasDetails = true; // if we are performing a forced refresh ask the user to choose between using a valid NFO and a valid scraper if (needsRefresh && IsModal() && !scraper->IsNoop() && (nfoResult == CNfoFile::URL_NFO || nfoResult == CNfoFile::COMBINED_NFO || nfoResult == CNfoFile::FULL_NFO)) { int heading = 20159; if (scraper->Content() == CONTENT_MOVIES) heading = 13346; else if (scraper->Content() == CONTENT_TVSHOWS) heading = m_item->m_bIsFolder ? 20351 : 20352; else if (scraper->Content() == CONTENT_MUSICVIDEOS) heading = 20393; if (CGUIDialogYesNo::ShowAndGetInput(heading, 20446)) { hasDetails = false; ignoreNfo = true; scraperUrl.Clear(); scraper = originalScraper; } } } // no need to re-fetch the episode guide for episodes if (scraper->Content() == CONTENT_TVSHOWS && !m_item->m_bIsFolder) hasDetails = true; // if we don't have an url or need to refresh anyway do the web search if (!hasDetails && (needsRefresh || scraperUrl.m_url.empty())) { SetTitle(StringUtils::Format(g_localizeStrings.Get(197).c_str(), scraper->Name().c_str())); SetText(itemTitle); SetProgress(0); // clear any cached data from the scraper scraper->ClearCache(); // create the info downloader for the scraper CVideoInfoDownloader infoDownloader(scraper); // try to find a matching item MOVIELIST itemResultList; int result = infoDownloader.FindMovie(itemTitle, itemResultList, GetProgressDialog()); // close the progress dialog MarkFinished(); if (result > 0) { // there are multiple matches for the item if (!itemResultList.empty()) { // choose the first match if (!IsModal()) scraperUrl = itemResultList.at(0); else { // ask the user what to do CGUIDialogSelect* selectDialog = static_cast<CGUIDialogSelect*>(g_windowManager.GetWindow(WINDOW_DIALOG_SELECT)); selectDialog->Reset(); selectDialog->SetHeading(scraper->Content() == CONTENT_TVSHOWS ? 20356 : 196); for (const auto& itemResult : itemResultList) selectDialog->Add(itemResult.strTitle); selectDialog->EnableButton(true, 413); // "Manual" selectDialog->Open(); // check if the user has chosen one of the results int selectedItem = selectDialog->GetSelectedItem(); if (selectedItem >= 0) scraperUrl = itemResultList.at(selectedItem); // the user hasn't chosen one of the results and but has chosen to manually enter a title to use else if (selectDialog->IsButtonPressed()) { // ask the user to input a title to use if (!CGUIKeyboardFactory::ShowAndGetInput(itemTitle, g_localizeStrings.Get(scraper->Content() == CONTENT_TVSHOWS ? 20357 : 16009), false)) return false; // go through the whole process again needsRefresh = true; continue; } // nothing else we can do else return false; } CLog::Log(LOGDEBUG, "CVideoLibraryRefreshingJob: user selected item '%s' with URL '%s'", scraperUrl.strTitle.c_str(), scraperUrl.m_url.at(0).m_url.c_str()); } } else if (result < 0 || !VIDEO::CVideoInfoScanner::DownloadFailed(GetProgressDialog())) { failure = true; break; } } // if the URL is still empty, check whether or not we're allowed // to prompt and ask the user to input a new search title if (!hasDetails && scraperUrl.m_url.empty()) { if (IsModal()) { // ask the user to input a title to use if (!CGUIKeyboardFactory::ShowAndGetInput(itemTitle, g_localizeStrings.Get(scraper->Content() == CONTENT_TVSHOWS ? 20357 : 16009), false)) return false; // go through the whole process again needsRefresh = true; continue; } // nothing else we can do failure = true; break; } // before we start downloading all the necessary information cleanup any existing artwork and hashes CTextureDatabase textureDb; if (textureDb.Open()) { for (const auto& artwork : m_item->GetArt()) textureDb.InvalidateCachedTexture(artwork.second); textureDb.Close(); } m_item->ClearArt(); // put together the list of items to refresh std::string path = m_item->GetPath(); CFileItemList items; if (m_item->HasVideoInfoTag() && m_item->GetVideoInfoTag()->m_iDbId > 0) { // for a tvshow we need to handle all paths of it std::vector<std::string> tvshowPaths; if (CMediaTypes::IsMediaType(m_item->GetVideoInfoTag()->m_type, MediaTypeTvShow) && m_refreshAll && db.GetPathsLinkedToTvShow(m_item->GetVideoInfoTag()->m_iDbId, tvshowPaths)) { for (const auto& tvshowPath : tvshowPaths) { CFileItemPtr tvshowItem(new CFileItem(*m_item->GetVideoInfoTag())); tvshowItem->SetPath(tvshowPath); items.Add(tvshowItem); } } // otherwise just add a copy of the item else items.Add(CFileItemPtr(new CFileItem(*m_item->GetVideoInfoTag()))); // update the path to the real path (instead of a videodb:// one) path = m_item->GetVideoInfoTag()->m_strPath; } else items.Add(CFileItemPtr(new CFileItem(*m_item))); // set the proper path of the list of items to lookup items.SetPath(m_item->m_bIsFolder ? URIUtils::GetParentPath(path) : URIUtils::GetDirectory(path)); int headingLabel = 198; if (scraper->Content() == CONTENT_TVSHOWS) { if (m_item->m_bIsFolder) headingLabel = 20353; else headingLabel = 20361; } else if (scraper->Content() == CONTENT_MUSICVIDEOS) headingLabel = 20394; // prepare the progress dialog for downloading all the necessary information SetTitle(g_localizeStrings.Get(headingLabel)); SetText(scraperUrl.strTitle); SetProgress(0); // remove any existing data for the item we're going to refresh if (m_item->GetVideoInfoTag()->m_iDbId > 0) { int dbId = m_item->GetVideoInfoTag()->m_iDbId; if (scraper->Content() == CONTENT_MOVIES) db.DeleteMovie(dbId); else if (scraper->Content() == CONTENT_MUSICVIDEOS) db.DeleteMusicVideo(dbId); else if (scraper->Content() == CONTENT_TVSHOWS) { if (!m_item->m_bIsFolder) db.DeleteEpisode(dbId); else if (m_refreshAll) db.DeleteTvShow(dbId); else db.DeleteDetailsForTvShow(dbId); } } // finally download the information for the item if (!scanner.RetrieveVideoInfo(items, scanSettings.parent_name, scraper->Content(), !ignoreNfo, &scraperUrl, m_refreshAll, GetProgressDialog())) { // something went wrong MarkFinished(); // check if the user cancelled if (!IsCancelled() && IsModal()) CGUIDialogOK::ShowAndGetInput(195, itemTitle); return false; } // retrieve the updated information from the database if (scraper->Content() == CONTENT_MOVIES) db.GetMovieInfo(m_item->GetPath(), *m_item->GetVideoInfoTag()); else if (scraper->Content() == CONTENT_MUSICVIDEOS) db.GetMusicVideoInfo(m_item->GetPath(), *m_item->GetVideoInfoTag()); else if (scraper->Content() == CONTENT_TVSHOWS) { // update tvshow info to get updated episode numbers if (m_item->m_bIsFolder) db.GetTvShowInfo(m_item->GetPath(), *m_item->GetVideoInfoTag()); else db.GetEpisodeInfo(m_item->GetPath(), *m_item->GetVideoInfoTag()); } // we're finally done MarkFinished(); break; } while (needsRefresh); if (failure && IsModal()) CGUIDialogOK::ShowAndGetInput(195, itemTitle); return true; }
bool CMusicInfoScanner::DownloadArtistInfo(const CStdString& strPath, const CStdString& strArtist, bool& bCanceled, CGUIDialogProgress* pDialog) { XFILE::MUSICDATABASEDIRECTORY::CQueryParams params; XFILE::MUSICDATABASEDIRECTORY::CDirectoryNode::GetDatabaseInfo(strPath, params); bCanceled = false; CArtist artist; m_musicDatabase.Open(); if (m_musicDatabase.GetArtistInfo(params.GetArtistId(),artist)) // already got the info return true; // find artist info ADDON::ScraperPtr info; if (!m_musicDatabase.GetScraperForPath(strPath, info, ADDON::ADDON_SCRAPER_ARTISTS) || !info) { m_musicDatabase.Close(); return false; } if (m_handle) { m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20320), info->Name().c_str())); m_handle->SetText(strArtist); } // clear our scraper cache info->ClearCache(); CMusicInfoScraper scraper(info); // handle nfo files CStdString strArtistPath, strNfo; m_musicDatabase.GetArtistPath(params.GetArtistId(),strArtistPath); URIUtils::AddFileToFolder(strArtistPath,"artist.nfo",strNfo); CNfoFile::NFOResult result=CNfoFile::NO_NFO; CNfoFile nfoReader; if (XFILE::CFile::Exists(strNfo)) { CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str()); result = nfoReader.Create(strNfo, info); if (result == CNfoFile::FULL_NFO) { CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__); CArtist artist; nfoReader.GetDetails(artist); m_musicDatabase.SetArtistInfo(params.GetArtistId(), artist); map<string, string> artwork = GetArtistArtwork(params.GetArtistId(), &artist); m_musicDatabase.SetArtForItem(params.GetArtistId(), "artist", artwork); m_musicDatabase.Close(); return true; } else if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO) { CScraperUrl scrUrl(nfoReader.ScraperUrl()); CMusicArtistInfo artist("nfo",scrUrl); info = nfoReader.GetScraperInfo(); CLog::Log(LOGDEBUG,"-- nfo-scraper: %s",info->Name().c_str()); CLog::Log(LOGDEBUG,"-- nfo url: %s", scrUrl.m_url[0].m_url.c_str()); scraper.SetScraperInfo(info); scraper.GetArtists().push_back(artist); } else CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str()); } if (!scraper.GetArtistCount()) { scraper.FindArtistInfo(strArtist); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); bCanceled = true; } Sleep(1); } } int iSelectedArtist = 0; if (result == CNfoFile::NO_NFO) { if (scraper.Succeeded() && scraper.GetArtistCount() >= 1) { // now load the first match if (pDialog && scraper.GetArtistCount() > 1) { // if we found more then 1 album, let user choose one CGUIDialogSelect *pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (pDlg) { pDlg->SetHeading(g_localizeStrings.Get(21890)); pDlg->Reset(); pDlg->EnableButton(true, 413); // manual for (int i = 0; i < scraper.GetArtistCount(); ++i) { // set the label to artist CFileItem item(scraper.GetArtist(i).GetArtist()); CStdString strTemp=scraper.GetArtist(i).GetArtist().strArtist; if (!scraper.GetArtist(i).GetArtist().strBorn.IsEmpty()) strTemp += " ("+scraper.GetArtist(i).GetArtist().strBorn+")"; if (!scraper.GetArtist(i).GetArtist().genre.empty()) { CStdString genres = StringUtils::Join(scraper.GetArtist(i).GetArtist().genre, g_advancedSettings.m_musicItemSeparator); if (!genres.empty()) strTemp.Format("[%s] %s", genres.c_str(), strTemp.c_str()); } item.SetLabel(strTemp); item.m_idepth = i; // use this to hold the index of the album in the scraper pDlg->Add(&item); } pDlg->DoModal(); // and wait till user selects one if (pDlg->GetSelectedLabel() < 0) { // none chosen if (!pDlg->IsButtonPressed()) { bCanceled = true; return false; } // manual button pressed CStdString strNewArtist = strArtist; if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false; if (pDialog) { pDialog->SetLine(0, strNewArtist); pDialog->Progress(); } m_musicDatabase.Close(); return DownloadArtistInfo(strPath,strNewArtist,bCanceled,pDialog); } iSelectedArtist = pDlg->GetSelectedItem()->m_idepth; } } } else { m_musicDatabase.Close(); return false; } } scraper.LoadArtistInfo(iSelectedArtist, strArtist); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); bCanceled = true; } Sleep(1); } if (scraper.Succeeded()) { artist = scraper.GetArtist(iSelectedArtist).GetArtist(); if (result == CNfoFile::COMBINED_NFO) nfoReader.GetDetails(artist,NULL,true); m_musicDatabase.SetArtistInfo(params.GetArtistId(), artist); } // check thumb stuff map<string, string> artwork = GetArtistArtwork(params.GetArtistId(), &artist); m_musicDatabase.SetArtForItem(params.GetArtistId(), "artist", artwork); m_musicDatabase.Close(); return true; }
bool CMusicInfoScanner::DownloadAlbumInfo(const CStdString& strPath, const CStdString& strArtist, const CStdString& strAlbum, bool& bCanceled, CMusicAlbumInfo& albumInfo, CGUIDialogProgress* pDialog) { CAlbum album; VECSONGS songs; XFILE::MUSICDATABASEDIRECTORY::CQueryParams params; XFILE::MUSICDATABASEDIRECTORY::CDirectoryNode::GetDatabaseInfo(strPath, params); bCanceled = false; m_musicDatabase.Open(); if (m_musicDatabase.HasAlbumInfo(params.GetAlbumId()) && m_musicDatabase.GetAlbumInfo(params.GetAlbumId(),album,&songs)) return true; // find album info ADDON::ScraperPtr info; if (!m_musicDatabase.GetScraperForPath(strPath, info, ADDON::ADDON_SCRAPER_ALBUMS) || !info) { m_musicDatabase.Close(); return false; } if (m_handle) { m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20321), info->Name().c_str())); m_handle->SetText(strArtist+" - "+strAlbum); } // clear our scraper cache info->ClearCache(); CMusicInfoScraper scraper(info); // handle nfo files CStdString strAlbumPath, strNfo; m_musicDatabase.GetAlbumPath(params.GetAlbumId(),strAlbumPath); URIUtils::AddFileToFolder(strAlbumPath,"album.nfo",strNfo); CNfoFile::NFOResult result=CNfoFile::NO_NFO; CNfoFile nfoReader; if (XFILE::CFile::Exists(strNfo)) { CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str()); result = nfoReader.Create(strNfo, info, -1, strPath); if (result == CNfoFile::FULL_NFO) { CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__); CAlbum album; nfoReader.GetDetails(album); m_musicDatabase.SetAlbumInfo(params.GetAlbumId(), album, album.songs); GetAlbumArtwork(params.GetAlbumId(), album); m_musicDatabase.Close(); return true; } else if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO) { CScraperUrl scrUrl(nfoReader.ScraperUrl()); CMusicAlbumInfo album("nfo",scrUrl); info = nfoReader.GetScraperInfo(); CLog::Log(LOGDEBUG,"-- nfo-scraper: %s",info->Name().c_str()); CLog::Log(LOGDEBUG,"-- nfo url: %s", scrUrl.m_url[0].m_url.c_str()); scraper.SetScraperInfo(info); scraper.GetAlbums().push_back(album); } else CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str()); } if (!scraper.CheckValidOrFallback(g_guiSettings.GetString("musiclibrary.albumsscraper"))) { // the current scraper is invalid, as is the default - bail CLog::Log(LOGERROR, "%s - current and default scrapers are invalid. Pick another one", __FUNCTION__); return false; } if (!scraper.GetAlbumCount()) { scraper.FindAlbumInfo(strAlbum, strArtist); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); bCanceled = true; } Sleep(1); } } CGUIDialogSelect *pDlg=NULL; int iSelectedAlbum=0; if (result == CNfoFile::NO_NFO) { iSelectedAlbum = -1; // set negative so that we can detect a failure if (scraper.Succeeded() && scraper.GetAlbumCount() >= 1) { int bestMatch = -1; double bestRelevance = 0; double minRelevance = THRESHOLD; if (scraper.GetAlbumCount() > 1) // score the matches { //show dialog with all albums found if (pDialog) { pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlg->SetHeading(g_localizeStrings.Get(181).c_str()); pDlg->Reset(); pDlg->EnableButton(true, 413); // manual } for (int i = 0; i < scraper.GetAlbumCount(); ++i) { CMusicAlbumInfo& info = scraper.GetAlbum(i); double relevance = info.GetRelevance(); if (relevance < 0) relevance = CUtil::AlbumRelevance(info.GetAlbum().strAlbum, strAlbum, StringUtils::Join(info.GetAlbum().artist, g_advancedSettings.m_musicItemSeparator), strArtist); // if we're doing auto-selection (ie querying all albums at once, then allow 95->100% for perfect matches) // otherwise, perfect matches only if (relevance >= max(minRelevance, bestRelevance)) { // we auto-select the best of these bestRelevance = relevance; bestMatch = i; } if (pDialog) { // set the label to [relevance] album - artist CStdString strTemp; strTemp.Format("[%0.2f] %s", relevance, info.GetTitle2()); CFileItem item(strTemp); item.m_idepth = i; // use this to hold the index of the album in the scraper pDlg->Add(&item); } if (relevance > .99f) // we're so close, no reason to search further break; } } else { CMusicAlbumInfo& info = scraper.GetAlbum(0); double relevance = info.GetRelevance(); if (relevance < 0) relevance = CUtil::AlbumRelevance(info.GetAlbum().strAlbum, strAlbum, StringUtils::Join(info.GetAlbum().artist, g_advancedSettings.m_musicItemSeparator), strArtist); if (relevance < THRESHOLD) { m_musicDatabase.Close(); return false; } bestRelevance = relevance; bestMatch = 0; } iSelectedAlbum = bestMatch; if (pDialog && bestRelevance < THRESHOLD) { pDlg->Sort(false); pDlg->DoModal(); // and wait till user selects one if (pDlg->GetSelectedLabel() < 0) { // none chosen if (!pDlg->IsButtonPressed()) { bCanceled = true; return false; } // manual button pressed CStdString strNewAlbum = strAlbum; if (!CGUIKeyboardFactory::ShowAndGetInput(strNewAlbum, g_localizeStrings.Get(16011), false)) return false; if (strNewAlbum == "") return false; CStdString strNewArtist = strArtist; if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return false; pDialog->SetLine(0, strNewAlbum); pDialog->SetLine(1, strNewArtist); pDialog->Progress(); m_musicDatabase.Close(); return DownloadAlbumInfo(strPath,strNewArtist,strNewAlbum,bCanceled,albumInfo,pDialog); } iSelectedAlbum = pDlg->GetSelectedItem()->m_idepth; } } if (iSelectedAlbum < 0) { m_musicDatabase.Close(); return false; } } scraper.LoadAlbumInfo(iSelectedAlbum); while (!scraper.Completed()) { if (m_bStop) { bCanceled = true; scraper.Cancel(); } Sleep(1); } if (scraper.Succeeded()) { albumInfo = scraper.GetAlbum(iSelectedAlbum); album = scraper.GetAlbum(iSelectedAlbum).GetAlbum(); if (result == CNfoFile::COMBINED_NFO) nfoReader.GetDetails(album,NULL,true); m_musicDatabase.SetAlbumInfo(params.GetAlbumId(), album, scraper.GetAlbum(iSelectedAlbum).GetSongs(),false); } else { m_musicDatabase.Close(); return false; } // check thumb stuff GetAlbumArtwork(params.GetAlbumId(), album); m_musicDatabase.Close(); return true; }
void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons); CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item && !StringUtils::StartsWithNoCase(item->GetPath(), "addons://more/")) { // are we in the playlists location? bool inPlaylists = m_vecItems->IsPath(CUtil::MusicPlaylistsLocation()) || m_vecItems->IsPath("special://musicplaylists/"); CMusicDatabaseDirectory dir; // enable music info button on an album or on a song. if (item->IsAudio() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->m_bIsFolder) { buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); } else if (item->IsVideoDb()) { if (!item->m_bIsFolder) // music video buttons.Add(CONTEXT_BUTTON_INFO, 20393); if (StringUtils::StartsWithNoCase(item->GetPath(), "videodb://musicvideos/artists/") && item->m_bIsFolder) { long idArtist = m_musicdatabase.GetArtistByName(m_vecItems->Get(itemNumber)->GetLabel()); if (idArtist > - 1) buttons.Add(CONTEXT_BUTTON_INFO,21891); } } else if (!inPlaylists && (dir.HasAlbumInfo(item->GetPath())|| dir.IsArtistDir(item->GetPath()) ) && !dir.IsAllItem(item->GetPath()) && !item->IsParentFolder() && !item->IsPlugin() && !item->IsScript() && !StringUtils::StartsWithNoCase(item->GetPath(), "musicsearch://")) { if (dir.IsArtistDir(item->GetPath())) buttons.Add(CONTEXT_BUTTON_INFO, 21891); else buttons.Add(CONTEXT_BUTTON_INFO, 13351); } // enable query all albums button only in album view if (dir.HasAlbumInfo(item->GetPath()) && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb() && !item->IsParentFolder() && !item->IsPlugin() && !StringUtils::StartsWithNoCase(item->GetPath(), "musicsearch://")) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 20059); } // enable query all artist button only in album view if (dir.IsArtistDir(item->GetPath()) && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb()) { ADDON::ScraperPtr info; m_musicdatabase.GetScraperForPath(item->GetPath(), info, ADDON::ADDON_SCRAPER_ARTISTS); if (info && info->Supports(CONTENT_ARTISTS)) buttons.Add(CONTEXT_BUTTON_INFO_ALL, 21884); } //Set default or clear default NODE_TYPE nodetype = dir.GetDirectoryType(item->GetPath()); if (!item->IsParentFolder() && !inPlaylists && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TOP100)) { if (!item->IsPath(CSettings::Get().GetString("mymusic.defaultlibview"))) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (!CSettings::Get().GetString("mymusic.defaultlibview").empty()) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } NODE_TYPE childtype = dir.GetDirectoryChildType(item->GetPath()); if (childtype == NODE_TYPE_ALBUM || childtype == NODE_TYPE_ARTIST || nodetype == NODE_TYPE_GENRE || nodetype == NODE_TYPE_ALBUM || nodetype == NODE_TYPE_ALBUM_RECENTLY_ADDED || nodetype == NODE_TYPE_ALBUM_COMPILATIONS) { // we allow the user to set content for // 1. general artist and album nodes // 2. specific per genre // 3. specific per artist // 4. specific per album buttons.Add(CONTEXT_BUTTON_SET_CONTENT,20195); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator)) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20400); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0 && item->GetMusicInfoTag()->GetAlbum().size() > 0 && item->GetMusicInfoTag()->GetTitle().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle()) > -1) buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20401); } if (item->HasVideoInfoTag() && !item->m_bIsFolder) { if (item->GetVideoInfoTag()->m_playCount > 0) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched else buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched if ((CProfilesManager::Get().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !item->IsPlugin()) { buttons.Add(CONTEXT_BUTTON_RENAME, 16105); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } } if (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode.xsp" && (item->IsPlayList() || item->IsSmartPlayList())) buttons.Add(CONTEXT_BUTTON_DELETE, 117); if (item->IsPlugin() || item->IsScript() || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } // noncontextual buttons CGUIWindowMusicBase::GetNonContextButtons(buttons); CContextMenuManager::Get().AddVisibleItems(item, buttons); }
bool CGUIDialogContentSettings::Show(ADDON::ScraperPtr& scraper, VIDEO::SScanSettings& settings, CONTENT_TYPE content /* = CONTENT_NONE */) { CGUIDialogContentSettings *dialog = g_windowManager.GetWindow<CGUIDialogContentSettings>(WINDOW_DIALOG_CONTENT_SETTINGS); if (dialog == NULL) return false; if (scraper != NULL) { dialog->SetContent(content != CONTENT_NONE ? content : scraper->Content()); dialog->SetScraper(scraper); // toast selected but disabled scrapers if (CServiceBroker::GetAddonMgr().IsAddonDisabled(scraper->ID())) CGUIDialogKaiToast::QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(24024), scraper->Name(), 2000, true); } dialog->SetScanSettings(settings); dialog->Open(); bool confirmed = dialog->IsConfirmed(); if (confirmed) { scraper = dialog->GetScraper(); content = dialog->GetContent(); if (scraper == NULL || content == CONTENT_NONE) settings.exclude = dialog->GetExclude(); else { settings.exclude = false; settings.noupdate = dialog->GetNoUpdating(); scraper->SetPathSettings(content, ""); if (content == CONTENT_TVSHOWS) { settings.parent_name = settings.parent_name_root = dialog->GetContainsSingleItem(); settings.recurse = 0; } else if (content == CONTENT_MOVIES || content == CONTENT_MUSICVIDEOS) { if (dialog->GetUseDirectoryNames()) { settings.parent_name = true; settings.parent_name_root = false; settings.recurse = dialog->GetScanRecursive() ? INT_MAX : 1; if (dialog->GetContainsSingleItem()) { settings.parent_name_root = true; settings.recurse = 0; } } else { settings.parent_name = false; settings.parent_name_root = false; settings.recurse = dialog->GetScanRecursive() ? INT_MAX : 0; } } } } // now that we have evaluated all settings we need to reset the content dialog->ResetContent(); return confirmed; }
/** * Look for a thumbnail for pItem. If one does not exist, look for an autogenerated * thumbnail. If that does not exist, attempt to autogenerate one. Finally, check * for the existance of fanart and set properties accordinly. * @return: true if pItem has been modified */ bool CVideoThumbLoader::LoadItem(CFileItem* pItem) { if (pItem->m_bIsShareOrDrive || pItem->IsParentFolder()) return false; // resume point if (pItem->HasVideoInfoTag() && pItem->GetVideoInfoTag()->m_resumePoint.totalTimeInSeconds == 0) { CVideoDatabase db; db.Open(); if (db.GetResumePoint(*pItem->GetVideoInfoTag())) pItem->SetInvalid(); db.Close(); } // video db items normally have info in the database if (pItem->HasVideoInfoTag() && pItem->GetVideoInfoTag()->m_iDbId > -1 && !pItem->GetVideoInfoTag()->m_type.IsEmpty() && pItem->GetArt().empty()) { CVideoDatabase db; db.Open(); map<string, string> artwork; if (db.GetArtForItem(pItem->GetVideoInfoTag()->m_iDbId, pItem->GetVideoInfoTag()->m_type, artwork)) pItem->SetArt(artwork); else { if (pItem->GetVideoInfoTag()->m_type == "movie" || pItem->GetVideoInfoTag()->m_type == "episode" || pItem->GetVideoInfoTag()->m_type == "tvshow" || pItem->GetVideoInfoTag()->m_type == "musicvideo") { // no art in the library, so find it locally and add SScanSettings settings; ADDON::ScraperPtr info = db.GetScraperForPath(pItem->GetVideoInfoTag()->m_strPath, settings); if (info) { CFileItem item(*pItem); item.SetPath(pItem->GetVideoInfoTag()->GetPath()); CVideoInfoScanner scanner; scanner.GetArtwork(&item, info->Content(), settings.parent_name_root, true); pItem->SetArt(item.GetArt()); } } else if (pItem->GetVideoInfoTag()->m_type == "set") { // no art for a set -> use the first movie for this set for art CFileItemList items; if (db.GetMoviesNav("", items, -1, -1, -1, -1, -1, -1, pItem->GetVideoInfoTag()->m_iDbId) && items.Size() > 0) { if (db.GetArtForItem(items[0]->GetVideoInfoTag()->m_iDbId, items[0]->GetVideoInfoTag()->m_type, artwork)) pItem->SetArt(artwork); } } else if (pItem->GetVideoInfoTag()->m_type == "actor" || pItem->GetVideoInfoTag()->m_type == "artist" || pItem->GetVideoInfoTag()->m_type == "writer" || pItem->GetVideoInfoTag()->m_type == "director") { // We can't realistically get the local thumbs (as we'd need to check every movie that contains this actor) // and most users won't have local actor thumbs that are actually different than the scraped ones. if (g_guiSettings.GetBool("videolibrary.actorthumbs")) { pItem->GetVideoInfoTag()->m_strPictureURL.Parse(); CStdString thumb = CScraperUrl::GetThumbURL(pItem->GetVideoInfoTag()->m_strPictureURL.GetFirstThumb()); if (!thumb.IsEmpty()) pItem->SetThumbnailImage(thumb); } } else if (pItem->GetVideoInfoTag()->m_type == "season") { // season art is fetched on scan from the tvshow root path (m_strPath in the season info tag) // or from the show m_strPictureURL member of the tvshow, so grab the tvshow to get this. CVideoInfoTag tag; db.GetTvShowInfo(pItem->GetVideoInfoTag()->m_strPath, tag, pItem->GetVideoInfoTag()->m_iIdShow); map<int, string> seasons; CVideoInfoScanner::GetSeasonThumbs(tag, seasons, true); map<int, string>::iterator season = seasons.find(pItem->GetVideoInfoTag()->m_iSeason); if (season != seasons.end()) pItem->SetThumbnailImage(season->second); } // add to the database for next time around map<string, string> artwork = pItem->GetArt(); if (!artwork.empty()) { db.SetArtForItem(pItem->GetVideoInfoTag()->m_iDbId, pItem->GetVideoInfoTag()->m_type, artwork); for (map<string, string>::iterator i = artwork.begin(); i != artwork.end(); ++i) CTextureCache::Get().BackgroundCacheImage(i->second); } else // nothing found - set an empty thumb so that next time around we don't hit here again db.SetArtForItem(pItem->GetVideoInfoTag()->m_iDbId, pItem->GetVideoInfoTag()->m_type, "thumb", ""); } // For episodes and seasons, we want to set fanart for that of the show if (!pItem->HasProperty("fanart_image") && pItem->GetVideoInfoTag()->m_iIdShow >= 0) { string fanart = db.GetArtForItem(pItem->GetVideoInfoTag()->m_iIdShow, "tvshow", "fanart"); if (!fanart.empty()) pItem->SetProperty("fanart_image", fanart); } db.Close(); } if (pItem->GetVideoInfoTag()->m_type != "movie" && pItem->GetVideoInfoTag()->m_type != "episode" && pItem->GetVideoInfoTag()->m_type != "tvshow" && pItem->GetVideoInfoTag()->m_type != "musicvideo") return true; // nothing else to be done // fanart if (!pItem->HasProperty("fanart_image")) { CStdString fanart = GetCachedImage(*pItem, "fanart"); if (fanart.IsEmpty()) { fanart = pItem->GetLocalFanart(); if (!fanart.IsEmpty()) // cache it SetCachedImage(*pItem, "fanart", fanart); } if (!fanart.IsEmpty()) { CTextureCache::Get().BackgroundCacheImage(fanart); pItem->SetProperty("fanart_image", fanart); } } // thumbnails if (!pItem->HasThumbnail()) { FillThumb(*pItem); if (!pItem->HasThumbnail() && !pItem->m_bIsFolder && pItem->IsVideo()) { // create unique thumb for auto generated thumbs CStdString thumbURL = GetEmbeddedThumbURL(*pItem); if (!CTextureCache::Get().GetCachedImage(thumbURL).IsEmpty()) { CTextureCache::Get().BackgroundCacheImage(thumbURL); pItem->SetProperty("HasAutoThumb", true); pItem->SetProperty("AutoThumbImage", thumbURL); pItem->SetThumbnailImage(thumbURL); } else if (g_guiSettings.GetBool("myvideos.extractthumb") && g_guiSettings.GetBool("myvideos.extractflags")) { CFileItem item(*pItem); CStdString path(item.GetPath()); if (URIUtils::IsInRAR(item.GetPath())) SetupRarOptions(item,path); CThumbExtractor* extract = new CThumbExtractor(item, path, true, thumbURL); AddJob(extract); return true; } } } // flag extraction if (!pItem->m_bIsFolder && pItem->HasVideoInfoTag() && g_guiSettings.GetBool("myvideos.extractflags") && (!pItem->GetVideoInfoTag()->HasStreamDetails() || pItem->GetVideoInfoTag()->m_streamDetails.GetVideoDuration() <= 0)) { CFileItem item(*pItem); CStdString path(item.GetPath()); if (URIUtils::IsInRAR(item.GetPath())) SetupRarOptions(item,path); CThumbExtractor* extract = new CThumbExtractor(item,path,false); AddJob(extract); } return true; }
INFO_RET CMusicInfoScanner::DownloadArtistInfo(const CArtist& artist, const ADDON::ScraperPtr& info, MUSIC_GRABBER::CMusicArtistInfo& artistInfo, CGUIDialogProgress* pDialog) { if (m_handle) { m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20320).c_str(), info->Name().c_str())); m_handle->SetText(artist.strArtist); } // clear our scraper cache info->ClearCache(); CMusicInfoScraper scraper(info); bool bMusicBrainz = false; if (!artist.strMusicBrainzArtistID.empty()) { CScraperUrl musicBrainzURL; if (ResolveMusicBrainz(artist.strMusicBrainzArtistID, info, musicBrainzURL)) { CMusicArtistInfo artistNfo("nfo", musicBrainzURL); scraper.GetArtists().clear(); scraper.GetArtists().push_back(artistNfo); bMusicBrainz = true; } } // handle nfo files std::string path = artist.strPath; if (path.empty()) m_musicDatabase.GetArtistPath(artist.idArtist, path); std::string strNfo = URIUtils::AddFileToFolder(path, "artist.nfo"); CNfoFile::NFOResult result=CNfoFile::NO_NFO; CNfoFile nfoReader; if (XFILE::CFile::Exists(strNfo)) { CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str()); result = nfoReader.Create(strNfo, info); if (result == CNfoFile::FULL_NFO) { CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__); nfoReader.GetDetails(artistInfo.GetArtist()); return INFO_ADDED; } else if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO) { CScraperUrl scrUrl(nfoReader.ScraperUrl()); CMusicArtistInfo artistNfo("nfo",scrUrl); ADDON::ScraperPtr nfoReaderScraper = nfoReader.GetScraperInfo(); CLog::Log(LOGDEBUG,"-- nfo-scraper: %s",nfoReaderScraper->Name().c_str()); CLog::Log(LOGDEBUG,"-- nfo url: %s", scrUrl.m_url[0].m_url.c_str()); scraper.SetScraperInfo(nfoReaderScraper); scraper.GetArtists().push_back(artistNfo); } else CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str()); } if (!scraper.GetArtistCount()) { scraper.FindArtistInfo(artist.strArtist); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); return INFO_CANCELLED; } Sleep(1); } } int iSelectedArtist = 0; if (result == CNfoFile::NO_NFO && !bMusicBrainz) { if (scraper.GetArtistCount() >= 1) { // now load the first match if (pDialog && scraper.GetArtistCount() > 1) { // if we found more then 1 album, let user choose one CGUIDialogSelect *pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); if (pDlg) { pDlg->SetHeading(g_localizeStrings.Get(21890)); pDlg->Reset(); pDlg->EnableButton(true, 413); // manual for (int i = 0; i < scraper.GetArtistCount(); ++i) { // set the label to artist CFileItem item(scraper.GetArtist(i).GetArtist()); std::string strTemp=scraper.GetArtist(i).GetArtist().strArtist; if (!scraper.GetArtist(i).GetArtist().strBorn.empty()) strTemp += " ("+scraper.GetArtist(i).GetArtist().strBorn+")"; if (!scraper.GetArtist(i).GetArtist().genre.empty()) { std::string genres = StringUtils::Join(scraper.GetArtist(i).GetArtist().genre, g_advancedSettings.m_musicItemSeparator); if (!genres.empty()) strTemp = StringUtils::Format("[%s] %s", genres.c_str(), strTemp.c_str()); } item.SetLabel(strTemp); item.m_idepth = i; // use this to hold the index of the album in the scraper pDlg->Add(&item); } pDlg->DoModal(); // and wait till user selects one if (pDlg->GetSelectedLabel() < 0) { // none chosen if (!pDlg->IsButtonPressed()) return INFO_CANCELLED; // manual button pressed std::string strNewArtist = artist.strArtist; if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return INFO_CANCELLED; if (pDialog) { pDialog->SetLine(0, strNewArtist); pDialog->Progress(); } CArtist newArtist; newArtist.strArtist = strNewArtist; return DownloadArtistInfo(newArtist, info, artistInfo, pDialog); } iSelectedArtist = pDlg->GetSelectedItem()->m_idepth; } } } else return INFO_NOT_FOUND; } scraper.LoadArtistInfo(iSelectedArtist, artist.strArtist); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); return INFO_CANCELLED; } Sleep(1); } if (!scraper.Succeeded()) return INFO_ERROR; artistInfo = scraper.GetArtist(iSelectedArtist); if (result == CNfoFile::COMBINED_NFO) nfoReader.GetDetails(artistInfo.GetArtist(), NULL, true); return INFO_ADDED; }
void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons); CGUIDialogMusicScan *musicScan = (CGUIDialogMusicScan *)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN); CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item && (item->GetExtraInfo().Find("lastfm") < 0)) { // are we in the playlists location? bool inPlaylists = m_vecItems->GetPath().Equals(CUtil::MusicPlaylistsLocation()) || m_vecItems->GetPath().Equals("special://musicplaylists/"); CMusicDatabaseDirectory dir; // enable music info button on an album or on a song. if (item->IsAudio() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLastFM() && !item->m_bIsFolder) { buttons.Add(CONTEXT_BUTTON_SONG_INFO, 658); } else if (item->IsVideoDb()) { if (!item->m_bIsFolder) // music video buttons.Add(CONTEXT_BUTTON_INFO, 20393); if (item->GetPath().Left(14).Equals("videodb://3/4/") && item->GetPath().size() > 14 && item->m_bIsFolder) { long idArtist = m_musicdatabase.GetArtistByName(m_vecItems->Get(itemNumber)->GetLabel()); if (idArtist > - 1) buttons.Add(CONTEXT_BUTTON_INFO,21891); } } else if (!inPlaylists && (dir.HasAlbumInfo(item->GetPath())|| dir.IsArtistDir(item->GetPath()) ) && !dir.IsAllItem(item->GetPath()) && !item->IsParentFolder() && !item->IsLastFM() && !item->IsPlugin() && !item->IsScript() && !item->GetPath().Left(14).Equals("musicsearch://")) { if (dir.IsArtistDir(item->GetPath())) buttons.Add(CONTEXT_BUTTON_INFO, 21891); else buttons.Add(CONTEXT_BUTTON_INFO, 13351); } // enable query all albums button only in album view if (dir.HasAlbumInfo(item->GetPath()) && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb() && !item->IsParentFolder() && !item->IsLastFM() && !item->IsPlugin() && !item->GetPath().Left(14).Equals("musicsearch://")) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 20059); } // enable query all artist button only in album view if (dir.IsArtistDir(item->GetPath()) && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb()) { ADDON::ScraperPtr info; m_musicdatabase.GetScraperForPath(item->GetPath(), info, ADDON::ADDON_SCRAPER_ARTISTS); if (info && info->Supports(CONTENT_ARTISTS)) buttons.Add(CONTEXT_BUTTON_INFO_ALL, 21884); } //Set default or clear default NODE_TYPE nodetype = dir.GetDirectoryType(item->GetPath()); if (!item->IsParentFolder() && !inPlaylists && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TOP100)) { if (!item->GetPath().Equals(g_settings.m_defaultMusicLibSource)) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (strcmp(g_settings.m_defaultMusicLibSource, "")) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } NODE_TYPE childtype = dir.GetDirectoryChildType(item->GetPath()); if (childtype == NODE_TYPE_ALBUM || childtype == NODE_TYPE_ARTIST || nodetype == NODE_TYPE_GENRE || nodetype == NODE_TYPE_ALBUM || nodetype == NODE_TYPE_ALBUM_RECENTLY_ADDED || nodetype == NODE_TYPE_ALBUM_COMPILATIONS) { // we allow the user to set content for // 1. general artist and album nodes // 2. specific per genre // 3. specific per artist // 4. specific per album buttons.Add(CONTEXT_BUTTON_SET_CONTENT,20195); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtist()) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20400); } if (item->HasMusicInfoTag() && item->GetMusicInfoTag()->GetArtist().size() > 0 && item->GetMusicInfoTag()->GetAlbum().size() > 0 && item->GetMusicInfoTag()->GetTitle().size() > 0) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtist(),item->GetMusicInfoTag()->GetAlbum(),item->GetMusicInfoTag()->GetTitle()) > -1) buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20401); } if (item->HasVideoInfoTag() && !item->m_bIsFolder) { if (item->GetVideoInfoTag()->m_playCount > 0) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched else buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched if ((g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !item->IsPlugin()) { buttons.Add(CONTEXT_BUTTON_RENAME, 16105); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } } if (inPlaylists && !URIUtils::GetFileName(item->GetPath()).Equals("PartyMode.xsp") && (item->IsPlayList() || item->IsSmartPlayList())) buttons.Add(CONTEXT_BUTTON_DELETE, 117); if (item->IsPlugin() || item->IsScript() || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } // noncontextual buttons if (musicScan && musicScan->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning else if (musicScan) buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); CGUIWindowMusicBase::GetNonContextButtons(buttons); }
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons); CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(m_vecItems->GetPath()); if (!item) { // nothing to do here } else if (m_vecItems->IsPath("sources://video/")) { // get the usual shares CGUIDialogContextMenu::GetContextButtons("video", item, buttons); if (!item->IsDVD() && item->GetPath() != "add" && !item->IsParentFolder() && (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { CVideoDatabase database; database.Open(); ADDON::ScraperPtr info = database.GetScraperForPath(item->GetPath()); if (!item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath())) { if (info && info->Content() != CONTENT_NONE) { buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); } } } else { // are we in the playlists location? bool inPlaylists = m_vecItems->IsPath(CUtil::VideoPlaylistsLocation()) || m_vecItems->IsPath("special://videoplaylists/"); if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_artist.empty()) { CMusicDatabase database; database.Open(); if (database.GetArtistByName(StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator)) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20396); } if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strAlbum.empty()) { CMusicDatabase database; database.Open(); if (database.GetAlbumByName(item->GetVideoInfoTag()->m_strAlbum) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ALBUM, 20397); } if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strAlbum.empty() && !item->GetVideoInfoTag()->m_artist.empty() && !item->GetVideoInfoTag()->m_strTitle.empty()) { CMusicDatabase database; database.Open(); if (database.GetSongByArtistAndAlbumAndTitle(StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator), item->GetVideoInfoTag()->m_strAlbum, item->GetVideoInfoTag()->m_strTitle) > -1) { buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20398); } } if (!item->IsParentFolder()) { ADDON::ScraperPtr info; VIDEO::SScanSettings settings; GetScraperForItem(item.get(), info, settings); // can we update the database? if (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) { if (!g_application.IsVideoScanning() && item->IsVideoDb() && item->HasVideoInfoTag() && (item->GetVideoInfoTag()->m_type == MediaTypeMovie || // movies item->GetVideoInfoTag()->m_type == MediaTypeTvShow || // tvshows item->GetVideoInfoTag()->m_type == MediaTypeSeason || // seasons item->GetVideoInfoTag()->m_type == MediaTypeEpisode || // episodes item->GetVideoInfoTag()->m_type == MediaTypeMusicVideo || // musicvideos item->GetVideoInfoTag()->m_type == "tag" || // tags item->GetVideoInfoTag()->m_type == MediaTypeVideoCollection)) // sets { buttons.Add(CONTEXT_BUTTON_EDIT, 16106); } if (node == NODE_TYPE_TITLE_TVSHOWS) { buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } if (node == NODE_TYPE_ACTOR && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder) { if (StringUtils::StartsWithNoCase(m_vecItems->GetPath(), "videodb://musicvideos")) // mvids buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); else buttons.Add(CONTEXT_BUTTON_SET_ACTOR_THUMB, 20403); } } if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot()) { // non-video db items, file operations are allowed if ((CServiceBroker::GetSettings().GetBool(CSettings::SETTING_FILELISTS_ALLOWFILEDELETION) && CUtil::SupportsWriteFileOperations(item->GetPath())) || (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode-Video.xsp" && (item->IsPlayList() || item->IsSmartPlayList()))) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } // add "Set/Change content" to folders if (item->m_bIsFolder && !item->IsVideoDb() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLibraryFolder() && !item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath())) { if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } } if ((!item->HasVideoInfoTag() || item->GetVideoInfoTag()->m_iDbId == -1) && info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SCAN_TO_LIBRARY, 21845); } } }
void CGUIWindowMusicNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (item) { // are we in the playlists location? bool inPlaylists = m_vecItems->IsPath(CUtil::MusicPlaylistsLocation()) || m_vecItems->IsPath("special://musicplaylists/"); if (m_vecItems->IsPath("sources://music/")) { // get the usual music shares, and anything for all media windows CGUIDialogContextMenu::GetContextButtons("music", item, buttons); #ifdef HAS_DVD_DRIVE // enable Rip CD an audio disc if (g_mediaManager.IsDiscInDrive() && item->IsCDDA()) { // those cds can also include Audio Tracks: CDExtra and MixedMode! MEDIA_DETECT::CCdInfo *pCdInfo = g_mediaManager.GetCdInfo(); if (pCdInfo->IsAudio(1) || pCdInfo->IsCDExtra(1) || pCdInfo->IsMixedMode(1)) { if (CJobManager::GetInstance().IsProcessing("cdrip")) buttons.Add(CONTEXT_BUTTON_CANCEL_RIP_CD, 14100); else buttons.Add(CONTEXT_BUTTON_RIP_CD, 600); } } #endif // Add the scan button(s) if (g_application.IsMusicScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning else if (!inPlaylists && !m_vecItems->IsInternetStream() && !item->IsPath("add") && !item->IsParentFolder() && !item->IsPlugin() && !StringUtils::StartsWithNoCase(item->GetPath(), "addons://") && (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { buttons.Add(CONTEXT_BUTTON_SCAN, 13352); } CGUIMediaWindow::GetContextButtons(itemNumber, buttons); } else { CGUIWindowMusicBase::GetContextButtons(itemNumber, buttons); CMusicDatabaseDirectory dir; // enable query all albums button only in album view if (item->IsAlbum() && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb() && !item->IsParentFolder() && !item->IsPlugin() && !StringUtils::StartsWithNoCase(item->GetPath(), "musicsearch://")) { buttons.Add(CONTEXT_BUTTON_INFO_ALL, 20059); } // enable query all artist button only in artist view if (dir.IsArtistDir(item->GetPath()) && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder && !item->IsVideoDb()) { ADDON::ScraperPtr info; if(m_musicdatabase.GetScraperForPath(item->GetPath(), info, ADDON::ADDON_SCRAPER_ARTISTS)) { if (info && info->Supports(CONTENT_ARTISTS)) buttons.Add(CONTEXT_BUTTON_INFO_ALL, 21884); } } //Set default or clear default NODE_TYPE nodetype = dir.GetDirectoryType(item->GetPath()); if (!item->IsParentFolder() && !inPlaylists && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TOP100)) { if (!item->IsPath(CSettings::GetInstance().GetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW))) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (!CSettings::GetInstance().GetString(CSettings::SETTING_MYMUSIC_DEFAULTLIBVIEW).empty()) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } NODE_TYPE childtype = dir.GetDirectoryChildType(item->GetPath()); if (childtype == NODE_TYPE_ALBUM || childtype == NODE_TYPE_ARTIST || nodetype == NODE_TYPE_GENRE || nodetype == NODE_TYPE_ALBUM || nodetype == NODE_TYPE_ALBUM_RECENTLY_ADDED || nodetype == NODE_TYPE_ALBUM_COMPILATIONS) { // we allow the user to set content for // 1. general artist and album nodes // 2. specific per genre // 3. specific per artist // 4. specific per album buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20195); } if (item->HasMusicInfoTag() && !item->GetMusicInfoTag()->GetArtistString().empty()) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtistString()) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20400); } if (item->HasMusicInfoTag() && !item->GetMusicInfoTag()->GetArtistString().empty() && !item->GetMusicInfoTag()->GetAlbum().empty() && !item->GetMusicInfoTag()->GetTitle().empty()) { CVideoDatabase database; database.Open(); if (database.GetMatchingMusicVideo(item->GetMusicInfoTag()->GetArtistString(), item->GetMusicInfoTag()->GetAlbum(), item->GetMusicInfoTag()->GetTitle()) > -1) buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20401); } if (item->HasVideoInfoTag() && !item->m_bIsFolder) { if ((CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) && !item->IsPlugin()) { buttons.Add(CONTEXT_BUTTON_RENAME, 16105); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } } if (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode.xsp" && (item->IsPlayList() || item->IsSmartPlayList())) buttons.Add(CONTEXT_BUTTON_DELETE, 117); if (!item->IsReadOnly() && CSettings::GetInstance().GetBool("filelists.allowfiledeletion")) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } } } // noncontextual buttons CGUIWindowMusicBase::GetNonContextButtons(buttons); }
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; }
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons); if (item && item->GetProperty("pluginreplacecontextitems").asBoolean()) return; CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(m_vecItems->GetPath()); if (!item) { // nothing to do here } else if (m_vecItems->IsPath("sources://video/")) { // get the usual shares CGUIDialogContextMenu::GetContextButtons("video", item, buttons); // add scan button somewhere here if (g_application.IsVideoScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning if (!item->IsDVD() && item->GetPath() != "add" && !item->IsParentFolder() && (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { CVideoDatabase database; database.Open(); ADDON::ScraperPtr info = database.GetScraperForPath(item->GetPath()); if (!item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath())) { if (info && info->Content() != CONTENT_NONE) { buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); } } } else { // are we in the playlists location? bool inPlaylists = m_vecItems->IsPath(CUtil::VideoPlaylistsLocation()) || m_vecItems->IsPath("special://videoplaylists/"); if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_artist.empty()) { CMusicDatabase database; database.Open(); if (database.GetArtistByName(StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator)) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20396); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetAlbumByName(item->GetVideoInfoTag()->m_strAlbum) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ALBUM, 20397); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0 && item->GetVideoInfoTag()->m_artist.size() > 0 && item->GetVideoInfoTag()->m_strTitle.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetSongByArtistAndAlbumAndTitle(StringUtils::Join(item->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator), item->GetVideoInfoTag()->m_strAlbum, item->GetVideoInfoTag()->m_strTitle) > -1) { buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20398); } } if (!item->IsParentFolder()) { ADDON::ScraperPtr info; VIDEO::SScanSettings settings; GetScraperForItem(item.get(), info, settings); if (info && info->Content() == CONTENT_TVSHOWS) buttons.Add(CONTEXT_BUTTON_INFO, item->m_bIsFolder ? 20351 : 20352); else if (info && info->Content() == CONTENT_MUSICVIDEOS) buttons.Add(CONTEXT_BUTTON_INFO,20393); else if (info && info->Content() == CONTENT_MOVIES) buttons.Add(CONTEXT_BUTTON_INFO, 13346); // can we update the database? if (CProfilesManager::GetInstance().GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) { if (!item->IsPlugin() && !item->IsScript() && !item->IsLiveTV() && !item->IsAddonsPath() && item->GetPath() != "sources://video/" && item->GetPath() != "special://videoplaylists/" && !StringUtils::StartsWith(item->GetPath(), "newsmartplaylist://") && !StringUtils::StartsWith(item->GetPath(), "newplaylist://") && !StringUtils::StartsWith(item->GetPath(), "newtag://")) { if (item->m_bIsFolder) { // Have both options for folders since we don't know whether all childs are watched/unwatched buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched } else { if (item->GetOverlayImage() == "OverlayWatched.png") buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched else buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched } } if (!g_application.IsVideoScanning() && item->IsVideoDb() && item->HasVideoInfoTag() && (item->GetVideoInfoTag()->m_type == MediaTypeMovie || // movies item->GetVideoInfoTag()->m_type == MediaTypeTvShow || // tvshows item->GetVideoInfoTag()->m_type == MediaTypeSeason || // seasons item->GetVideoInfoTag()->m_type == MediaTypeEpisode || // episodes item->GetVideoInfoTag()->m_type == MediaTypeMusicVideo || // musicvideos item->GetVideoInfoTag()->m_type == "tag" || // tags item->GetVideoInfoTag()->m_type == MediaTypeVideoCollection)) // sets { buttons.Add(CONTEXT_BUTTON_EDIT, 16106); } if (node == NODE_TYPE_TITLE_TVSHOWS) { if (g_application.IsVideoScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } if (node == NODE_TYPE_ACTOR && !dir.IsAllItem(item->GetPath()) && item->m_bIsFolder) { if (StringUtils::StartsWithNoCase(m_vecItems->GetPath(), "videodb://musicvideos")) // mvids buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); else buttons.Add(CONTEXT_BUTTON_SET_ACTOR_THUMB, 20403); } } if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot()) { // non-video db items, file operations are allowed if ((CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_ALLOWFILEDELETION) && CUtil::SupportsWriteFileOperations(item->GetPath())) || (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode-Video.xsp" && (item->IsPlayList() || item->IsSmartPlayList()))) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } // add "Set/Change content" to folders if (item->m_bIsFolder && !item->IsVideoDb() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLibraryFolder() && !item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath())) { if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } } if (item->IsPlugin() || item->IsScript() || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } CContextMenuManager::GetInstance().AddVisibleItems(item, buttons); } }
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons); if (item && item->GetPropertyBOOL("pluginreplacecontextitems")) return; CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(m_vecItems->m_strPath); if (!item) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); else buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); } else { ADDON::ScraperPtr info; VIDEO::SScanSettings settings; GetScraperForItem(item.get(), info, settings); if (info && info->Content() == CONTENT_TVSHOWS) buttons.Add(CONTEXT_BUTTON_INFO, item->m_bIsFolder ? 20351 : 20352); else if (info && info->Content() == CONTENT_MUSICVIDEOS) buttons.Add(CONTEXT_BUTTON_INFO,20393); else if (!item->m_bIsFolder && !item->m_strPath.Left(19).Equals("newsmartplaylist://")) buttons.Add(CONTEXT_BUTTON_INFO, 13346); if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strArtist.IsEmpty()) { CMusicDatabase database; database.Open(); if (database.GetArtistByName(item->GetVideoInfoTag()->m_strArtist) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20396); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetAlbumByName(item->GetVideoInfoTag()->m_strAlbum) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ALBUM, 20397); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0 && item->GetVideoInfoTag()->m_strArtist.size() > 0 && item->GetVideoInfoTag()->m_strTitle.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetSongByArtistAndAlbumAndTitle(item->GetVideoInfoTag()->m_strArtist, item->GetVideoInfoTag()->m_strAlbum, item->GetVideoInfoTag()->m_strTitle) > -1) { buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20398); } } if (!item->IsParentFolder()) { // can we update the database? if (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) { if (node == NODE_TYPE_TITLE_TVSHOWS) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); else buttons.Add(CONTEXT_BUTTON_UPDATE_TVSHOW, 13349); } if ((info && info->Content() == CONTENT_TVSHOWS && item->m_bIsFolder) || (item->IsVideoDb() && item->HasVideoInfoTag() && !item->m_bIsFolder)) { if (item->m_bIsFolder || item->GetVideoInfoTag()->m_playCount > 0) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched if (item->m_bIsFolder || item->GetVideoInfoTag()->m_playCount == 0) buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched if (node != NODE_TYPE_SEASONS) buttons.Add(CONTEXT_BUTTON_EDIT, 16105); //Edit Title } if (m_database.HasContent(VIDEODB_CONTENT_TVSHOWS) && item->HasVideoInfoTag() && !item->m_bIsFolder && item->GetVideoInfoTag()->m_iEpisode == -1 && item->GetVideoInfoTag()->m_strArtist.IsEmpty()) // movie entry { if (m_database.IsLinkedToTvshow(item->GetVideoInfoTag()->m_iDbId)) buttons.Add(CONTEXT_BUTTON_UNLINK_MOVIE,20385); buttons.Add(CONTEXT_BUTTON_LINK_MOVIE,20384); } if (node == NODE_TYPE_SEASONS && item->m_bIsFolder) buttons.Add(CONTEXT_BUTTON_SET_SEASON_THUMB, 20371); if (item->m_strPath.Left(14).Equals("videodb://1/7/") && item->m_strPath.size() > 14 && item->m_bIsFolder) // sets { buttons.Add(CONTEXT_BUTTON_EDIT, 16105); buttons.Add(CONTEXT_BUTTON_SET_MOVIESET_THUMB, 20435); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } if (node == NODE_TYPE_ACTOR && !dir.IsAllItem(item->m_strPath) && item->m_bIsFolder) { if (m_vecItems->m_strPath.Left(11).Equals("videodb://3")) // mvids buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); else buttons.Add(CONTEXT_BUTTON_SET_ACTOR_THUMB, 20403); } if (item->IsVideoDb() && item->HasVideoInfoTag() && (!item->m_bIsFolder || node == NODE_TYPE_TITLE_TVSHOWS)) { if (info && info->Content() == CONTENT_TVSHOWS) { if(item->GetVideoInfoTag()->m_iBookmarkId != -1 && item->GetVideoInfoTag()->m_iBookmarkId != 0) { buttons.Add(CONTEXT_BUTTON_UNLINK_BOOKMARK, 20405); } } buttons.Add(CONTEXT_BUTTON_DELETE, 646); } // this should ideally be non-contextual (though we need some context for non-tv show node I guess) CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) { if (node != NODE_TYPE_TITLE_TVSHOWS) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); } else buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); } //Set default and/or clear default NODE_TYPE nodetype = CVideoDatabaseDirectory::GetDirectoryType(item->m_strPath); if (!item->IsParentFolder() && !m_vecItems->m_strPath.Equals("special://videoplaylists/") && (nodetype == NODE_TYPE_ROOT || nodetype == NODE_TYPE_OVERVIEW || nodetype == NODE_TYPE_TVSHOWS_OVERVIEW || nodetype == NODE_TYPE_MOVIES_OVERVIEW || nodetype == NODE_TYPE_MUSICVIDEOS_OVERVIEW)) { if (!item->m_strPath.Equals(g_settings.m_defaultVideoLibSource)) buttons.Add(CONTEXT_BUTTON_SET_DEFAULT, 13335); // set default if (strcmp(g_settings.m_defaultVideoLibSource, "")) buttons.Add(CONTEXT_BUTTON_CLEAR_DEFAULT, 13403); // clear default } if ((CVideoDatabaseDirectory::GetDirectoryChildType(item->m_strPath) == NODE_TYPE_TITLE_MOVIES || CVideoDatabaseDirectory::GetDirectoryChildType(item->m_strPath) == NODE_TYPE_TITLE_MUSICVIDEOS || item->m_strPath.Equals("videodb://1/") || item->m_strPath.Equals("videodb://4/") || item->m_strPath.Equals("videodb://6/")) && nodetype != NODE_TYPE_RECENTLY_ADDED_MOVIES) { buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched } if (m_vecItems->m_strPath.Equals("special://videoplaylists/")) { // video playlists, file operations are allowed if (!item->IsReadOnly()) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } } if (item->IsPlugin() || item->m_strPath.Left(9).Equals("script://") || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } } CGUIWindowVideoBase::GetNonContextButtons(itemNumber, buttons); }
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons); if (item && item->GetPropertyBOOL("pluginreplacecontextitems")) return; CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(m_vecItems->m_strPath); if (!item) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); else buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); } else if (m_vecItems->m_strPath.Equals("sources://video/")) { // get the usual shares CGUIDialogContextMenu::GetContextButtons("video", item, buttons); // add scan button somewhere here CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); // Stop Scanning if (!item->IsDVD() && item->m_strPath != "add" && (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser)) { CVideoDatabase database; database.Open(); ADDON::ScraperPtr info = database.GetScraperForPath(item->m_strPath); if (!pScanDlg || (pScanDlg && !pScanDlg->IsScanning())) { if (!item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath()) { if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); } } if (info && (!pScanDlg || (pScanDlg && !pScanDlg->IsScanning()))) buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } } else { ADDON::ScraperPtr info; VIDEO::SScanSettings settings; GetScraperForItem(item.get(), info, settings); if (info && info->Content() == CONTENT_TVSHOWS) buttons.Add(CONTEXT_BUTTON_INFO, item->m_bIsFolder ? 20351 : 20352); else if (info && info->Content() == CONTENT_MUSICVIDEOS) buttons.Add(CONTEXT_BUTTON_INFO,20393); else if (!item->m_bIsFolder && !item->m_strPath.Left(19).Equals("newsmartplaylist://")) buttons.Add(CONTEXT_BUTTON_INFO, 13346); if (item->HasVideoInfoTag() && !item->GetVideoInfoTag()->m_strArtist.IsEmpty()) { CMusicDatabase database; database.Open(); if (database.GetArtistByName(item->GetVideoInfoTag()->m_strArtist) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ARTIST, 20396); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetAlbumByName(item->GetVideoInfoTag()->m_strAlbum) > -1) buttons.Add(CONTEXT_BUTTON_GO_TO_ALBUM, 20397); } if (item->HasVideoInfoTag() && item->GetVideoInfoTag()->m_strAlbum.size() > 0 && item->GetVideoInfoTag()->m_strArtist.size() > 0 && item->GetVideoInfoTag()->m_strTitle.size() > 0) { CMusicDatabase database; database.Open(); if (database.GetSongByArtistAndAlbumAndTitle(item->GetVideoInfoTag()->m_strArtist, item->GetVideoInfoTag()->m_strAlbum, item->GetVideoInfoTag()->m_strTitle) > -1) { buttons.Add(CONTEXT_BUTTON_PLAY_OTHER, 20398); } } if (!item->IsParentFolder()) { // can we update the database? if (g_settings.GetCurrentProfile().canWriteDatabases() || g_passwordManager.bMasterUser) { if (node == NODE_TYPE_TITLE_TVSHOWS) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); else buttons.Add(CONTEXT_BUTTON_UPDATE_TVSHOW, 13349); } if (!item->IsPlugin() && !item->IsLiveTV() && !item->IsAddonsPath() && item->m_strPath != "sources://video/" && item->m_strPath != "special://videoplaylists/") { if (item->m_bIsFolder) { // Have both options for folders since we don't know whether all childs are watched/unwatched buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched } else { if (item->GetOverlayImage().Equals("OverlayWatched.png")) buttons.Add(CONTEXT_BUTTON_MARK_UNWATCHED, 16104); //Mark as UnWatched else buttons.Add(CONTEXT_BUTTON_MARK_WATCHED, 16103); //Mark as Watched } } if ((node == NODE_TYPE_TITLE_TVSHOWS) || (item->IsVideoDb() && item->HasVideoInfoTag() && !item->m_bIsFolder)) { buttons.Add(CONTEXT_BUTTON_EDIT, 16105); //Edit Title } if (m_database.HasContent(VIDEODB_CONTENT_TVSHOWS) && item->HasVideoInfoTag() && !item->m_bIsFolder && item->GetVideoInfoTag()->m_iEpisode == -1 && item->GetVideoInfoTag()->m_strArtist.IsEmpty() && item->GetVideoInfoTag()->m_iDbId >= 0) // movie entry { if (m_database.IsLinkedToTvshow(item->GetVideoInfoTag()->m_iDbId)) buttons.Add(CONTEXT_BUTTON_UNLINK_MOVIE,20385); buttons.Add(CONTEXT_BUTTON_LINK_MOVIE,20384); } if (node == NODE_TYPE_SEASONS && item->m_bIsFolder) buttons.Add(CONTEXT_BUTTON_SET_SEASON_THUMB, 20371); if (item->m_strPath.Left(14).Equals("videodb://1/7/") && item->m_strPath.size() > 14 && item->m_bIsFolder) // sets { buttons.Add(CONTEXT_BUTTON_EDIT, 16105); buttons.Add(CONTEXT_BUTTON_SET_MOVIESET_THUMB, 20435); buttons.Add(CONTEXT_BUTTON_DELETE, 646); } if (node == NODE_TYPE_ACTOR && !dir.IsAllItem(item->m_strPath) && item->m_bIsFolder) { if (m_vecItems->m_strPath.Left(11).Equals("videodb://3")) // mvids buttons.Add(CONTEXT_BUTTON_SET_ARTIST_THUMB, 13359); else buttons.Add(CONTEXT_BUTTON_SET_ACTOR_THUMB, 20403); } if (item->IsVideoDb() && item->HasVideoInfoTag() && (!item->m_bIsFolder || node == NODE_TYPE_TITLE_TVSHOWS)) { if (info && info->Content() == CONTENT_TVSHOWS) { if(item->GetVideoInfoTag()->m_iBookmarkId != -1 && item->GetVideoInfoTag()->m_iBookmarkId != 0) { buttons.Add(CONTEXT_BUTTON_UNLINK_BOOKMARK, 20405); } } buttons.Add(CONTEXT_BUTTON_DELETE, 646); } // this should ideally be non-contextual (though we need some context for non-tv show node I guess) CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (pScanDlg && pScanDlg->IsScanning()) { if (node != NODE_TYPE_TITLE_TVSHOWS) buttons.Add(CONTEXT_BUTTON_STOP_SCANNING, 13353); } else buttons.Add(CONTEXT_BUTTON_UPDATE_LIBRARY, 653); } if (!m_vecItems->IsVideoDb() && !m_vecItems->IsVirtualDirectoryRoot()) { // non-video db items, file operations are allowed if (g_guiSettings.GetBool("filelists.allowfiledeletion") && CUtil::SupportsFileOperations(item->m_strPath)) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } // add "Set/Change content" to folders if (item->m_bIsFolder && !item->IsPlayList() && !item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath()) { CGUIDialogVideoScan *pScanDlg = (CGUIDialogVideoScan *)g_windowManager.GetWindow(WINDOW_DIALOG_VIDEO_SCAN); if (!pScanDlg || (pScanDlg && !pScanDlg->IsScanning())) { if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); } } } if (item->IsPlugin() || item->m_strPath.Left(9).Equals("script://") || m_vecItems->IsPlugin()) buttons.Add(CONTEXT_BUTTON_PLUGIN_SETTINGS, 1045); } } CGUIWindowVideoBase::GetNonContextButtons(itemNumber, buttons); }
bool CVideoThumbLoader::FillLibraryArt(CFileItem *pItem) { if (pItem->GetVideoInfoTag()->m_iDbId > -1 && !pItem->GetVideoInfoTag()->m_type.IsEmpty()) { CVideoDatabase db; db.Open(); map<string, string> artwork; if (db.GetArtForItem(pItem->GetVideoInfoTag()->m_iDbId, pItem->GetVideoInfoTag()->m_type, artwork)) pItem->SetArt(artwork); else { if (pItem->GetVideoInfoTag()->m_type == "movie" || pItem->GetVideoInfoTag()->m_type == "episode" || pItem->GetVideoInfoTag()->m_type == "tvshow" || pItem->GetVideoInfoTag()->m_type == "musicvideo") { // no art in the library, so find it locally and add SScanSettings settings; ADDON::ScraperPtr info = db.GetScraperForPath(pItem->GetVideoInfoTag()->m_strPath, settings); if (info) { CFileItem item(*pItem); item.SetPath(pItem->GetVideoInfoTag()->GetPath()); CVideoInfoScanner scanner; scanner.GetArtwork(&item, info->Content(), settings.parent_name_root, true); pItem->SetArt(item.GetArt()); } } else if (pItem->GetVideoInfoTag()->m_type == "set") { // no art for a set -> use the first movie for this set for art CFileItemList items; if (db.GetMoviesNav("", items, -1, -1, -1, -1, -1, -1, pItem->GetVideoInfoTag()->m_iDbId) && items.Size() > 0) { LoadItem(items[0].get()); if (!items[0]->GetArt().empty()) pItem->SetArt(items[0]->GetArt()); } } else if (pItem->GetVideoInfoTag()->m_type == "actor" || pItem->GetVideoInfoTag()->m_type == "artist" || pItem->GetVideoInfoTag()->m_type == "writer" || pItem->GetVideoInfoTag()->m_type == "director") { // We can't realistically get the local thumbs (as we'd need to check every movie that contains this actor) // and most users won't have local actor thumbs that are actually different than the scraped ones. if (g_guiSettings.GetBool("videolibrary.actorthumbs")) { pItem->GetVideoInfoTag()->m_strPictureURL.Parse(); CStdString thumb = CScraperUrl::GetThumbURL(pItem->GetVideoInfoTag()->m_strPictureURL.GetFirstThumb()); if (!thumb.IsEmpty()) pItem->SetThumbnailImage(thumb); } } else if (pItem->GetVideoInfoTag()->m_type == "season") { // season art is fetched on scan from the tvshow root path (m_strPath in the season info tag) // or from the show m_strPictureURL member of the tvshow, so grab the tvshow to get this. CVideoInfoTag tag; db.GetTvShowInfo(pItem->GetVideoInfoTag()->m_strPath, tag, pItem->GetVideoInfoTag()->m_iIdShow); map<int, string> seasons; CVideoInfoScanner::GetSeasonThumbs(tag, seasons, true); map<int, string>::iterator season = seasons.find(pItem->GetVideoInfoTag()->m_iSeason); if (season != seasons.end()) pItem->SetThumbnailImage(season->second); } // add to the database for next time around map<string, string> artwork = pItem->GetArt(); if (!artwork.empty()) { db.SetArtForItem(pItem->GetVideoInfoTag()->m_iDbId, pItem->GetVideoInfoTag()->m_type, artwork); for (map<string, string>::iterator i = artwork.begin(); i != artwork.end(); ++i) CTextureCache::Get().BackgroundCacheImage(i->second); } else // nothing found - set an empty thumb so that next time around we don't hit here again db.SetArtForItem(pItem->GetVideoInfoTag()->m_iDbId, pItem->GetVideoInfoTag()->m_type, "thumb", ""); } // For episodes and seasons, we want to set fanart for that of the show if (!pItem->HasProperty("fanart_image") && pItem->GetVideoInfoTag()->m_iIdShow >= 0) { string fanart = db.GetArtForItem(pItem->GetVideoInfoTag()->m_iIdShow, "tvshow", "fanart"); if (!fanart.empty()) pItem->SetProperty("fanart_image", fanart); } db.Close(); } return !pItem->GetArt().empty(); }
INFO_RET CMusicInfoScanner::DownloadAlbumInfo(const CAlbum& album, const ADDON::ScraperPtr& info, CMusicAlbumInfo& albumInfo, CGUIDialogProgress* pDialog) { if (m_handle) { m_handle->SetTitle(StringUtils::Format(g_localizeStrings.Get(20321).c_str(), info->Name().c_str())); m_handle->SetText(StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator) + " - " + album.strAlbum); } // clear our scraper cache info->ClearCache(); CMusicInfoScraper scraper(info); bool bMusicBrainz = false; if (!album.strMusicBrainzAlbumID.empty()) { CScraperUrl musicBrainzURL; if (ResolveMusicBrainz(album.strMusicBrainzAlbumID, info, musicBrainzURL)) { CMusicAlbumInfo albumNfo("nfo", musicBrainzURL); scraper.GetAlbums().clear(); scraper.GetAlbums().push_back(albumNfo); bMusicBrainz = true; } } // handle nfo files std::string path = album.strPath; if (path.empty()) m_musicDatabase.GetAlbumPath(album.idAlbum, path); std::string strNfo = URIUtils::AddFileToFolder(path, "album.nfo"); CNfoFile::NFOResult result = CNfoFile::NO_NFO; CNfoFile nfoReader; if (XFILE::CFile::Exists(strNfo)) { CLog::Log(LOGDEBUG,"Found matching nfo file: %s", strNfo.c_str()); result = nfoReader.Create(strNfo, info); if (result == CNfoFile::FULL_NFO) { CLog::Log(LOGDEBUG, "%s Got details from nfo", __FUNCTION__); nfoReader.GetDetails(albumInfo.GetAlbum()); return INFO_ADDED; } else if (result == CNfoFile::URL_NFO || result == CNfoFile::COMBINED_NFO) { CScraperUrl scrUrl(nfoReader.ScraperUrl()); CMusicAlbumInfo albumNfo("nfo",scrUrl); ADDON::ScraperPtr nfoReaderScraper = nfoReader.GetScraperInfo(); CLog::Log(LOGDEBUG,"-- nfo-scraper: %s", nfoReaderScraper->Name().c_str()); CLog::Log(LOGDEBUG,"-- nfo url: %s", scrUrl.m_url[0].m_url.c_str()); scraper.SetScraperInfo(nfoReaderScraper); scraper.GetAlbums().clear(); scraper.GetAlbums().push_back(albumNfo); } else CLog::Log(LOGERROR,"Unable to find an url in nfo file: %s", strNfo.c_str()); } if (!scraper.CheckValidOrFallback(CSettings::Get().GetString("musiclibrary.albumsscraper"))) { // the current scraper is invalid, as is the default - bail CLog::Log(LOGERROR, "%s - current and default scrapers are invalid. Pick another one", __FUNCTION__); return INFO_ERROR; } if (!scraper.GetAlbumCount()) { scraper.FindAlbumInfo(album.strAlbum, StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator)); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); return INFO_CANCELLED; } Sleep(1); } } CGUIDialogSelect *pDlg = NULL; int iSelectedAlbum=0; if (result == CNfoFile::NO_NFO && !bMusicBrainz) { iSelectedAlbum = -1; // set negative so that we can detect a failure if (scraper.Succeeded() && scraper.GetAlbumCount() >= 1) { double bestRelevance = 0; double minRelevance = THRESHOLD; if (scraper.GetAlbumCount() > 1) // score the matches { //show dialog with all albums found if (pDialog) { pDlg = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDlg->SetHeading(g_localizeStrings.Get(181).c_str()); pDlg->Reset(); pDlg->EnableButton(true, 413); // manual } for (int i = 0; i < scraper.GetAlbumCount(); ++i) { CMusicAlbumInfo& info = scraper.GetAlbum(i); double relevance = info.GetRelevance(); if (relevance < 0) relevance = CUtil::AlbumRelevance(info.GetAlbum().strAlbum, album.strAlbum, StringUtils::Join(info.GetAlbum().artist, g_advancedSettings.m_musicItemSeparator), StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator)); // if we're doing auto-selection (ie querying all albums at once, then allow 95->100% for perfect matches) // otherwise, perfect matches only if (relevance >= max(minRelevance, bestRelevance)) { // we auto-select the best of these bestRelevance = relevance; iSelectedAlbum = i; } if (pDialog) { // set the label to [relevance] album - artist std::string strTemp = StringUtils::Format("[%0.2f] %s", relevance, info.GetTitle2().c_str()); CFileItem item(strTemp); item.m_idepth = i; // use this to hold the index of the album in the scraper pDlg->Add(&item); } if (relevance > .99f) // we're so close, no reason to search further break; } if (pDialog && bestRelevance < THRESHOLD) { pDlg->Sort(false); pDlg->DoModal(); // and wait till user selects one if (pDlg->GetSelectedLabel() < 0) { // none chosen if (!pDlg->IsButtonPressed()) return INFO_CANCELLED; // manual button pressed std::string strNewAlbum = album.strAlbum; if (!CGUIKeyboardFactory::ShowAndGetInput(strNewAlbum, g_localizeStrings.Get(16011), false)) return INFO_CANCELLED; if (strNewAlbum == "") return INFO_CANCELLED; std::string strNewArtist = StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator); if (!CGUIKeyboardFactory::ShowAndGetInput(strNewArtist, g_localizeStrings.Get(16025), false)) return INFO_CANCELLED; pDialog->SetLine(0, strNewAlbum); pDialog->SetLine(1, strNewArtist); pDialog->Progress(); CAlbum newAlbum = album; newAlbum.strAlbum = strNewAlbum; newAlbum.artist = StringUtils::Split(strNewArtist, g_advancedSettings.m_musicItemSeparator); return DownloadAlbumInfo(newAlbum, info, albumInfo, pDialog); } iSelectedAlbum = pDlg->GetSelectedItem()->m_idepth; } } else { CMusicAlbumInfo& info = scraper.GetAlbum(0); double relevance = info.GetRelevance(); if (relevance < 0) relevance = CUtil::AlbumRelevance(info.GetAlbum().strAlbum, album.strAlbum, StringUtils::Join(info.GetAlbum().artist, g_advancedSettings.m_musicItemSeparator), StringUtils::Join(album.artist, g_advancedSettings.m_musicItemSeparator)); if (relevance < THRESHOLD) return INFO_NOT_FOUND; iSelectedAlbum = 0; } } if (iSelectedAlbum < 0) return INFO_NOT_FOUND; } scraper.LoadAlbumInfo(iSelectedAlbum); while (!scraper.Completed()) { if (m_bStop) { scraper.Cancel(); return INFO_CANCELLED; } Sleep(1); } if (!scraper.Succeeded()) return INFO_ERROR; albumInfo = scraper.GetAlbum(iSelectedAlbum); if (result == CNfoFile::COMBINED_NFO) nfoReader.GetDetails(albumInfo.GetAlbum(), NULL, true); return INFO_ADDED; }
bool CGUIDialogContentSettings::Show(ADDON::ScraperPtr& scraper, VIDEO::SScanSettings& settings, bool& bRunScan, CONTENT_TYPE musicContext/*=CONTENT_NONE*/) { CGUIDialogContentSettings *dialog = (CGUIDialogContentSettings *)g_windowManager.GetWindow(WINDOW_DIALOG_CONTENT_SETTINGS); if (!dialog) return false; if (scraper) { dialog->m_content = musicContext != CONTENT_NONE ? musicContext : scraper->Content(); dialog->m_origContent = dialog->m_content; dialog->m_scraper = scraper; // toast selected but disabled scrapers if (!scraper->Enabled()) g_application.m_guiDialogKaiToast.QueueNotification(CGUIDialogKaiToast::Error, g_localizeStrings.Get(24023), scraper->Name(), 2000, true); } dialog->m_bRunScan = bRunScan; dialog->m_bScanRecursive = (settings.recurse > 0 && !settings.parent_name) || (settings.recurse > 1 && settings.parent_name); dialog->m_bUseDirNames = settings.parent_name; dialog->m_bExclude = settings.exclude; dialog->m_bSingleItem = settings.parent_name_root; dialog->m_bNoUpdate = settings.noupdate; dialog->m_bNeedSave = false; dialog->DoModal(); if (dialog->m_bNeedSave) { scraper = boost::dynamic_pointer_cast<CScraper>(dialog->m_scraper); CONTENT_TYPE content = dialog->m_content; if (!scraper || content == CONTENT_NONE) { scraper.reset(); bRunScan = false; settings.exclude = dialog->m_bExclude; } else { settings.exclude = false; settings.noupdate = dialog->m_bNoUpdate; bRunScan = dialog->m_bRunScan; scraper->SetPathSettings(content, ""); if (content == CONTENT_TVSHOWS) { settings.parent_name = dialog->m_bSingleItem; settings.parent_name_root = dialog->m_bSingleItem; settings.recurse = 0; } else if (content == CONTENT_MOVIES) { if (dialog->m_bUseDirNames) { settings.parent_name = true; settings.parent_name_root = false; settings.recurse = dialog->m_bScanRecursive ? INT_MAX : 1; if (dialog->m_bSingleItem) { settings.parent_name_root = true; settings.recurse = 0; } } else { settings.parent_name = false; settings.parent_name_root = false; settings.recurse = dialog->m_bScanRecursive ? INT_MAX : 0; } } else if (content == CONTENT_MUSICVIDEOS) { settings.parent_name = false; settings.parent_name_root = false; settings.recurse = dialog->m_bScanRecursive ? INT_MAX : 0; } } } dialog->m_scraper.reset(); dialog->m_content = dialog->m_origContent = CONTENT_NONE; return dialog->m_bNeedSave; }
bool CMusicArtistInfo::Load(CCurlFile& http, const ADDON::ScraperPtr& scraper, const CStdString &strSearch) { return m_bLoaded = scraper->GetArtistDetails(http, m_artistURL, strSearch, m_artist); }