//! @todo Currently no support for "embedded thumb" as there is no easy way to grab it //! without sending a file that has this as it's album to this class void CGUIDialogMusicInfo::OnGetThumb() { CFileItemList items; // Current thumb if (CFile::Exists(m_albumItem->GetArt("thumb"))) { CFileItemPtr item(new CFileItem("thumb://Current", false)); item->SetArt("thumb", m_albumItem->GetArt("thumb")); item->SetLabel(g_localizeStrings.Get(20016)); items.Add(item); } // Grab the thumbnail(s) from the web std::vector<std::string> thumbs; if (m_bArtistInfo) m_artist.thumbURL.GetThumbURLs(thumbs); else m_album.thumbURL.GetThumbURLs(thumbs); for (unsigned int i = 0; i < thumbs.size(); ++i) { std::string strItemPath; strItemPath = StringUtils::Format("thumb://Remote%i", i); CFileItemPtr item(new CFileItem(strItemPath, false)); item->SetArt("thumb", thumbs[i]); item->SetIconImage("DefaultPicture.png"); item->SetLabel(g_localizeStrings.Get(20015)); //! @todo Do we need to clear the cached image? // CTextureCache::GetInstance().ClearCachedImage(thumb); items.Add(item); } // local thumb std::string localThumb; bool existsThumb = false; if (m_bArtistInfo) { CMusicDatabase database; database.Open(); // First look for thumb in the artists folder, the primary location std::string strArtistPath = m_artist.strPath; // Get path when don't already have it. bool artistpathfound = !strArtistPath.empty(); if (!artistpathfound) artistpathfound = database.GetArtistPath(m_artist, strArtistPath); if (artistpathfound) { localThumb = URIUtils::AddFileToFolder(strArtistPath, "folder.jpg"); existsThumb = CFile::Exists(localThumb); } // If not there fall back local to music files (historic location for those album artists with a unique folder) if (!existsThumb) { artistpathfound = database.GetOldArtistPath(m_artist.idArtist, strArtistPath); if (artistpathfound) { localThumb = URIUtils::AddFileToFolder(strArtistPath, "folder.jpg"); existsThumb = CFile::Exists(localThumb); } } } else { localThumb = m_albumItem->GetUserMusicThumb(); existsThumb = CFile::Exists(localThumb); } if (existsThumb) { CFileItemPtr item(new CFileItem("thumb://Local", false)); item->SetArt("thumb", localThumb); item->SetLabel(g_localizeStrings.Get(20017)); items.Add(item); } else { CFileItemPtr item(new CFileItem("thumb://None", false)); if (m_bArtistInfo) item->SetIconImage("DefaultArtist.png"); else item->SetIconImage("DefaultAlbumCover.png"); item->SetLabel(g_localizeStrings.Get(20018)); items.Add(item); } std::string result; bool flip=false; VECSOURCES sources(*CMediaSourceSettings::GetInstance().GetSources("music")); AddItemPathToFileBrowserSources(sources, *m_albumItem); g_mediaManager.GetLocalDrives(sources); if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(1030), result, &flip)) return; // user cancelled if (result == "thumb://Current") return; // user chose the one they have std::string newThumb; if (StringUtils::StartsWith(result, "thumb://Remote")) { int number = atoi(result.substr(14).c_str()); newThumb = thumbs[number]; } else if (result == "thumb://Local") newThumb = localThumb; else if (CFile::Exists(result)) newThumb = result; // update thumb in the database CMusicDatabase db; if (db.Open()) { db.SetArtForItem(m_albumItem->GetMusicInfoTag()->GetDatabaseId(), m_albumItem->GetMusicInfoTag()->GetType(), "thumb", newThumb); db.Close(); } m_albumItem->SetArt("thumb", newThumb); m_hasUpdatedThumb = true; // tell our GUI to completely reload all controls (as some of them // are likely to have had this image in use so will need refreshing) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_windowManager.SendMessage(msg); // Update our screen Update(); }
// Allow user to select a Fanart void CGUIDialogMusicInfo::OnGetFanart() { CFileItemList items; if (m_albumItem->HasArt("fanart")) { CFileItemPtr itemCurrent(new CFileItem("fanart://Current",false)); itemCurrent->SetArt("thumb", m_albumItem->GetArt("fanart")); itemCurrent->SetLabel(g_localizeStrings.Get(20440)); items.Add(itemCurrent); } // Grab the thumbnails from the web for (unsigned int i = 0; i < m_artist.fanart.GetNumFanarts(); i++) { std::string strItemPath = StringUtils::Format("fanart://Remote%i",i); CFileItemPtr item(new CFileItem(strItemPath, false)); std::string thumb = m_artist.fanart.GetPreviewURL(i); item->SetArt("thumb", CTextureUtils::GetWrappedThumbURL(thumb)); item->SetIconImage("DefaultPicture.png"); item->SetLabel(g_localizeStrings.Get(20441)); //! @todo Do we need to clear the cached image? // CTextureCache::GetInstance().ClearCachedImage(thumb); items.Add(item); } // Grab a local fanart std::string strLocal; CMusicDatabase database; database.Open(); // First look for fanart in the artists folder, the primary location std::string strArtistPath = m_artist.strPath; // Get path when don't already have it. bool artistpathfound = !strArtistPath.empty(); if (!artistpathfound) artistpathfound = database.GetArtistPath(m_artist, strArtistPath); if (artistpathfound) { CFileItem item(strArtistPath, true); strLocal = item.GetLocalFanart(); } // If not there fall back local to music files (historic location for those album artists with a unique folder) if (strLocal.empty()) { artistpathfound = database.GetOldArtistPath(m_artist.idArtist, strArtistPath); if (artistpathfound) { CFileItem item(strArtistPath, true); strLocal = item.GetLocalFanart(); } } if (!strLocal.empty()) { CFileItemPtr itemLocal(new CFileItem("fanart://Local",false)); itemLocal->SetArt("thumb", strLocal); itemLocal->SetLabel(g_localizeStrings.Get(20438)); //! @todo Do we need to clear the cached image? CTextureCache::GetInstance().ClearCachedImage(strLocal); items.Add(itemLocal); } else { CFileItemPtr itemNone(new CFileItem("fanart://None", false)); itemNone->SetIconImage("DefaultArtist.png"); itemNone->SetLabel(g_localizeStrings.Get(20439)); items.Add(itemNone); } std::string result; bool flip = false; VECSOURCES sources(*CMediaSourceSettings::GetInstance().GetSources("music")); AddItemPathToFileBrowserSources(sources, *m_albumItem); g_mediaManager.GetLocalDrives(sources); if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(20437), result, &flip, 20445)) return; // user cancelled // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail if (StringUtils::EqualsNoCase(result, "fanart://Current")) return; if (StringUtils::EqualsNoCase(result, "fanart://Local")) result = strLocal; if (StringUtils::StartsWith(result, "fanart://Remote")) { int iFanart = atoi(result.substr(15).c_str()); m_artist.fanart.SetPrimaryFanart(iFanart); result = m_artist.fanart.GetImageURL(); } else if (StringUtils::EqualsNoCase(result, "fanart://None") || !CFile::Exists(result)) result.clear(); if (flip && !result.empty()) result = CTextureUtils::GetWrappedImageURL(result, "", "flipped"); // update thumb in the database CMusicDatabase db; if (db.Open()) { db.SetArtForItem(m_albumItem->GetMusicInfoTag()->GetDatabaseId(), m_albumItem->GetMusicInfoTag()->GetType(), "fanart", result); db.Close(); } m_albumItem->SetArt("fanart", result); m_hasUpdatedThumb = true; // tell our GUI to completely reload all controls (as some of them // are likely to have had this image in use so will need refreshing) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_windowManager.SendMessage(msg); // Update our screen Update(); }
// TODO: Currently no support for "embedded thumb" as there is no easy way to grab it // without sending a file that has this as it's album to this class void CGUIDialogMusicInfo::OnGetThumb() { CFileItemList items; // Current thumb if (CFile::Exists(m_albumItem->GetThumbnailImage())) { CFileItemPtr item(new CFileItem("thumb://Current", false)); item->SetThumbnailImage(m_albumItem->GetThumbnailImage()); item->SetLabel(g_localizeStrings.Get(20016)); items.Add(item); } // Grab the thumbnail(s) from the web vector<CStdString> thumbs; if (m_bArtistInfo) m_artist.thumbURL.GetThumbURLs(thumbs); else m_album.thumbURL.GetThumbURLs(thumbs); for (unsigned int i = 0; i < thumbs.size(); ++i) { CStdString strItemPath; strItemPath.Format("thumb://Remote%i", i); CFileItemPtr item(new CFileItem(strItemPath, false)); item->SetThumbnailImage(thumbs[i]); item->SetIconImage("DefaultPicture.png"); item->SetLabel(g_localizeStrings.Get(20015)); // TODO: Do we need to clear the cached image? // CTextureCache::Get().ClearCachedImage(thumb); items.Add(item); } // local thumb CStdString localThumb; if (m_bArtistInfo) { CMusicDatabase database; database.Open(); CStdString strArtistPath; if (database.GetArtistPath(m_artist.idArtist,strArtistPath)) URIUtils::AddFileToFolder(strArtistPath,"folder.jpg",localThumb); } else localThumb = m_albumItem->GetUserMusicThumb(); if (CFile::Exists(localThumb)) { CFileItemPtr item(new CFileItem("thumb://Local", false)); item->SetThumbnailImage(localThumb); item->SetLabel(g_localizeStrings.Get(20017)); items.Add(item); } else { CFileItemPtr item(new CFileItem("thumb://None", false)); if (m_bArtistInfo) item->SetIconImage("DefaultArtist.png"); else item->SetIconImage("DefaultAlbumCover.png"); item->SetLabel(g_localizeStrings.Get(20018)); items.Add(item); } CStdString result; bool flip=false; VECSOURCES sources(g_settings.m_musicSources); g_mediaManager.GetLocalDrives(sources); if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(1030), result, &flip)) return; // user cancelled if (result == "thumb://Current") return; // user chose the one they have CStdString newThumb; if (result.Left(14) == "thumb://Remote") { int number = atoi(result.Mid(14)); newThumb = thumbs[number]; } else if (result == "thumb://Local") newThumb = localThumb; else if (CFile::Exists(result)) newThumb = result; else // none newThumb = "-"; // force local thumbs to be ignored // update thumb in the database CMusicDatabase db; if (db.Open()) { db.SetArtForItem(m_albumItem->GetMusicInfoTag()->GetDatabaseId(), m_albumItem->GetMusicInfoTag()->GetType(), "thumb", newThumb); db.Close(); } m_albumItem->SetThumbnailImage(newThumb); m_hasUpdatedThumb = true; // tell our GUI to completely reload all controls (as some of them // are likely to have had this image in use so will need refreshing) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_windowManager.SendMessage(msg); // Update our screen Update(); }
// Allow user to select a Fanart void CGUIDialogMusicInfo::OnGetFanart() { CFileItemList items; if (m_albumItem->HasProperty("fanart_image")) { CFileItemPtr itemCurrent(new CFileItem("fanart://Current",false)); itemCurrent->SetThumbnailImage(m_albumItem->GetProperty("fanart_image").asString()); itemCurrent->SetLabel(g_localizeStrings.Get(20440)); items.Add(itemCurrent); } // Grab the thumbnails from the web for (unsigned int i = 0; i < m_artist.fanart.GetNumFanarts(); i++) { CStdString strItemPath; strItemPath.Format("fanart://Remote%i",i); CFileItemPtr item(new CFileItem(strItemPath, false)); CStdString thumb = m_artist.fanart.GetPreviewURL(i); item->SetThumbnailImage(CTextureCache::GetWrappedThumbURL(thumb)); item->SetIconImage("DefaultPicture.png"); item->SetLabel(g_localizeStrings.Get(20441)); // TODO: Do we need to clear the cached image? // CTextureCache::Get().ClearCachedImage(thumb); items.Add(item); } // Grab a local thumb CMusicDatabase database; database.Open(); CStdString strArtistPath; database.GetArtistPath(m_artist.idArtist,strArtistPath); CFileItem item(strArtistPath,true); CStdString strLocal = item.GetLocalFanart(); if (!strLocal.IsEmpty()) { CFileItemPtr itemLocal(new CFileItem("fanart://Local",false)); itemLocal->SetThumbnailImage(strLocal); itemLocal->SetLabel(g_localizeStrings.Get(20438)); // TODO: Do we need to clear the cached image? CTextureCache::Get().ClearCachedImage(strLocal); items.Add(itemLocal); } else { CFileItemPtr itemNone(new CFileItem("fanart://None", false)); itemNone->SetIconImage("DefaultArtist.png"); itemNone->SetLabel(g_localizeStrings.Get(20439)); items.Add(itemNone); } CStdString result; VECSOURCES sources(g_settings.m_musicSources); g_mediaManager.GetLocalDrives(sources); bool flip=false; if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(20437), result, &flip, 20445)) return; // user cancelled // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail if (result.Equals("fanart://Current")) return; if (result.Equals("fanart://Local")) result = strLocal; if (result.Left(15) == "fanart://Remote") { int iFanart = atoi(result.Mid(15).c_str()); m_artist.fanart.SetPrimaryFanart(iFanart); result = m_artist.fanart.GetImageURL(); } else if (result.Equals("fanart://None") || !CFile::Exists(result)) result.clear(); if (flip && !result.empty()) result = CTextureCache::GetWrappedImageURL(result, "", "flipped"); // update thumb in the database CMusicDatabase db; if (db.Open()) { db.SetArtForItem(m_albumItem->GetMusicInfoTag()->GetDatabaseId(), m_albumItem->GetMusicInfoTag()->GetType(), "fanart", result); db.Close(); } if (!result.empty()) m_albumItem->SetProperty("fanart_image",result); else m_albumItem->ClearProperty("fanart_image"); m_hasUpdatedThumb = true; // tell our GUI to completely reload all controls (as some of them // are likely to have had this image in use so will need refreshing) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_windowManager.SendMessage(msg); // Update our screen Update(); }
// TODO: Currently no support for "embedded thumb" as there is no easy way to grab it // without sending a file that has this as it's album to this class void CGUIWindowMusicInfo::OnGetThumb() { CFileItemList items; // Current thumb if (CFile::Exists(m_albumItem->GetThumbnailImage())) { CFileItemPtr item(new CFileItem("thumb://Current", false)); item->SetThumbnailImage(m_albumItem->GetThumbnailImage()); item->SetLabel(g_localizeStrings.Get(20016)); items.Add(item); } // Grab the thumbnail(s) from the web vector<CStdString> thumbs; if (m_bArtistInfo) m_artist.thumbURL.GetThumbURLs(thumbs); else m_album.thumbURL.GetThumbURLs(thumbs); for (unsigned int i = 0; i < thumbs.size(); ++i) { CStdString strItemPath; strItemPath.Format("thumb://Remote%i", i); CFileItemPtr item(new CFileItem(strItemPath, false)); item->SetThumbnailImage(thumbs[i]); item->SetIconImage("DefaultPicture.png"); item->SetLabel(g_localizeStrings.Get(20015)); // TODO: Do we need to clear the cached image? // CTextureCache::Get().ClearCachedImage(thumb); items.Add(item); } // local thumb CStdString localThumb; if (m_bArtistInfo) { CMusicDatabase database; database.Open(); CStdString strArtistPath; if (database.GetArtistPath(m_artist.idArtist,strArtistPath)) CUtil::AddFileToFolder(strArtistPath,"folder.jpg",localThumb); } else localThumb = m_albumItem->GetUserMusicThumb(); if (CFile::Exists(localThumb)) { CFileItemPtr item(new CFileItem("thumb://Local", false)); item->SetThumbnailImage(localThumb); item->SetLabel(g_localizeStrings.Get(20017)); items.Add(item); } else { CFileItemPtr item(new CFileItem("thumb://None", false)); if (m_bArtistInfo) item->SetIconImage("DefaultArtist.png"); else item->SetIconImage("DefaultAlbumCover.png"); item->SetLabel(g_localizeStrings.Get(20018)); items.Add(item); } CStdString result; bool flip=false; VECSOURCES sources(g_settings.m_musicSources); g_mediaManager.GetLocalDrives(sources); if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(1030), result, &flip)) return; // user cancelled if (result == "thumb://Current") return; // user chose the one they have // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail CStdString cachedThumb; if (m_bArtistInfo) cachedThumb = m_albumItem->GetCachedArtistThumb(); else cachedThumb = CUtil::GetCachedAlbumThumb(m_album.strAlbum, m_album.strArtist); CTextureCache::Get().ClearCachedImage(cachedThumb, true); if (result.Left(14) == "thumb://Remote") { int number = atoi(result.Mid(14)); CFile::Cache(thumbs[number], cachedThumb); } else if (result == "thumb://Local") CFile::Cache(localThumb, cachedThumb); else if (CFile::Exists(result)) CPicture::CreateThumbnail(result, cachedThumb); else result = "thumb://None"; if (result == "thumb://None") { // clear this thumb (note - it'll likely be recached, nothing we can do about that at this point) CTextureCache::Get().ClearCachedImage(cachedThumb, true); cachedThumb = ""; } m_albumItem->SetThumbnailImage(cachedThumb); m_hasUpdatedThumb = true; // tell our GUI to completely reload all controls (as some of them // are likely to have had this image in use so will need refreshing) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_windowManager.SendMessage(msg); // Update our screen Update(); }
// Allow user to select a Fanart void CGUIDialogMusicInfo::OnGetFanart() { CFileItemList items; CStdString cachedThumb(CThumbnailCache::GetThumb(m_artist.strArtist,g_settings.GetMusicFanartFolder())); if (CFile::Exists(cachedThumb)) { CFileItemPtr itemCurrent(new CFileItem("fanart://Current",false)); itemCurrent->SetThumbnailImage(cachedThumb); itemCurrent->SetLabel(g_localizeStrings.Get(20440)); items.Add(itemCurrent); } // Grab the thumbnails from the web for (unsigned int i = 0; i < m_artist.fanart.GetNumFanarts(); i++) { CStdString strItemPath; strItemPath.Format("fanart://Remote%i",i); CFileItemPtr item(new CFileItem(strItemPath, false)); CStdString thumb = m_artist.fanart.GetPreviewURL(i); item->SetThumbnailImage(CTextureCache::GetWrappedThumbURL(thumb)); item->SetIconImage("DefaultPicture.png"); item->SetLabel(g_localizeStrings.Get(20441)); // TODO: Do we need to clear the cached image? // CTextureCache::Get().ClearCachedImage(thumb); items.Add(item); } // Grab a local thumb CMusicDatabase database; database.Open(); CStdString strArtistPath; database.GetArtistPath(m_artist.idArtist,strArtistPath); CFileItem item(strArtistPath,true); CStdString strLocal = item.GetLocalFanart(); if (!strLocal.IsEmpty()) { CFileItemPtr itemLocal(new CFileItem("fanart://Local",false)); itemLocal->SetThumbnailImage(strLocal); itemLocal->SetLabel(g_localizeStrings.Get(20438)); // TODO: Do we need to clear the cached image? CTextureCache::Get().ClearCachedImage(strLocal); items.Add(itemLocal); } else { CFileItemPtr itemNone(new CFileItem("fanart://None", false)); itemNone->SetIconImage("DefaultArtist.png"); itemNone->SetLabel(g_localizeStrings.Get(20439)); items.Add(itemNone); } CStdString result; VECSOURCES sources(g_settings.m_musicSources); g_mediaManager.GetLocalDrives(sources); bool flip=false; if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(20437), result, &flip, 20445)) return; // user cancelled // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail if (result.Equals("fanart://Current")) return; if (result.Equals("fanart://Local")) result = strLocal; CTextureCache::Get().ClearCachedImage(cachedThumb, true); if (!result.Equals("fanart://None")) { // local file if (result.Left(15) == "fanart://Remote") { int iFanart = atoi(result.Mid(15).c_str()); m_artist.fanart.SetPrimaryFanart(iFanart); // download the fullres fanart image CStdString tempFile = "special://temp/fanart_download.jpg"; CAsyncFileCopy downloader; if (!downloader.Copy(m_artist.fanart.GetImageURL(), tempFile, g_localizeStrings.Get(13413))) return; result = tempFile; } if (flip) CPicture::ConvertFile(result, cachedThumb,0,1920,-1,100,true); else CPicture::CacheFanart(result, cachedThumb); m_albumItem->SetProperty("fanart_image",cachedThumb); m_hasUpdatedThumb = true; } // tell our GUI to completely reload all controls (as some of them // are likely to have had this image in use so will need refreshing) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_windowManager.SendMessage(msg); // Update our screen Update(); }
bool CGUIWindowVideoNav::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_SET_DEFAULT: g_settings.m_defaultVideoLibSource = GetQuickpathName(item->m_strPath); g_settings.Save(); return true; case CONTEXT_BUTTON_CLEAR_DEFAULT: g_settings.m_defaultVideoLibSource.Empty(); g_settings.Save(); return true; case CONTEXT_BUTTON_EDIT: UpdateVideoTitle(item.get()); CUtil::DeleteVideoDatabaseDirectoryCache(); Update(m_vecItems->m_strPath); return true; case CONTEXT_BUTTON_SET_SEASON_THUMB: case CONTEXT_BUTTON_SET_ACTOR_THUMB: case CONTEXT_BUTTON_SET_ARTIST_THUMB: case CONTEXT_BUTTON_SET_MOVIESET_THUMB: { // Grab the thumbnails from the web CStdString strPath; CFileItemList items; CUtil::AddFileToFolder(g_advancedSettings.m_cachePath,"imdbthumbs",strPath); CUtil::WipeDir(strPath); XFILE::CDirectory::Create(strPath); CFileItemPtr noneitem(new CFileItem("thumb://None", false)); CStdString cachedThumb = m_vecItems->Get(itemNumber)->GetCachedSeasonThumb(); if (button == CONTEXT_BUTTON_SET_ACTOR_THUMB) cachedThumb = m_vecItems->Get(itemNumber)->GetCachedActorThumb(); if (button == CONTEXT_BUTTON_SET_ARTIST_THUMB) cachedThumb = m_vecItems->Get(itemNumber)->GetCachedArtistThumb(); if (button == CONTEXT_BUTTON_SET_MOVIESET_THUMB) cachedThumb = m_vecItems->Get(itemNumber)->GetCachedVideoThumb(); if (CFile::Exists(cachedThumb)) { CFileItemPtr item(new CFileItem("thumb://Current", false)); item->SetThumbnailImage(cachedThumb); item->SetLabel(g_localizeStrings.Get(20016)); items.Add(item); } noneitem->SetIconImage("DefaultFolder.png"); noneitem->SetLabel(g_localizeStrings.Get(20018)); vector<CStdString> thumbs; if (button != CONTEXT_BUTTON_SET_ARTIST_THUMB) { CVideoInfoTag tag; if (button == CONTEXT_BUTTON_SET_SEASON_THUMB) m_database.GetTvShowInfo("",tag,m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_iDbId); else tag = *m_vecItems->Get(itemNumber)->GetVideoInfoTag(); if (button == CONTEXT_BUTTON_SET_SEASON_THUMB) tag.m_strPictureURL.GetThumbURLs(thumbs, m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_iSeason); else tag.m_strPictureURL.GetThumbURLs(thumbs); for (unsigned int i = 0; i < thumbs.size(); i++) { CStdString strItemPath; strItemPath.Format("thumb://Remote%i",i); CFileItemPtr item(new CFileItem(strItemPath, false)); item->SetThumbnailImage(thumbs[i]); item->SetIconImage("DefaultPicture.png"); item->SetLabel(g_localizeStrings.Get(20015)); items.Add(item); // TODO: Do we need to clear the cached image? // CTextureCache::Get().ClearCachedImage(thumbs[i]); } } bool local=false; if (button == CONTEXT_BUTTON_SET_ARTIST_THUMB) { CStdString picturePath; CStdString strPath = m_vecItems->Get(itemNumber)->m_strPath; CUtil::RemoveSlashAtEnd(strPath); int nPos=strPath.ReverseFind("/"); if (nPos>-1) { // try to guess where the user should start // browsing for the artist thumb CMusicDatabase database; database.Open(); long idArtist=database.GetArtistByName(m_vecItems->Get(itemNumber)->GetLabel()); database.GetArtistPath(idArtist, picturePath); } CStdString strThumb; CUtil::AddFileToFolder(picturePath,"folder.jpg",strThumb); if (XFILE::CFile::Exists(strThumb)) { CFileItemPtr pItem(new CFileItem(strThumb,false)); pItem->SetLabel(g_localizeStrings.Get(20017)); pItem->SetThumbnailImage(strThumb); items.Add(pItem); local = true; } else noneitem->SetIconImage("DefaultArtist.png"); } if (button == CONTEXT_BUTTON_SET_ACTOR_THUMB) { CStdString picturePath; CStdString strThumb; CUtil::AddFileToFolder(picturePath,"folder.jpg",strThumb); if (XFILE::CFile::Exists(strThumb)) { CFileItemPtr pItem(new CFileItem(strThumb,false)); pItem->SetLabel(g_localizeStrings.Get(20017)); pItem->SetThumbnailImage(strThumb); items.Add(pItem); local = true; } else noneitem->SetIconImage("DefaultActor.png"); } if (button == CONTEXT_BUTTON_SET_MOVIESET_THUMB) noneitem->SetIconImage("DefaultVideo.png"); if (!local) items.Add(noneitem); VECSOURCES sources=g_settings.m_videoSources; g_mediaManager.GetLocalDrives(sources); CStdString result; if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(20019), result)) { return false; // user cancelled } if (result == "thumb://Current") return false; // user chose the one they have // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail CTextureCache::Get().ClearCachedImage(cachedThumb, true); if (result.Left(14) == "thumb://Remote") { int number = atoi(result.Mid(14)); CFile::Cache(thumbs[number], cachedThumb); } if (result == "thumb://None") CTextureCache::Get().ClearCachedImage(cachedThumb, true); else CFile::Cache(result,cachedThumb); CUtil::DeleteVideoDatabaseDirectoryCache(); CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_windowManager.SendMessage(msg); Update(m_vecItems->m_strPath); return true; } case CONTEXT_BUTTON_UPDATE_LIBRARY: { OnScan(""); return true; } case CONTEXT_BUTTON_UNLINK_MOVIE: { OnLinkMovieToTvShow(itemNumber, true); Update(m_vecItems->m_strPath); return true; } case CONTEXT_BUTTON_LINK_MOVIE: { OnLinkMovieToTvShow(itemNumber, false); return true; } case CONTEXT_BUTTON_GO_TO_ARTIST: { CStdString strPath; CMusicDatabase database; database.Open(); strPath.Format("musicdb://2/%ld/",database.GetArtistByName(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strArtist)); g_windowManager.ActivateWindow(WINDOW_MUSIC_NAV,strPath); return true; } case CONTEXT_BUTTON_GO_TO_ALBUM: { CStdString strPath; CMusicDatabase database; database.Open(); strPath.Format("musicdb://3/%ld/",database.GetAlbumByName(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strAlbum)); g_windowManager.ActivateWindow(WINDOW_MUSIC_NAV,strPath); return true; } case CONTEXT_BUTTON_PLAY_OTHER: { CMusicDatabase database; database.Open(); CSong song; if (database.GetSongById(database.GetSongByArtistAndAlbumAndTitle(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strArtist,m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strAlbum, m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strTitle), song)) { g_application.getApplicationMessenger().PlayFile(song); } return true; } case CONTEXT_BUTTON_UNLINK_BOOKMARK: { m_database.Open(); m_database.DeleteBookMarkForEpisode(*m_vecItems->Get(itemNumber)->GetVideoInfoTag()); m_database.Close(); CUtil::DeleteVideoDatabaseDirectoryCache(); Update(m_vecItems->m_strPath); return true; } default: break; } return CGUIWindowVideoBase::OnContextButton(itemNumber, button); }
// TODO: Currently no support for "embedded thumb" as there is no easy way to grab it // without sending a file that has this as it's album to this class void CGUIWindowMusicInfo::OnGetThumb() { CFileItemList items; // Grab the thumbnail from the web CStdString thumbFromWeb; CUtil::AddFileToFolder(g_advancedSettings.m_cachePath, "allmusicThumb", thumbFromWeb); int iDownloaded=DownloadThumbnail(thumbFromWeb,true); if (iDownloaded > 0) { for (int i=0;i<iDownloaded;++i) { CStdString strThumb; strThumb.Format("thumb://Remote%i",i); CFileItem *item = new CFileItem(strThumb, false); strThumb.Format("%s%i.tbn",thumbFromWeb,i); item->SetThumbnailImage(strThumb); item->SetLabel(g_localizeStrings.Get(20055)); items.Add(item); } } // Current thumb if (CFile::Exists(m_albumItem->GetThumbnailImage())) { CFileItem *item = new CFileItem("thumb://Current", false); item->SetThumbnailImage(m_albumItem->GetThumbnailImage()); item->SetLabel(g_localizeStrings.Get(20016)); items.Add(item); } // local thumb CStdString cachedLocalThumb; CStdString localThumb; if (m_bArtistInfo) { CMusicDatabase database; database.Open(); CStdString strArtistPath; database.GetArtistPath(m_artist.idArtist,strArtistPath); CUtil::AddFileToFolder(strArtistPath,"folder.jpg",localThumb); } else CStdString localThumb = m_albumItem->GetUserMusicThumb(); if (CFile::Exists(localThumb)) { CUtil::AddFileToFolder(g_advancedSettings.m_cachePath, "localthumb.jpg", cachedLocalThumb); CPicture pic; if (pic.DoCreateThumbnail(localThumb, cachedLocalThumb)) { CFileItem *item = new CFileItem("thumb://Local", false); item->SetThumbnailImage(cachedLocalThumb); item->SetLabel(g_localizeStrings.Get(20017)); items.Add(item); } } CFileItem *item = new CFileItem("thumb://None", false); if (m_bArtistInfo) item->SetThumbnailImage("defaultArtistBig.png"); else item->SetThumbnailImage("defaultAlbumCover.png"); item->SetLabel(g_localizeStrings.Get(20018)); items.Add(item); CStdString result; if (!CGUIDialogFileBrowser::ShowAndGetImage(items, g_settings.m_musicSources, g_localizeStrings.Get(1030), result)) return; // user cancelled if (result == "thumb://Current") return; // user chose the one they have // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail CStdString cachedThumb; if (m_bArtistInfo) cachedThumb = m_albumItem->GetCachedArtistThumb(); else cachedThumb = CUtil::GetCachedAlbumThumb(m_album.strAlbum, m_album.strArtist); if (result == "thumb://None") { // cache the default thumb CPicture pic; pic.CacheSkinImage("defaultAlbumCover.png", cachedThumb); } else if (result.Left(14).Equals("thumb://Remote")) CFile::Cache(thumbFromWeb+result.Mid(14)+".tbn", cachedThumb); else if (result == "thumb://Local") CFile::Cache(cachedLocalThumb, cachedThumb); else if (CFile::Exists(result)) { CPicture pic; pic.DoCreateThumbnail(result, cachedThumb); } m_albumItem->SetThumbnailImage(cachedThumb); m_hasUpdatedThumb = true; // tell our GUI to completely reload all controls (as some of them // are likely to have had this image in use so will need refreshing) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_graphicsContext.SendMessage(msg); // Update our screen Update(); }
// Allow user to select a Fanart void CGUIWindowMusicInfo::OnGetFanart() { CFileItemList items; CFileItemPtr itemNone(new CFileItem("fanart://None", false)); itemNone->SetThumbnailImage("DefaultArtistBig.png"); itemNone->SetLabel(g_localizeStrings.Get(20018)); items.Add(itemNone); CMusicDatabase database; database.Open(); CStdString strArtistPath; database.GetArtistPath(m_artist.idArtist,strArtistPath); CStdString cachedThumb(itemNone->GetCachedFanart(strArtistPath)); if (CFile::Exists(cachedThumb)) { CFileItemPtr itemCurrent(new CFileItem("fanart://Current",false)); itemCurrent->SetThumbnailImage(cachedThumb); itemCurrent->SetLabel(g_localizeStrings.Get(20016)); items.Add(itemCurrent); } CFileItem item(strArtistPath,true); CStdString strLocal = item.CacheFanart(true); if (!strLocal.IsEmpty()) { CFileItemPtr itemLocal(new CFileItem("fanart://Local",false)); itemLocal->SetThumbnailImage(strLocal); itemLocal->SetLabel(g_localizeStrings.Get(20017)); items.Add(itemLocal); } CStdString result; VECSOURCES sources(g_settings.m_musicSources); g_mediaManager.GetLocalDrives(sources); if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, g_localizeStrings.Get(20019), result)) return; // user cancelled // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail if (result.Equals("fanart://Current")) return; if (result.Equals("fanart://Local")) result = strLocal; if (CFile::Exists(cachedThumb)) CFile::Delete(cachedThumb); if (!result.Equals("thumb://None") && CFile::Exists(result)) { // local file CPicture pic; pic.CacheImage(result, cachedThumb); } // tell our GUI to completely reload all controls (as some of them // are likely to have had this image in use so will need refreshing) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_graphicsContext.SendMessage(msg); // Update our screen Update(); }
// TODO: Currently no support for "embedded thumb" as there is no easy way to grab it // without sending a file that has this as it's album to this class void CGUIWindowMusicInfo::OnGetThumb() { CFileItemList items; // Grab the thumbnail from the web CStdString thumbFromWeb; CUtil::AddFileToFolder(g_advancedSettings.m_cachePath, "allmusicThumb", thumbFromWeb); CScraperUrl url; if (m_bArtistInfo) url = m_artist.thumbURL; else url = m_album.thumbURL; for (unsigned int i = 0; i < url.m_url.size(); i++) { CStdString strThumb; strThumb.Format("thumb://Remote%i",i); CFileItemPtr item(new CFileItem(strThumb, false)); item->SetThumbnailImage("http://this.is/a/thumb/from/the/web"); item->SetIconImage("defaultPicture.png"); item->GetVideoInfoTag()->m_strPictureURL.m_url.push_back(url.m_url[i]); item->SetLabel(g_localizeStrings.Get(415)); item->SetProperty("labelonthumbload", g_localizeStrings.Get(20015)); // make sure any previously cached thumb is removed if (CFile::Exists(item->GetCachedPictureThumb())) CFile::Delete(item->GetCachedPictureThumb()); items.Add(item); } // Current thumb if (CFile::Exists(m_albumItem->GetThumbnailImage())) { CFileItemPtr item(new CFileItem("thumb://Current", false)); item->SetThumbnailImage(m_albumItem->GetThumbnailImage()); item->SetLabel(g_localizeStrings.Get(20016)); items.Add(item); } // local thumb CStdString cachedLocalThumb; CStdString localThumb; if (m_bArtistInfo) { CMusicDatabase database; database.Open(); CStdString strArtistPath; database.GetArtistPath(m_artist.idArtist,strArtistPath); CUtil::AddFileToFolder(strArtistPath,"folder.jpg",localThumb); } else CStdString localThumb = m_albumItem->GetUserMusicThumb(); if (CFile::Exists(localThumb)) { CUtil::AddFileToFolder(g_advancedSettings.m_cachePath, "localthumb.jpg", cachedLocalThumb); CPicture pic; if (pic.DoCreateThumbnail(localThumb, cachedLocalThumb)) { CFileItemPtr item(new CFileItem("thumb://Local", false)); item->SetThumbnailImage(cachedLocalThumb); item->SetLabel(g_localizeStrings.Get(20017)); items.Add(item); } } CFileItemPtr item(new CFileItem("thumb://None", false)); if (m_bArtistInfo) item->SetThumbnailImage("defaultArtistBig.png"); else item->SetThumbnailImage("defaultAlbumCover.png"); item->SetLabel(g_localizeStrings.Get(20018)); items.Add(item); CStdString result; if (!CGUIDialogFileBrowser::ShowAndGetImage(items, g_settings.m_musicSources, g_localizeStrings.Get(1030), result)) return; // user cancelled if (result == "thumb://Current") return; // user chose the one they have // delete the thumbnail if that's what the user wants, else overwrite with the // new thumbnail CStdString cachedThumb; if (m_bArtistInfo) cachedThumb = m_albumItem->GetCachedArtistThumb(); else cachedThumb = CUtil::GetCachedAlbumThumb(m_album.strAlbum, m_album.strArtist); if (result.Left(14).Equals("thumb://Remote")) { CStdString strFile; CFileItem chosen(result, false); CStdString thumb = chosen.GetCachedPictureThumb(); if (CFile::Exists(thumb)) { // NOTE: This could fail if the thumbloader was too slow and the user too impatient CFile::Cache(thumb, cachedThumb); } else result = "thumb://None"; } if (result == "thumb://None") { // cache the default thumb CPicture pic; pic.CacheSkinImage("defaultAlbumCover.png", cachedThumb); } else if (result == "thumb://Local") CFile::Cache(cachedLocalThumb, cachedThumb); else if (CFile::Exists(result)) { CPicture pic; pic.DoCreateThumbnail(result, cachedThumb); } m_albumItem->SetThumbnailImage(cachedThumb); m_hasUpdatedThumb = true; // tell our GUI to completely reload all controls (as some of them // are likely to have had this image in use so will need refreshing) CGUIMessage msg(GUI_MSG_NOTIFY_ALL, 0, 0, GUI_MSG_REFRESH_THUMBS); g_graphicsContext.SendMessage(msg); // Update our screen Update(); }
// Fetch full album/artist information including art types list bool DoWork() override { CGUIDialogMusicInfo *dialog = CServiceBroker::GetGUI()->GetWindowManager(). GetWindow<CGUIDialogMusicInfo>(WINDOW_DIALOG_MUSIC_INFO); if (!dialog) return false; if (dialog->IsCancelled()) return false; CFileItemPtr m_item = dialog->GetCurrentListItem(); CMusicInfoTag& tag = *m_item->GetMusicInfoTag(); CMusicDatabase database; database.Open(); // May only have partially populated item, so fetch all artist or album data from db if (tag.GetType() == MediaTypeArtist) { int artistId = tag.GetDatabaseId(); CArtist artist; if (!database.GetArtist(artistId, artist)) return false; tag.SetArtist(artist); CMusicDatabase::SetPropertiesFromArtist(*m_item, artist); m_item->SetLabel(artist.strArtist); // Get artist folder where local art could be found // Get the *name* of the folder for this artist within the Artist Info folder (may not exist). // If there is no Artist Info folder specified in settings this will be blank database.GetArtistPath(artist, artist.strPath); // Get the old location for those album artists with a unique folder (local to music files) // If there is no folder for the artist and *only* the artist this will be blank std::string oldartistpath; bool oldpathfound = database.GetOldArtistPath(artist.idArtist, oldartistpath); // Set up path for *item folder when browsing for art, by default this is // in the Artist Info Folder (when it exists), but could end up blank std::string artistItemPath = artist.strPath; if (!CDirectory::Exists(artistItemPath)) { // 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 (oldpathfound) artistItemPath = oldartistpath; else // Fall back further to browse the Artist Info Folder itself artistItemPath = CServiceBroker::GetSettings().GetString(CSettings::SETTING_MUSICLIBRARY_ARTISTSFOLDER); } m_item->SetPath(artistItemPath); // Store info as CArtist as well as item properties dialog->SetArtist(artist, oldartistpath); // Fetch artist discography as scraped from online sources, but always // include all the albums in the music library dialog->SetDiscography(database); } else { // tag.GetType == MediaTypeAlbum int albumId = tag.GetDatabaseId(); CAlbum album; if (!database.GetAlbum(albumId, album)) return false; tag.SetAlbum(album); CMusicDatabase::SetPropertiesFromAlbum(*m_item, album); // Get album folder where local art could be found database.GetAlbumPath(albumId, album.strPath); // Set up path for *item folder when browsing for art m_item->SetPath(album.strPath); // Store info as CAlbum as well as item properties dialog->SetAlbum(album, album.strPath); // Set the list of songs and related art dialog->SetSongs(album.songs); } database.Close(); /* Load current art (to CGUIListItem.m_art) For albums this includes related artist(s) art and artist fanart set as fallback album fanart. Clear item art first to ensure fresh not cached/partial art */ m_item->ClearArt(); CMusicThumbLoader loader; loader.LoadItem(m_item.get()); // Fill vector of possible art types with current art, when it exists, // for display on the art type selection dialog CFileItemList artlist; MUSIC_UTILS::FillArtTypesList(*m_item, artlist); dialog->SetArtTypeList(artlist); if (dialog->IsCancelled()) return false; // Tell waiting MusicDialog that job is complete dialog->FetchComplete(); return true; }