bool CAudioLibrary::FillFileItem(const CStdString &strFilename, CFileItemPtr &item, const CVariant ¶meterObject /* = CVariant(CVariant::VariantTypeArray) */) { CMusicDatabase musicdatabase; if (strFilename.empty() || !musicdatabase.Open()) return false; if (CDirectory::Exists(strFilename)) { CAlbum album; int albumid = musicdatabase.GetAlbumIdByPath(strFilename); if (!musicdatabase.GetAlbumInfo(albumid, album, NULL)) return false; item->SetFromAlbum(album); CFileItemList items; items.Add(item); if (GetAdditionalAlbumDetails(parameterObject, items, musicdatabase) != OK) return false; } else { CSong song; if (!musicdatabase.GetSongByFileName(strFilename, song)) return false; item->SetFromSong(song); CFileItemList items; items.Add(item); if (GetAdditionalSongDetails(parameterObject, items, musicdatabase) != OK) return false; } return true; }
bool CVideoThumbLoader::FillLibraryArt(CFileItem &item) { CVideoInfoTag &tag = *item.GetVideoInfoTag(); if (tag.m_iDbId > -1 && !tag.m_type.empty()) { map<string, string> artwork; m_videoDatabase->Open(); if (m_videoDatabase->GetArtForItem(tag.m_iDbId, tag.m_type, artwork)) SetArt(item, artwork); else if (tag.m_type == MediaTypeArtist) { // we retrieve music video art from the music database (no backward compat) CMusicDatabase database; database.Open(); int idArtist = database.GetArtistByName(item.GetLabel()); if (database.GetArtForItem(idArtist, MediaTypeArtist, artwork)) item.SetArt(artwork); } else if (tag.m_type == MediaTypeAlbum) { // we retrieve music video art from the music database (no backward compat) CMusicDatabase database; database.Open(); int idAlbum = database.GetAlbumByName(item.GetLabel(), tag.m_artist); if (database.GetArtForItem(idAlbum, MediaTypeAlbum, artwork)) item.SetArt(artwork); } // For episodes and seasons, we want to set fanart for that of the show if (!item.HasArt("fanart") && tag.m_iIdShow >= 0) { ArtCache::const_iterator i = m_showArt.find(tag.m_iIdShow); if (i == m_showArt.end()) { map<string, string> showArt; m_videoDatabase->GetArtForItem(tag.m_iIdShow, MediaTypeTvShow, showArt); i = m_showArt.insert(make_pair(tag.m_iIdShow, showArt)).first; } if (i != m_showArt.end()) { item.AppendArt(i->second, "tvshow"); item.SetArtFallback("fanart", "tvshow.fanart"); item.SetArtFallback("tvshow.thumb", "tvshow.poster"); } } m_videoDatabase->Close(); } return !item.GetArt().empty(); }
JSONRPC_STATUS CAudioLibrary::GetSongDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { int idSong = (int)parameterObject["songid"].asInteger(); CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return InternalError; CSong song; if (!musicdatabase.GetSong(idSong, song)) return InvalidParams; CFileItemList items; CFileItemPtr item = CFileItemPtr(new CFileItem(song)); FillItemArtistIDs(song.GetArtistIDArray(), item); items.Add(item); JSONRPC_STATUS ret = GetAdditionalSongDetails(parameterObject, items, musicdatabase); if (ret != OK) return ret; HandleFileItem("songid", true, "songdetails", items[0], parameterObject, parameterObject["properties"], result, false); return OK; }
void CGUIDialogMusicInfo::SetAlbum(const CAlbum& album, const CStdString &path) { m_album = album; SetSongs(m_album.songs); *m_albumItem = CFileItem(path, true); m_albumItem->GetMusicInfoTag()->SetAlbum(m_album.strAlbum); m_albumItem->GetMusicInfoTag()->SetAlbumArtist(StringUtils::Join(m_album.artist, g_advancedSettings.m_musicItemSeparator)); m_albumItem->GetMusicInfoTag()->SetArtist(m_album.artist); m_albumItem->GetMusicInfoTag()->SetYear(m_album.iYear); m_albumItem->GetMusicInfoTag()->SetLoaded(true); m_albumItem->GetMusicInfoTag()->SetRating('0' + m_album.iRating); m_albumItem->GetMusicInfoTag()->SetGenre(m_album.genre); m_albumItem->GetMusicInfoTag()->SetDatabaseId(m_album.idAlbum, "album"); CMusicDatabase::SetPropertiesFromAlbum(*m_albumItem,m_album); CMusicThumbLoader loader; loader.LoadItem(m_albumItem.get()); // set the artist thumb, fanart if (!m_album.artist.empty()) { CMusicDatabase db; db.Open(); map<string, string> artwork; if (db.GetArtistArtForItem(m_album.idAlbum, "album", artwork)) { if (artwork.find("thumb") != artwork.end()) m_albumItem->SetProperty("artistthumb", artwork["thumb"]); if (artwork.find("fanart") != artwork.end()) m_albumItem->SetArt("fanart",artwork["fanart"]); } } m_hasUpdatedThumb = false; m_bArtistInfo = false; m_albumSongs->SetContent("albums"); }
JSONRPC_STATUS CAudioLibrary::GetProperties(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { CVariant properties = CVariant(CVariant::VariantTypeObject); for (CVariant::const_iterator_array it = parameterObject["properties"].begin_array(); it != parameterObject["properties"].end_array(); it++) { std::string propertyName = it->asString(); CVariant property; if (propertyName == "missingartistid") property = (int)BLANKARTIST_ID; else if (propertyName == "librarylastupdated") { CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return InternalError; property = musicdatabase.GetLibraryLastUpdated(); } properties[propertyName] = property; } result = properties; return OK; }
JSONRPC_STATUS CAudioLibrary::GetRecentlyPlayedAlbums(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return InternalError; VECALBUMS albums; if (!musicdatabase.GetRecentlyPlayedAlbums(albums)) return InternalError; CFileItemList items; for (unsigned int index = 0; index < albums.size(); index++) { CStdString path; path.Format("musicdb://7/%i/", albums[index].idAlbum); CFileItemPtr item; FillAlbumItem(albums[index], path, item); items.Add(item); } HandleFileItemList("albumid", false, "albums", items, parameterObject, result); return OK; }
CStdString CMusicDatabaseFile::TranslateUrl(const CURL& url) { CMusicDatabase musicDatabase; if (!musicDatabase.Open()) return ""; CStdString strFileName=URIUtils::GetFileName(url.Get()); CStdString strExtension = URIUtils::GetExtension(strFileName); URIUtils::RemoveExtension(strFileName); if (!StringUtils::IsNaturalNumber(strFileName)) return ""; long idSong=atol(strFileName.c_str()); CSong song; if (!musicDatabase.GetSong(idSong, song)) return ""; if (!URIUtils::HasExtension(song.strFileName, strExtension)) return ""; return song.strFileName; }
bool CDirectoryNodeAlbumRecentlyAdded::GetContent(CFileItemList& items) const { CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return false; VECALBUMS albums; if (!musicdatabase.GetRecentlyAddedAlbums(albums)) { musicdatabase.Close(); return false; } for (int i=0; i<(int)albums.size(); ++i) { CAlbum& album=albums[i]; std::string strDir = StringUtils::Format("%s%ld/", BuildPath().c_str(), album.idAlbum); CFileItemPtr pItem(new CFileItem(strDir, album)); items.Add(pItem); } musicdatabase.Close(); return true; }
bool CLastFmManager::Unlove(const CMusicInfoTag& musicinfotag, bool askConfirmation /*= true*/) { if (!IsLastFmEnabled()) { CLog::Log(LOGERROR, "LastFmManager Unlove, lasfm is not enabled"); return false; } CStdString strTitle = musicinfotag.GetTitle(); CStdString strArtist = StringUtils::Join(musicinfotag.GetArtist(), g_advancedSettings.m_musicItemSeparator); if (strArtist.IsEmpty()) { CLog::Log(LOGERROR, "Last.fm Unlove no artistname provided."); return false; } if (strTitle.IsEmpty()) { CLog::Log(LOGERROR, "Last.fm Unlove no tracktitle provided."); return false; } CStdString strInfo; strInfo.Format("%s - %s", strArtist, strTitle); if (!askConfirmation || CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(15200), g_localizeStrings.Get(15297), strInfo, "")) { if (CallXmlRpc("unLoveTrack", strArtist, strTitle)) { //update our local rating, now this is tricky because we only have an artist and title //and don't know if it was a local or radio song. //So we're going to try to get it from the database and check if the rating is 5, //if it is we can assume this was the song we loved before. CMusicDatabase musicdatabase; if (musicdatabase.Open()) { long songid = musicdatabase.GetSongByArtistAndAlbumAndTitle(strArtist, "%", strTitle); if (songid > 0) { CSong song; musicdatabase.GetSongById(songid, song); if (song.rating == '5') { //reset the rating musicdatabase.SetSongRating(song.strFileName, '0'); } } musicdatabase.Close(); } return true; } } return false; }
bool CRecentlyAddedJob::UpdateTotal() { CGUIWindow* home = g_windowManager.GetWindow(WINDOW_HOME); if ( home == NULL ) return false; CLog::Log(LOGDEBUG, "CRecentlyAddedJob::UpdateTotal() - Running RecentlyAdded home screen update"); CVideoDatabase videodatabase; CMusicDatabase musicdatabase; musicdatabase.Open(); int MusSongTotals = atoi(musicdatabase.GetSingleValue("songview" , "count(1)").c_str()); int MusAlbumTotals = atoi(musicdatabase.GetSingleValue("songview" , "count(distinct strAlbum)").c_str()); int MusArtistTotals = atoi(musicdatabase.GetSingleValue("songview" , "count(distinct strArtists)").c_str()); musicdatabase.Close(); videodatabase.Open(); int tvShowCount = atoi(videodatabase.GetSingleValue("tvshow_view" , "count(1)").c_str()); int movieTotals = atoi(videodatabase.GetSingleValue("movie_view" , "count(1)").c_str()); int movieWatched = atoi(videodatabase.GetSingleValue("movie_view" , "count(playCount)").c_str()); int MusVidTotals = atoi(videodatabase.GetSingleValue("musicvideo_view" , "count(1)").c_str()); int MusVidWatched = atoi(videodatabase.GetSingleValue("musicvideo_view" , "count(playCount)").c_str()); int EpWatched = atoi(videodatabase.GetSingleValue("tvshow_view" , "sum(watchedcount)").c_str()); int EpCount = atoi(videodatabase.GetSingleValue("tvshow_view" , "sum(totalcount)").c_str()); int TvShowsWatched = atoi(videodatabase.GetSingleValue("tvshow_view" , "sum(watchedcount = totalcount)").c_str()); videodatabase.Close(); home->SetProperty("TVShows.Count" , tvShowCount); home->SetProperty("TVShows.Watched" , TvShowsWatched); home->SetProperty("TVShows.UnWatched" , tvShowCount - TvShowsWatched); home->SetProperty("Episodes.Count" , EpCount); home->SetProperty("Episodes.Watched" , EpWatched); home->SetProperty("Episodes.UnWatched" , EpCount-EpWatched); home->SetProperty("Movies.Count" , movieTotals); home->SetProperty("Movies.Watched" , movieWatched); home->SetProperty("Movies.UnWatched" , movieTotals - movieWatched); home->SetProperty("MusicVideos.Count" , MusVidTotals); home->SetProperty("MusicVideos.Watched" , MusVidWatched); home->SetProperty("MusicVideos.UnWatched" , MusVidTotals - MusVidWatched); home->SetProperty("Music.SongsCount" , MusSongTotals); home->SetProperty("Music.AlbumsCount" , MusAlbumTotals); home->SetProperty("Music.ArtistsCount" , MusArtistTotals); return true; }
void CMediaSettings::OnSettingAction(const CSetting *setting) { if (setting == NULL) return; const std::string &settingId = setting->GetId(); if (settingId == "karaoke.export") { CContextButtons choices; choices.Add(1, g_localizeStrings.Get(22034)); choices.Add(2, g_localizeStrings.Get(22035)); int retVal = CGUIDialogContextMenu::ShowAndGetChoice(choices); if ( retVal > 0 ) { std::string path(CProfilesManager::Get().GetDatabaseFolder()); VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(661), path, true)) { CMusicDatabase musicdatabase; musicdatabase.Open(); if ( retVal == 1 ) { path = URIUtils::AddFileToFolder(path, "karaoke.html"); musicdatabase.ExportKaraokeInfo( path, true ); } else { path = URIUtils::AddFileToFolder(path, "karaoke.csv"); musicdatabase.ExportKaraokeInfo( path, false ); } musicdatabase.Close(); } } } else if (settingId == "karaoke.importcsv") { std::string path(CProfilesManager::Get().GetDatabaseFolder()); VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "karaoke.csv", g_localizeStrings.Get(651) , path)) { CMusicDatabase musicdatabase; musicdatabase.Open(); musicdatabase.ImportKaraokeInfo(path); musicdatabase.Close(); } } else if (settingId == "musiclibrary.cleanup") { if (CGUIDialogYesNo::ShowAndGetInput(CVariant{313}, CVariant{333})) g_application.StartMusicCleanup(true); } else if (settingId == "musiclibrary.export") CBuiltins::Execute("exportlibrary(music)"); else if (settingId == "musiclibrary.import") { std::string path; VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "musicdb.xml", g_localizeStrings.Get(651) , path)) { CMusicDatabase musicdatabase; musicdatabase.Open(); musicdatabase.ImportFromXML(path); musicdatabase.Close(); } } else if (settingId == "videolibrary.cleanup") { if (CGUIDialogYesNo::ShowAndGetInput(CVariant{313}, CVariant{333})) g_application.StartVideoCleanup(true); } else if (settingId == "videolibrary.export") CBuiltins::Execute("exportlibrary(video)"); else if (settingId == "videolibrary.import") { std::string path; VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(651) , path)) { CVideoDatabase videodatabase; videodatabase.Open(); videodatabase.ImportFromXML(path); videodatabase.Close(); } } }
bool CGUIWindowVideoNav::OnContextButton(int itemNumber, CONTEXT_BUTTON button) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); if (CGUIDialogContextMenu::OnContextButton("video", item, button)) { //! @todo should we search DB for entries from plugins? if (button == CONTEXT_BUTTON_REMOVE_SOURCE && !item->IsPlugin() && !item->IsLiveTV() &&!item->IsRSS() && !URIUtils::IsUPnP(item->GetPath())) { // if the source has been properly removed, remove the cached source list because the list has changed if (OnUnAssignContent(item->GetPath(), 20375, 20340)) m_vecItems->RemoveDiscCache(GetID()); } Refresh(); return true; } switch (button) { case CONTEXT_BUTTON_EDIT: { CONTEXT_BUTTON ret = (CONTEXT_BUTTON)CGUIDialogVideoInfo::ManageVideoItem(item); if (ret >= 0) { Refresh(true); if (ret == CONTEXT_BUTTON_DELETE) { int select = itemNumber >= m_vecItems->Size()-1 ? itemNumber-1:itemNumber; m_viewControl.SetSelectedItem(select); } } return true; } case CONTEXT_BUTTON_SET_ACTOR_THUMB: case CONTEXT_BUTTON_SET_ARTIST_THUMB: { std::string type = MediaTypeSeason; if (button == CONTEXT_BUTTON_SET_ACTOR_THUMB) type = "actor"; else if (button == CONTEXT_BUTTON_SET_ARTIST_THUMB) type = MediaTypeArtist; bool result = CGUIDialogVideoInfo::ManageVideoItemArtwork(m_vecItems->Get(itemNumber), type); Refresh(); return result; } case CONTEXT_BUTTON_GO_TO_ARTIST: { std::string strPath; CMusicDatabase database; database.Open(); strPath = StringUtils::Format("musicdb://artists/%i/", database.GetArtistByName(StringUtils::Join(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator))); g_windowManager.ActivateWindow(WINDOW_MUSIC_NAV,strPath); return true; } case CONTEXT_BUTTON_GO_TO_ALBUM: { std::string strPath; CMusicDatabase database; database.Open(); strPath = StringUtils::Format("musicdb://albums/%i/", 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.GetSong(database.GetSongByArtistAndAlbumAndTitle(StringUtils::Join(m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_artist, g_advancedSettings.m_videoItemSeparator),m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strAlbum, m_vecItems->Get(itemNumber)->GetVideoInfoTag()->m_strTitle), song)) { CApplicationMessenger::GetInstance().PostMsg(TMSG_MEDIA_PLAY, 0, 0, static_cast<void*>(new CFileItem(song))); } return true; } case CONTEXT_BUTTON_SCAN_TO_LIBRARY: CGUIDialogVideoInfo::ShowFor(*item); return true; default: break; } return CGUIWindowVideoBase::OnContextButton(itemNumber, button); }
bool CRecentlyAddedJob::UpdateMusic() { CGUIWindow* home = g_windowManager.GetWindow(WINDOW_HOME); if ( home == NULL ) return false; CLog::Log(LOGDEBUG, "CRecentlyAddedJob::UpdateMusic() - Running RecentlyAdded home screen update"); int i = 0; CFileItemList musicItems; CMusicDatabase musicdatabase; CMusicThumbLoader loader; loader.Initialize(); musicdatabase.Open(); if (musicdatabase.GetRecentlyAddedAlbumSongs("musicdb://4/", musicItems, NUM_ITEMS)) { long idAlbum = -1; CStdString strAlbumThumb; CStdString strAlbumFanart; for (; i < musicItems.Size(); ++i) { CFileItemPtr item = musicItems.Get(i); CStdString value; value.Format("%i", i + 1); CStdString strRating; CStdString strAlbum = item->GetMusicInfoTag()->GetAlbum(); CStdString strArtist = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator); if (idAlbum != item->GetMusicInfoTag()->GetAlbumId()) { strAlbumThumb.clear(); strAlbumFanart.clear(); idAlbum = item->GetMusicInfoTag()->GetAlbumId(); if (loader.LoadItem(item.get())) { strAlbumThumb = item->GetArt("thumb"); strAlbumFanart = item->GetArt("fanart"); } } strRating.Format("%c", item->GetMusicInfoTag()->GetRating()); home->SetProperty("LatestSong." + value + ".Title" , item->GetMusicInfoTag()->GetTitle()); home->SetProperty("LatestSong." + value + ".Year" , item->GetMusicInfoTag()->GetYear()); home->SetProperty("LatestSong." + value + ".Artist" , strArtist); home->SetProperty("LatestSong." + value + ".Album" , strAlbum); home->SetProperty("LatestSong." + value + ".Rating" , strRating); home->SetProperty("LatestSong." + value + ".Path" , item->GetMusicInfoTag()->GetURL()); home->SetProperty("LatestSong." + value + ".Thumb" , strAlbumThumb); home->SetProperty("LatestSong." + value + ".Fanart" , strAlbumFanart); } } for (; i < NUM_ITEMS; ++i) { CStdString value; value.Format("%i", i + 1); home->SetProperty("LatestSong." + value + ".Title" , ""); home->SetProperty("LatestSong." + value + ".Year" , ""); home->SetProperty("LatestSong." + value + ".Artist" , ""); home->SetProperty("LatestSong." + value + ".Album" , ""); home->SetProperty("LatestSong." + value + ".Rating" , ""); home->SetProperty("LatestSong." + value + ".Path" , ""); home->SetProperty("LatestSong." + value + ".Thumb" , ""); home->SetProperty("LatestSong." + value + ".Fanart" , ""); } i = 0; VECALBUMS albums; if (musicdatabase.GetRecentlyAddedAlbums(albums, NUM_ITEMS)) { for (; i < (int)albums.size(); ++i) { CStdString value; CStdString strPath; CStdString strThumb; CStdString strFanart; CStdString strDBpath; CStdString strSQLAlbum; CAlbum& album=albums[i]; value.Format("%i", i + 1); strThumb = musicdatabase.GetArtForItem(album.idAlbum, "album", "thumb"); strFanart = musicdatabase.GetArtistArtForItem(album.idAlbum, "album", "fanart"); strDBpath.Format("musicdb://3/%i/", album.idAlbum); strSQLAlbum.Format("idAlbum=%i", album.idAlbum); CStdString strArtist = musicdatabase.GetSingleValue("albumview", "strArtists", strSQLAlbum); home->SetProperty("LatestAlbum." + value + ".Title" , album.strAlbum); home->SetProperty("LatestAlbum." + value + ".Year" , album.iYear); home->SetProperty("LatestAlbum." + value + ".Artist" , strArtist); home->SetProperty("LatestAlbum." + value + ".Rating" , album.iRating); home->SetProperty("LatestAlbum." + value + ".Path" , strDBpath); home->SetProperty("LatestAlbum." + value + ".Thumb" , strThumb); home->SetProperty("LatestAlbum." + value + ".Fanart" , strFanart); } } for (; i < NUM_ITEMS; ++i) { CStdString value; value.Format("%i", i + 1); home->SetProperty("LatestAlbum." + value + ".Title" , ""); home->SetProperty("LatestAlbum." + value + ".Year" , ""); home->SetProperty("LatestAlbum." + value + ".Artist" , ""); home->SetProperty("LatestAlbum." + value + ".Rating" , ""); home->SetProperty("LatestAlbum." + value + ".Path" , ""); home->SetProperty("LatestAlbum." + value + ".Thumb" , ""); home->SetProperty("LatestAlbum." + value + ".Fanart" , ""); } musicdatabase.Close(); return true; }
// 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(); }
void CGUIDialogSmartPlaylistRule::OnBrowse() { CFileItemList items; CMusicDatabase database; database.Open(); CVideoDatabase videodatabase; videodatabase.Open(); std::string basePath; if (CSmartPlaylist::IsMusicType(m_type)) basePath = "musicdb://"; else basePath = "videodb://"; VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_type == "movies") basePath += "movies/"; else if (m_type == "tvshows") { type = VIDEODB_CONTENT_TVSHOWS; basePath += "tvshows/"; } else if (m_type == "musicvideos") { type = VIDEODB_CONTENT_MUSICVIDEOS; basePath += "musicvideos/"; } else if (m_type == "episodes") { if (m_rule.m_field == FieldGenre || m_rule.m_field == FieldYear || m_rule.m_field == FieldStudio) type = VIDEODB_CONTENT_TVSHOWS; else type = VIDEODB_CONTENT_EPISODES; basePath += "tvshows/"; } int iLabel = 0; if (m_rule.m_field == FieldGenre) { if (m_type == "tvshows" || m_type == "episodes" || m_type == "movies") videodatabase.GetGenresNav(basePath + "genres/", items, type); else if (m_type == "songs" || m_type == "albums" || m_type == "artists" || m_type == "mixed") database.GetGenresNav("musicdb://genres/",items); if (m_type == "musicvideos" || m_type == "mixed") { CFileItemList items2; videodatabase.GetGenresNav("videodb://musicvideos/genres/",items2,VIDEODB_CONTENT_MUSICVIDEOS); items.Append(items2); } iLabel = 515; } else if (m_rule.m_field == FieldCountry) { videodatabase.GetCountriesNav(basePath, items, type); iLabel = 574; } else if (m_rule.m_field == FieldArtist || m_rule.m_field == FieldAlbumArtist) { if (CSmartPlaylist::IsMusicType(m_type)) database.GetArtistsNav("musicdb://artists/", items, m_rule.m_field == FieldAlbumArtist, -1); if (m_type == "musicvideos" || m_type == "mixed") { CFileItemList items2; videodatabase.GetMusicVideoArtistsByName("", items2); items.Append(items2); } iLabel = 557; } else if (m_rule.m_field == FieldAlbum) { if (CSmartPlaylist::IsMusicType(m_type)) database.GetAlbumsNav("musicdb://albums/", items); if (m_type == "musicvideos" || m_type == "mixed") { CFileItemList items2; videodatabase.GetMusicVideoAlbumsByName("", items2); items.Append(items2); } iLabel = 558; } else if (m_rule.m_field == FieldActor) { videodatabase.GetActorsNav(basePath + "actors/",items,type); iLabel = 20337; } else if (m_rule.m_field == FieldYear) { if (CSmartPlaylist::IsMusicType(m_type)) database.GetYearsNav("musicdb://years/", items); if (CSmartPlaylist::IsVideoType(m_type)) { CFileItemList items2; videodatabase.GetYearsNav(basePath + "years/", items2, type); items.Append(items2); } iLabel = 562; } else if (m_rule.m_field == FieldDirector) { videodatabase.GetDirectorsNav(basePath + "directors/", items, type); iLabel = 20339; } else if (m_rule.m_field == FieldStudio) { videodatabase.GetStudiosNav(basePath + "studios/", items, type); iLabel = 572; } else if (m_rule.m_field == FieldWriter) { videodatabase.GetWritersNav(basePath, items, type); iLabel = 20417; } else if (m_rule.m_field == FieldTvShowTitle || (m_type == "tvshows" && m_rule.m_field == FieldTitle)) { videodatabase.GetTvShowsNav(basePath + "titles/", items); iLabel = 20343; } else if (m_rule.m_field == FieldTitle) { if (m_type == "songs" || m_type == "mixed") { database.GetSongsNav("musicdb://songs/", items, -1, -1, -1); iLabel = 134; } if (m_type == "movies") { videodatabase.GetMoviesNav(basePath + "titles/", items); iLabel = 20342; } if (m_type == "episodes") { videodatabase.GetEpisodesNav(basePath + "titles/-1/-1/", items); // we need to replace the db label (<season>x<episode> <title>) with the title only CLabelFormatter format("%T", ""); for (int i = 0; i < items.Size(); i++) format.FormatLabel(items[i].get()); iLabel = 20360; } if (m_type == "musicvideos" || m_type == "mixed") { videodatabase.GetMusicVideosNav(basePath + "titles/", items); iLabel = 20389; } } else if (m_rule.m_field == FieldPlaylist || m_rule.m_field == FieldVirtualFolder) { // use filebrowser to grab another smart playlist // Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't // think there's any decent way to deal with this, as the infinite loop may be an arbitrary // number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1 if (CSmartPlaylist::IsVideoType(m_type)) XFILE::CDirectory::GetDirectory("special://videoplaylists/", items, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS); if (CSmartPlaylist::IsMusicType(m_type)) { CFileItemList items2; XFILE::CDirectory::GetDirectory("special://musicplaylists/", items2, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS); items.Append(items2); } for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; CSmartPlaylist playlist; // don't list unloadable smartplaylists or any referencable smartplaylists // which do not match the type of the current smartplaylist if (!playlist.Load(item->GetPath()) || (m_rule.m_field == FieldPlaylist && (!CSmartPlaylist::CheckTypeCompatibility(m_type, playlist.GetType()) || (!playlist.GetGroup().empty() || playlist.IsGroupMixed())))) { items.Remove(i); i -= 1; continue; } if (!playlist.GetName().empty()) item->SetLabel(playlist.GetName()); } iLabel = 559; } else if (m_rule.m_field == FieldPath) { VECSOURCES sources; if (m_type == "songs" || m_type == "mixed") sources = *CMediaSourceSettings::GetInstance().GetSources("music"); if (CSmartPlaylist::IsVideoType(m_type)) { VECSOURCES sources2 = *CMediaSourceSettings::GetInstance().GetSources("video"); sources.insert(sources.end(),sources2.begin(),sources2.end()); } g_mediaManager.GetLocalDrives(sources); std::string path = m_rule.GetParameter(); CGUIDialogFileBrowser::ShowAndGetDirectory(sources, g_localizeStrings.Get(657), path, false); if (m_rule.m_parameter.size() > 0) m_rule.m_parameter.clear(); if (!path.empty()) m_rule.m_parameter.push_back(path); UpdateButtons(); return; } else if (m_rule.m_field == FieldSet) { videodatabase.GetSetsNav("videodb://movies/sets/", items, VIDEODB_CONTENT_MOVIES); iLabel = 20434; } else if (m_rule.m_field == FieldTag) { VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_type == "tvshows" || m_type == "episodes") type = VIDEODB_CONTENT_TVSHOWS; else if (m_type == "musicvideos") type = VIDEODB_CONTENT_MUSICVIDEOS; else if (m_type != "movies") return; videodatabase.GetTagsNav(basePath + "tags/", items, type); iLabel = 20459; } else { // TODO: Add browseability in here. assert(false); } // sort the items items.Sort(SortByLabel, SortOrderAscending, CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&items); std::string strHeading = StringUtils::Format(g_localizeStrings.Get(13401).c_str(), g_localizeStrings.Get(iLabel).c_str()); pDialog->SetHeading(CVariant{std::move(strHeading)}); pDialog->SetMultiSelection(m_rule.m_field != FieldPlaylist && m_rule.m_field != FieldVirtualFolder); if (!m_rule.m_parameter.empty()) pDialog->SetSelected(m_rule.m_parameter); pDialog->Open(); if (pDialog->IsConfirmed()) { m_rule.m_parameter.clear(); for (int i : pDialog->GetSelectedItems()) m_rule.m_parameter.push_back(items.Get(i)->GetLabel()); UpdateButtons(); } pDialog->Reset(); }
bool CSmartPlaylistDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items) { // Load in the SmartPlaylist and get the WHERE query CSmartPlaylist playlist; if (!playlist.Load(strPath)) return false; bool success = false, success2 = false; if (playlist.GetType().Equals("tvshows")) { CVideoDatabase db; db.Open(); CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db); success = db.GetTvShowsByWhere("videodb://2/2/", whereOrder, items); items.SetContent("tvshows"); db.Close(); } else if (playlist.GetType().Equals("episodes")) { CVideoDatabase db; db.Open(); CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db); success = db.GetEpisodesByWhere("videodb://2/2/", whereOrder, items); items.SetContent("episodes"); db.Close(); } else if (playlist.GetType().Equals("movies")) { CVideoDatabase db; db.Open(); success = db.GetMoviesByWhere("videodb://1/2/", playlist.GetWhereClause(db), playlist.GetOrderClause(db), items, true); items.SetContent("movies"); db.Close(); } else if (playlist.GetType().Equals("albums")) { CMusicDatabase db; db.Open(); success = db.GetAlbumsByWhere("musicdb://3/", playlist.GetWhereClause(db), playlist.GetOrderClause(db), items); items.SetContent("albums"); db.Close(); } if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty()) { CMusicDatabase db; db.Open(); CStdString type=playlist.GetType(); if (type.IsEmpty()) type = "songs"; if (playlist.GetType().Equals("mixed")) playlist.SetType("songs"); CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db); success = db.GetSongsByWhere("", whereOrder, items); items.SetContent("songs"); db.Close(); playlist.SetType(type); } if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed")) { CVideoDatabase db; db.Open(); CStdString type=playlist.GetType(); if (playlist.GetType().Equals("mixed")) playlist.SetType("musicvideos"); CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db); CFileItemList items2; success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2, false); // TODO: SMARTPLAYLISTS Don't check locks??? db.Close(); items.Append(items2); if (items2.Size()) items.SetContent("musicvideos"); playlist.SetType(type); } // go through and set the playlist order for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; item->m_iprogramCount = i; // hack for playlist order } if (playlist.GetType().Equals("mixed")) return success || success2; else if (playlist.GetType().Equals("musicvideos")) return success2; else return success; }
void CAnnouncementManager::Announce(AnnouncementFlag flag, const char *sender, const char *message, CFileItemPtr item, CVariant &data) { if (!item.get()) { Announce(flag, sender, message, data); return; } // Extract db id of item CVariant object = data.isNull() || data.isObject() ? data : CVariant::VariantTypeObject; CStdString type; int id = 0; if(item->HasPVRChannelInfoTag()) { const PVR::CPVRChannel *channel = item->GetPVRChannelInfoTag(); id = channel->ChannelID(); type = "channel"; object["item"]["title"] = channel->ChannelName(); object["item"]["channeltype"] = channel->IsRadio() ? "radio" : "tv"; if (data.isMember("player") && data["player"].isMember("playerid")) object["player"]["playerid"] = channel->IsRadio() ? PLAYLIST_MUSIC : PLAYLIST_VIDEO; } else if (item->HasVideoInfoTag()) { id = item->GetVideoInfoTag()->m_iDbId; // TODO: Can be removed once this is properly handled when starting playback of a file if (id <= 0 && !item->GetPath().empty() && (!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean())) { CVideoDatabase videodatabase; if (videodatabase.Open()) { if (videodatabase.LoadVideoInfo(item->GetPath(), *item->GetVideoInfoTag())) id = item->GetVideoInfoTag()->m_iDbId; videodatabase.Close(); } } if (!item->GetVideoInfoTag()->m_type.empty()) type = item->GetVideoInfoTag()->m_type; else CVideoDatabase::VideoContentTypeToString((VIDEODB_CONTENT_TYPE)item->GetVideoContentType(), type); if (id <= 0) { // TODO: Can be removed once this is properly handled when starting playback of a file item->SetProperty(LOOKUP_PROPERTY, false); object["item"]["title"] = item->GetVideoInfoTag()->m_strTitle; switch (item->GetVideoContentType()) { case VIDEODB_CONTENT_MOVIES: if (item->GetVideoInfoTag()->m_iYear > 0) object["item"]["year"] = item->GetVideoInfoTag()->m_iYear; break; case VIDEODB_CONTENT_EPISODES: if (item->GetVideoInfoTag()->m_iEpisode >= 0) object["item"]["episode"] = item->GetVideoInfoTag()->m_iEpisode; if (item->GetVideoInfoTag()->m_iSeason >= 0) object["item"]["season"] = item->GetVideoInfoTag()->m_iSeason; if (!item->GetVideoInfoTag()->m_strShowTitle.empty()) object["item"]["showtitle"] = item->GetVideoInfoTag()->m_strShowTitle; break; case VIDEODB_CONTENT_MUSICVIDEOS: if (!item->GetVideoInfoTag()->m_strAlbum.empty()) object["item"]["album"] = item->GetVideoInfoTag()->m_strAlbum; if (!item->GetVideoInfoTag()->m_artist.empty()) object["item"]["artist"] = StringUtils::Join(item->GetVideoInfoTag()->m_artist, " / "); break; } } } else if (item->HasMusicInfoTag()) { id = item->GetMusicInfoTag()->GetDatabaseId(); type = "song"; // TODO: Can be removed once this is properly handled when starting playback of a file if (id <= 0 && !item->GetPath().empty() && (!item->HasProperty(LOOKUP_PROPERTY) || item->GetProperty(LOOKUP_PROPERTY).asBoolean())) { CMusicDatabase musicdatabase; if (musicdatabase.Open()) { CSong song; if (musicdatabase.GetSongByFileName(item->GetPath(), song, item->m_lStartOffset)) { item->GetMusicInfoTag()->SetSong(song); id = item->GetMusicInfoTag()->GetDatabaseId(); } musicdatabase.Close(); } } if (id <= 0) { // TODO: Can be removed once this is properly handled when starting playback of a file item->SetProperty(LOOKUP_PROPERTY, false); CStdString title = item->GetMusicInfoTag()->GetTitle(); if (title.IsEmpty()) title = item->GetLabel(); object["item"]["title"] = title; if (item->GetMusicInfoTag()->GetTrackNumber() > 0) object["item"]["track"] = item->GetMusicInfoTag()->GetTrackNumber(); if (!item->GetMusicInfoTag()->GetAlbum().empty()) object["item"]["album"] = item->GetMusicInfoTag()->GetAlbum(); if (!item->GetMusicInfoTag()->GetArtist().empty()) object["item"]["artist"] = item->GetMusicInfoTag()->GetArtist(); } } else if (item->HasPictureInfoTag()) { type = "picture"; object["item"]["file"] = item->GetPath(); } else type = "unknown"; object["item"]["type"] = type; if (id > 0) object["item"]["id"] = id; Announce(flag, sender, message, object); }
void CSaveFileState::DoWork(CFileItem& item, CBookmark& bookmark, bool updatePlayCount) { std::string progressTrackingFile = item.GetPath(); if (item.HasVideoInfoTag() && StringUtils::StartsWith(item.GetVideoInfoTag()->m_strFileNameAndPath, "removable://")) progressTrackingFile = item.GetVideoInfoTag()->m_strFileNameAndPath; // this variable contains removable:// suffixed by disc label+uniqueid or is empty if label not uniquely identified else if (item.HasProperty("original_listitem_url")) { // only use original_listitem_url for Python, UPnP and Bluray sources std::string original = item.GetProperty("original_listitem_url").asString(); if (URIUtils::IsPlugin(original) || URIUtils::IsUPnP(original) || URIUtils::IsBluray(item.GetPath())) progressTrackingFile = original; } if (!progressTrackingFile.empty()) { #ifdef HAS_UPNP // checks if UPnP server of this file is available and supports updating if (URIUtils::IsUPnP(progressTrackingFile) && UPNP::CUPnP::SaveFileState(item, bookmark, updatePlayCount)) { return; } #endif if (item.IsVideo()) { std::string redactPath = CURL::GetRedacted(progressTrackingFile); CLog::Log(LOGDEBUG, "%s - Saving file state for video item %s", __FUNCTION__, redactPath.c_str()); CVideoDatabase videodatabase; if (!videodatabase.Open()) { CLog::Log(LOGWARNING, "%s - Unable to open video database. Can not save file state!", __FUNCTION__); } else { if (URIUtils::IsPlugin(progressTrackingFile) && !(item.HasVideoInfoTag() && item.GetVideoInfoTag()->m_iDbId >= 0)) { // FileItem from plugin can lack information, make sure all needed fields are set CVideoInfoTag *tag = item.GetVideoInfoTag(); CStreamDetails streams = tag->m_streamDetails; if (videodatabase.LoadVideoInfo(progressTrackingFile, *tag)) { item.SetPath(progressTrackingFile); item.ClearProperty("original_listitem_url"); tag->m_streamDetails = streams; } } bool updateListing = false; // No resume & watched status for livetv if (!item.IsLiveTV()) { if (updatePlayCount) { // no watched for not yet finished pvr recordings if (!item.IsInProgressPVRRecording()) { CLog::Log(LOGDEBUG, "%s - Marking video item %s as watched", __FUNCTION__, redactPath.c_str()); // consider this item as played videodatabase.IncrementPlayCount(item); item.GetVideoInfoTag()->IncrementPlayCount(); item.SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, true); updateListing = true; if (item.HasVideoInfoTag()) { CVariant data; data["id"] = item.GetVideoInfoTag()->m_iDbId; data["type"] = item.GetVideoInfoTag()->m_type; ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", data); } } } else videodatabase.UpdateLastPlayed(item); if (!item.HasVideoInfoTag() || item.GetVideoInfoTag()->GetResumePoint().timeInSeconds != bookmark.timeInSeconds) { if (bookmark.timeInSeconds <= 0.0f) videodatabase.ClearBookMarksOfFile(progressTrackingFile, CBookmark::RESUME); else videodatabase.AddBookMarkToFile(progressTrackingFile, bookmark, CBookmark::RESUME); if (item.HasVideoInfoTag()) item.GetVideoInfoTag()->SetResumePoint(bookmark); // UPnP announce resume point changes to clients // however not if playcount is modified as that already announces if (item.HasVideoInfoTag() && !updatePlayCount) { CVariant data; data["id"] = item.GetVideoInfoTag()->m_iDbId; data["type"] = item.GetVideoInfoTag()->m_type; ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", data); } updateListing = true; } } if (item.HasVideoInfoTag() && item.GetVideoInfoTag()->HasStreamDetails()) { CFileItem dbItem(item); // Check whether the item's db streamdetails need updating if (!videodatabase.GetStreamDetails(dbItem) || dbItem.GetVideoInfoTag()->m_streamDetails != item.GetVideoInfoTag()->m_streamDetails) { videodatabase.SetStreamDetailsForFile(item.GetVideoInfoTag()->m_streamDetails, progressTrackingFile); updateListing = true; } } // Could be part of an ISO stack. In this case the bookmark is saved onto the part. // In order to properly update the list, we need to refresh the stack's resume point CApplicationStackHelper& stackHelper = g_application.GetAppStackHelper(); if (stackHelper.HasRegisteredStack(item) && stackHelper.GetRegisteredStackTotalTimeMs(item) == 0) videodatabase.GetResumePoint(*(stackHelper.GetRegisteredStack(item)->GetVideoInfoTag())); videodatabase.Close(); if (updateListing) { CUtil::DeleteVideoDatabaseDirectoryCache(); CFileItemPtr msgItem(new CFileItem(item)); if (item.HasProperty("original_listitem_url")) msgItem->SetPath(item.GetProperty("original_listitem_url").asString()); CGUIMessage message(GUI_MSG_NOTIFY_ALL, CServiceBroker::GetGUI()->GetWindowManager().GetActiveWindow(), 0, GUI_MSG_UPDATE_ITEM, 0, msgItem); CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(message); } } } if (item.IsAudio()) { std::string redactPath = CURL::GetRedacted(progressTrackingFile); CLog::Log(LOGDEBUG, "%s - Saving file state for audio item %s", __FUNCTION__, redactPath.c_str()); CMusicDatabase musicdatabase; if (updatePlayCount) { if (!musicdatabase.Open()) { CLog::Log(LOGWARNING, "%s - Unable to open music database. Can not save file state!", __FUNCTION__); } else { // consider this item as played CLog::Log(LOGDEBUG, "%s - Marking audio item %s as listened", __FUNCTION__, redactPath.c_str()); musicdatabase.IncrementPlayCount(item); musicdatabase.Close(); // UPnP announce resume point changes to clients // however not if playcount is modified as that already announces if (item.IsMusicDb()) { CVariant data; data["id"] = item.GetMusicInfoTag()->GetDatabaseId(); data["type"] = item.GetMusicInfoTag()->GetType(); ANNOUNCEMENT::CAnnouncementManager::GetInstance().Announce(ANNOUNCEMENT::AudioLibrary, "xbmc", "OnUpdate", data); } } } if (item.IsAudioBook()) { musicdatabase.Open(); musicdatabase.SetResumeBookmarkForAudioBook(item, item.m_lStartOffset + CUtil::ConvertSecsToMilliSecs(bookmark.timeInSeconds)); musicdatabase.Close(); } } } }
//! @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(); }
bool CRecentlyAddedJob::UpdateMusic() { CGUIWindow* home = g_windowManager.GetWindow(WINDOW_HOME); if ( home == NULL ) return false; CLog::Log(LOGDEBUG, "CRecentlyAddedJob::UpdateMusic() - Running RecentlyAdded home screen update"); int i = 0; CFileItemList musicItems; CMusicDatabase musicdatabase; musicdatabase.Open(); if (musicdatabase.GetRecentlyAddedAlbumSongs("musicdb://", musicItems, NUM_ITEMS)) { for (; i < musicItems.Size(); ++i) { CFileItemPtr item = musicItems.Get(i); CStdString value; value.Format("%i", i + 1); CStdString strThumb; CStdString strRating; CStdString strAlbum = item->GetMusicInfoTag()->GetAlbum(); CStdString strArtist = item->GetMusicInfoTag()->GetArtist(); long idAlbum = musicdatabase.GetAlbumByName(strAlbum,strArtist); if (idAlbum != -1) musicdatabase.GetAlbumThumb(idAlbum,strThumb); strRating.Format("%c", item->GetMusicInfoTag()->GetRating()); home->SetProperty("LatestSong." + value + ".Title" , item->GetMusicInfoTag()->GetTitle()); home->SetProperty("LatestSong." + value + ".Year" , item->GetMusicInfoTag()->GetYear()); home->SetProperty("LatestSong." + value + ".Artist" , strArtist); home->SetProperty("LatestSong." + value + ".Album" , strAlbum); home->SetProperty("LatestSong." + value + ".Rating" , strRating); home->SetProperty("LatestSong." + value + ".Path" , item->GetMusicInfoTag()->GetURL()); home->SetProperty("LatestSong." + value + ".Thumb" , strThumb); home->SetProperty("LatestSong." + value + ".Fanart" , item->GetCachedFanart()); } } for (; i < NUM_ITEMS; ++i) { CStdString value; value.Format("%i", i + 1); home->SetProperty("LatestSong." + value + ".Title" , ""); home->SetProperty("LatestSong." + value + ".Year" , ""); home->SetProperty("LatestSong." + value + ".Artist" , ""); home->SetProperty("LatestSong." + value + ".Album" , ""); home->SetProperty("LatestSong." + value + ".Rating" , ""); home->SetProperty("LatestSong." + value + ".Path" , ""); home->SetProperty("LatestSong." + value + ".Thumb" , ""); home->SetProperty("LatestSong." + value + ".Fanart" , ""); } i = 0; VECALBUMS albums; if (musicdatabase.GetRecentlyAddedAlbums(albums, NUM_ITEMS)) { for (; i < (int)albums.size(); ++i) { CStdString value; CStdString strPath; CStdString strThumb; CStdString strDBpath; CStdString strSQLAlbum; CAlbum& album=albums[i]; value.Format("%i", i + 1); musicdatabase.GetAlbumThumb(album.idAlbum,strThumb); strDBpath.Format("musicdb://3/%i/", album.idAlbum); strSQLAlbum.Format("idAlbum=%i", album.idAlbum); CStdString strArtist = musicdatabase.GetSingleValue("albumview", "strArtist", strSQLAlbum); home->SetProperty("LatestAlbum." + value + ".Title" , musicdatabase.GetAlbumById(album.idAlbum)); home->SetProperty("LatestAlbum." + value + ".Year" , atoi(musicdatabase.GetSingleValue("album", "iYear", strSQLAlbum))); home->SetProperty("LatestAlbum." + value + ".Artist" , strArtist); home->SetProperty("LatestAlbum." + value + ".Rating" , musicdatabase.GetSingleValue("albumview", "iRating", strSQLAlbum)); home->SetProperty("LatestAlbum." + value + ".Path" , strDBpath); home->SetProperty("LatestAlbum." + value + ".Thumb" , strThumb); home->SetProperty("LatestAlbum." + value + ".Fanart" , CFileItem::GetCachedThumb(strArtist,g_settings.GetMusicFanartFolder())); } } for (; i < NUM_ITEMS; ++i) { CStdString value; value.Format("%i", i + 1); home->SetProperty("LatestAlbum." + value + ".Title" , ""); home->SetProperty("LatestAlbum." + value + ".Year" , ""); home->SetProperty("LatestAlbum." + value + ".Artist" , ""); home->SetProperty("LatestAlbum." + value + ".Rating" , ""); home->SetProperty("LatestAlbum." + value + ".Path" , ""); home->SetProperty("LatestAlbum." + value + ".Thumb" , ""); home->SetProperty("LatestAlbum." + value + ".Fanart" , ""); } musicdatabase.Close(); return true; }
bool CGUIDialogMusicInfo::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_DEINIT: { if (m_startUserrating != m_albumItem->GetMusicInfoTag()->GetUserrating()) { CMusicDatabase db; if (db.Open()) { m_needsUpdate = true; db.SetAlbumUserrating(m_albumItem->GetMusicInfoTag()->GetAlbumId(), m_albumItem->GetMusicInfoTag()->GetUserrating()); db.Close(); } } CGUIMessage msg(GUI_MSG_LABEL_RESET, GetID(), CONTROL_LIST); OnMessage(msg); m_albumSongs->Clear(); } break; case GUI_MSG_WINDOW_INIT: { CGUIDialog::OnMessage(message); m_bViewReview = true; m_bRefresh = false; Update(); return true; } break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_USERRATING) { OnSetUserrating(); } else if (iControl == CONTROL_BTN_REFRESH) { m_bRefresh = true; Close(); return true; } else if (iControl == CONTROL_BTN_GET_THUMB) { OnGetThumb(); } else if (iControl == CONTROL_LIST) { int iAction = message.GetParam1(); if (m_bArtistInfo && (ACTION_SELECT_ITEM == iAction || ACTION_MOUSE_LEFT_CLICK == iAction)) { CGUIMessage msg(GUI_MSG_ITEM_SELECTED, GetID(), iControl); g_windowManager.SendMessage(msg); int iItem = msg.GetParam1(); if (iItem < 0 || iItem >= static_cast<int>(m_albumSongs->Size())) break; CFileItemPtr item = m_albumSongs->Get(iItem); OnSearch(item.get()); return true; } } else if (iControl == CONTROL_BTN_GET_FANART) { OnGetFanart(); } } break; } return CGUIDialog::OnMessage(message); }
void CGUIDialogSmartPlaylistRule::OnBrowse() { CFileItemList items; CMusicDatabase database; database.Open(); CVideoDatabase videodatabase; videodatabase.Open(); VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_type.Equals("tvshows")) type = VIDEODB_CONTENT_TVSHOWS; else if (m_type.Equals("musicvideos")) type = VIDEODB_CONTENT_MUSICVIDEOS; else if (m_type.Equals("episodes")) type = VIDEODB_CONTENT_EPISODES; int iLabel = 0; if (m_rule.m_field == CSmartPlaylistRule::FIELD_GENRE) { if (m_type.Equals("tvshows") || m_type.Equals("episodes") || m_type.Equals("movies")) videodatabase.GetGenresNav("videodb://2/1/",items,type); else if (m_type.Equals("songs") || m_type.Equals("albums") || m_type.Equals("mixed")) database.GetGenresNav("musicdb://4/",items); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetGenresNav("videodb://3/1/",items2,VIDEODB_CONTENT_MUSICVIDEOS); items.Append(items2); } iLabel = 515; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_COUNTRY) { videodatabase.GetCountriesNav("videodb://2/1/",items,type); iLabel = 574; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ARTIST || m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUMARTIST) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums")) database.GetArtistsNav("musicdb://5/",items,-1,m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUMARTIST); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetMusicVideoArtistsByName("",items2); items.Append(items2); } iLabel = 557; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ALBUM) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums")) database.GetAlbumsNav("musicdb://6/",items,-1,-1,-1,-1); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetMusicVideoAlbumsByName("",items2); items.Append(items2); } iLabel = 558; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_ACTOR) { videodatabase.GetActorsNav("",items,type); iLabel = 20337; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_DIRECTOR) { videodatabase.GetDirectorsNav("",items,type); iLabel = 20339; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_STUDIO) { videodatabase.GetStudiosNav("",items,type); iLabel = 572; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_WRITER) { videodatabase.GetWritersNav("",items,type); iLabel = 20417; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_TVSHOWTITLE) { videodatabase.GetTvShowsNav("",items); iLabel = 20343; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_PLAYLIST) { // use filebrowser to grab another smart playlist // Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't // think there's any decent way to deal with this, as the infinite loop may be an arbitrary // number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1 CStdString path = "special://videoplaylists/"; if (m_type.Equals("songs") || m_type.Equals("albums")) path = "special://musicplaylists/"; XFILE::CDirectory::GetDirectory(path, items, ".xsp",false,false,XFILE::DIR_CACHE_ONCE,true,true); iLabel = 559; } else if (m_rule.m_field == CSmartPlaylistRule::FIELD_PATH) { VECSOURCES sources; if (m_type == "songs" || m_type == "mixed") sources = *g_settings.GetSourcesFromType("music"); if (m_type != "songs") { VECSOURCES sources2 = *g_settings.GetSourcesFromType("video"); sources.insert(sources.end(),sources2.begin(),sources2.end()); } g_mediaManager.GetLocalDrives(sources); CGUIDialogFileBrowser::ShowAndGetDirectory(sources,g_localizeStrings.Get(657),m_rule.m_parameter,false); UpdateButtons(); return; } else { // TODO: Add browseability in here. assert(false); } // sort the items items.Sort(SORT_METHOD_LABEL, SORT_ORDER_ASC); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&items); CStdString strHeading; strHeading.Format(g_localizeStrings.Get(13401),g_localizeStrings.Get(iLabel)); pDialog->SetHeading(strHeading); pDialog->DoModal(); if (pDialog->GetSelectedLabel() > -1) { m_rule.m_parameter = pDialog->GetSelectedLabelText(); UpdateButtons(); } pDialog->Reset(); }
bool CRecentlyAddedJob::UpdateMusic() { CGUIWindow* home = g_windowManager.GetWindow(WINDOW_HOME); if ( home == NULL ) return false; CLog::Log(LOGDEBUG, "CRecentlyAddedJob::UpdateMusic() - Running RecentlyAdded home screen update"); int i = 0; CFileItemList musicItems; CMusicDatabase musicdatabase; CMusicThumbLoader loader; loader.OnLoaderStart(); musicdatabase.Open(); if (musicdatabase.GetRecentlyAddedAlbumSongs(g_advancedSettings.m_recentlyAddedMusicPath, musicItems, NUM_ITEMS)) { long idAlbum = -1; std::string strAlbumThumb; std::string strAlbumFanart; for (; i < musicItems.Size(); ++i) { CFileItemPtr item = musicItems.Get(i); std::string value = StringUtils::Format("%i", i + 1); std::string strRating; std::string strAlbum = item->GetMusicInfoTag()->GetAlbum(); std::string strArtist = item->GetMusicInfoTag()->GetArtistString(); if (idAlbum != item->GetMusicInfoTag()->GetAlbumId()) { strAlbumThumb.clear(); strAlbumFanart.clear(); idAlbum = item->GetMusicInfoTag()->GetAlbumId(); if (loader.LoadItem(item.get())) { strAlbumThumb = item->GetArt("thumb"); strAlbumFanart = item->GetArt("fanart"); } } strRating = StringUtils::Format("%c", item->GetMusicInfoTag()->GetUserrating()); home->SetProperty("LatestSong." + value + ".Title" , item->GetMusicInfoTag()->GetTitle()); home->SetProperty("LatestSong." + value + ".Year" , item->GetMusicInfoTag()->GetYear()); home->SetProperty("LatestSong." + value + ".Artist" , strArtist); home->SetProperty("LatestSong." + value + ".Album" , strAlbum); home->SetProperty("LatestSong." + value + ".Rating" , strRating); home->SetProperty("LatestSong." + value + ".Path" , item->GetMusicInfoTag()->GetURL()); home->SetProperty("LatestSong." + value + ".Thumb" , strAlbumThumb); home->SetProperty("LatestSong." + value + ".Fanart" , strAlbumFanart); } } for (; i < NUM_ITEMS; ++i) { std::string value = StringUtils::Format("%i", i + 1); home->SetProperty("LatestSong." + value + ".Title" , ""); home->SetProperty("LatestSong." + value + ".Year" , ""); home->SetProperty("LatestSong." + value + ".Artist" , ""); home->SetProperty("LatestSong." + value + ".Album" , ""); home->SetProperty("LatestSong." + value + ".Rating" , ""); home->SetProperty("LatestSong." + value + ".Path" , ""); home->SetProperty("LatestSong." + value + ".Thumb" , ""); home->SetProperty("LatestSong." + value + ".Fanart" , ""); } i = 0; VECALBUMS albums; if (musicdatabase.GetRecentlyAddedAlbums(albums, NUM_ITEMS)) { for (; i < (int)albums.size(); ++i) { CAlbum& album=albums[i]; std::string value = StringUtils::Format("%i", i + 1); std::string strThumb = musicdatabase.GetArtForItem(album.idAlbum, MediaTypeAlbum, "thumb"); std::string strFanart = musicdatabase.GetArtistArtForItem(album.idAlbum, MediaTypeAlbum, "fanart"); std::string strDBpath = StringUtils::Format("musicdb://albums/%li/", album.idAlbum); home->SetProperty("LatestAlbum." + value + ".Title" , album.strAlbum); home->SetProperty("LatestAlbum." + value + ".Year" , album.iYear); home->SetProperty("LatestAlbum." + value + ".Artist" , album.GetAlbumArtistString()); home->SetProperty("LatestAlbum." + value + ".Rating" , album.iRating); home->SetProperty("LatestAlbum." + value + ".Path" , strDBpath); home->SetProperty("LatestAlbum." + value + ".Thumb" , strThumb); home->SetProperty("LatestAlbum." + value + ".Fanart" , strFanart); } } for (; i < NUM_ITEMS; ++i) { std::string value = StringUtils::Format("%i", i + 1); home->SetProperty("LatestAlbum." + value + ".Title" , ""); home->SetProperty("LatestAlbum." + value + ".Year" , ""); home->SetProperty("LatestAlbum." + value + ".Artist" , ""); home->SetProperty("LatestAlbum." + value + ".Rating" , ""); home->SetProperty("LatestAlbum." + value + ".Path" , ""); home->SetProperty("LatestAlbum." + value + ".Thumb" , ""); home->SetProperty("LatestAlbum." + value + ".Fanart" , ""); } musicdatabase.Close(); return true; }
bool CPartyModeManager::AddRandomSongs(int iSongs /* = 0 */) { int iPlaylist = PLAYLIST_MUSIC; if (m_bIsVideo) iPlaylist = PLAYLIST_VIDEO; CPlayList& playlist = g_playlistPlayer.GetPlaylist(iPlaylist); int iMissingSongs = QUEUE_DEPTH - playlist.size(); if (iSongs <= 0) iSongs = iMissingSongs; // distribute between types if mixed int iSongsToAdd=iSongs; int iVidsToAdd=iSongs; if (m_type.Equals("mixed")) { if (iSongs == 1) { if (rand() % 10 < 7) // 70 % chance of grabbing a song iVidsToAdd = 0; else iSongsToAdd = 0; } if (iSongs > 1) // grab 70 % songs, 30 % mvids { iSongsToAdd = (int).7f*iSongs; iVidsToAdd = (int).3f*iSongs; while (iSongsToAdd+iVidsToAdd < iSongs) // correct any rounding by adding songs iSongsToAdd++; } } // add songs to fill queue if (m_type.Equals("songs") || m_type.Equals("mixed")) { CMusicDatabase database; if (database.Open()) { // Method: // 1. Grab a random entry from the database using a where clause // 2. Iterate on iSongs. // Note: At present, this method is faster than the alternative, which is to grab // all valid songids, then select a random number of them (as done in AddInitialSongs()). // The reason for this is simply the number of songs we are requesting - we generally // only want one here. Any more than about 3 songs and it is more efficient // to use the technique in AddInitialSongs. As it's unlikely that we'll require // more than 1 song at a time here, this method is faster. bool error(false); for (int i = 0; i < iSongsToAdd; i++) { pair<CStdString,CStdString> whereClause = GetWhereClauseWithHistory(); CFileItemPtr item(new CFileItem); int songID; if (database.GetRandomSong(item.get(), songID, whereClause.first)) { // success Add(item); AddToHistory(1,songID); } else { error = true; break; } } if (error) { database.Close(); OnError(16034, (CStdString)"Cannot get songs from database. Aborting."); return false; } } else { OnError(16033, (CStdString)"Party mode could not open database. Aborting."); return false; } database.Close(); } if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CVideoDatabase database; if (database.Open()) { // Method: // 1. Grab a random entry from the database using a where clause // 2. Iterate on iSongs. // Note: At present, this method is faster than the alternative, which is to grab // all valid songids, then select a random number of them (as done in AddInitialSongs()). // The reason for this is simply the number of songs we are requesting - we generally // only want one here. Any more than about 3 songs and it is more efficient // to use the technique in AddInitialSongs. As it's unlikely that we'll require // more than 1 song at a time here, this method is faster. bool error(false); for (int i = 0; i < iVidsToAdd; i++) { pair<CStdString,CStdString> whereClause = GetWhereClauseWithHistory(); CFileItemPtr item(new CFileItem); int songID; if (database.GetRandomMusicVideo(item.get(), songID, whereClause.second)) { // success Add(item); AddToHistory(2,songID); } else { error = true; break; } } if (error) { database.Close(); OnError(16034, (CStdString)"Cannot get songs from database. Aborting."); return false; } } else { OnError(16033, (CStdString)"Party mode could not open database. Aborting."); return false; } database.Close(); } 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); 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); } } }
bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUSIC*/, const CStdString& strXspPath /*= ""*/) { // Filter using our PartyMode xml file CSmartPlaylist playlist; CStdString partyModePath; bool playlistLoaded; m_bIsVideo = context == PARTYMODECONTEXT_VIDEO; if (!strXspPath.IsEmpty()) //if a path to a smartplaylist is supplied use it partyModePath = strXspPath; else if (m_bIsVideo) partyModePath = g_settings.GetUserDataItem("PartyMode-Video.xsp"); else partyModePath = g_settings.GetUserDataItem("PartyMode.xsp"); playlistLoaded=playlist.Load(partyModePath); if ( playlistLoaded ) { m_type = playlist.GetType(); if (context == PARTYMODECONTEXT_UNKNOWN) { //get it from the xsp file m_bIsVideo = (m_type.Equals("video") || m_type.Equals("musicvideos") || m_type.Equals("mixed")); } if (m_type.Equals("mixed")) playlist.SetType("songs"); if (m_type.Equals("mixed")) playlist.SetType("video"); playlist.SetType(m_type); } else { m_strCurrentFilterMusic.Empty(); m_strCurrentFilterVideo.Empty(); m_type = m_bIsVideo ? "musicvideos" : "songs"; } CGUIDialogProgress* pDialog = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS); int iHeading = (m_bIsVideo ? 20250 : 20121); int iLine0 = (m_bIsVideo ? 20251 : 20123); pDialog->SetHeading(iHeading); pDialog->SetLine(0, iLine0); pDialog->SetLine(1, ""); pDialog->SetLine(2, ""); pDialog->StartModal(); ClearState(); unsigned int time = XbmcThreads::SystemClockMillis(); vector< pair<int,int> > songIDs; if (m_type.Equals("songs") || m_type.Equals("mixed")) { CMusicDatabase db; if (db.Open()) { set<CStdString> playlists; if ( playlistLoaded ) m_strCurrentFilterMusic = playlist.GetWhereClause(db, playlists); CLog::Log(LOGINFO, "PARTY MODE MANAGER: Registering filter:[%s]", m_strCurrentFilterMusic.c_str()); m_iMatchingSongs = (int)db.GetSongIDs(m_strCurrentFilterMusic, songIDs); if (m_iMatchingSongs < 1 && m_type.Equals("songs")) { pDialog->Close(); db.Close(); OnError(16031, (CStdString)"Party mode found no matching songs. Aborting."); return false; } } else { pDialog->Close(); OnError(16033, (CStdString)"Party mode could not open database. Aborting."); return false; } db.Close(); } if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { vector< pair<int,int> > songIDs2; CVideoDatabase db; if (db.Open()) { set<CStdString> playlists; if ( playlistLoaded ) m_strCurrentFilterVideo = playlist.GetWhereClause(db, playlists); CLog::Log(LOGINFO, "PARTY MODE MANAGER: Registering filter:[%s]", m_strCurrentFilterVideo.c_str()); m_iMatchingSongs += (int)db.GetMusicVideoIDs(m_strCurrentFilterVideo, songIDs2); if (m_iMatchingSongs < 1) { pDialog->Close(); db.Close(); OnError(16031, (CStdString)"Party mode found no matching songs. Aborting."); return false; } } else { pDialog->Close(); OnError(16033, (CStdString)"Party mode could not open database. Aborting."); return false; } db.Close(); songIDs.insert(songIDs.end(),songIDs2.begin(),songIDs2.end()); } // calculate history size if (m_iMatchingSongs < 50) m_songsInHistory = 0; else m_songsInHistory = (int)(m_iMatchingSongs/2); if (m_songsInHistory > 200) m_songsInHistory = 200; CLog::Log(LOGINFO,"PARTY MODE MANAGER: Matching songs = %i, History size = %i", m_iMatchingSongs, m_songsInHistory); CLog::Log(LOGINFO,"PARTY MODE MANAGER: Party mode enabled!"); int iPlaylist = m_bIsVideo ? PLAYLIST_VIDEO : PLAYLIST_MUSIC; g_playlistPlayer.ClearPlaylist(iPlaylist); g_playlistPlayer.SetShuffle(iPlaylist, false); g_playlistPlayer.SetRepeat(iPlaylist, PLAYLIST::REPEAT_NONE); pDialog->SetLine(0, (m_bIsVideo ? 20252 : 20124)); pDialog->Progress(); // add initial songs if (!AddInitialSongs(songIDs)) { pDialog->Close(); return false; } CLog::Log(LOGDEBUG, "%s time for song fetch: %u", __FUNCTION__, XbmcThreads::SystemClockMillis() - time); // start playing g_playlistPlayer.SetCurrentPlaylist(iPlaylist); Play(0); pDialog->Close(); // open now playing window if (m_type.Equals("songs")) { if (g_windowManager.GetActiveWindow() != WINDOW_MUSIC_PLAYLIST) g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST); } // done m_bEnabled = true; Announce(); return true; }
void CGUIDialogSmartPlaylistRule::OnBrowse() { CFileItemList items; CMusicDatabase database; database.Open(); CVideoDatabase videodatabase; videodatabase.Open(); VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_type.Equals("tvshows")) type = VIDEODB_CONTENT_TVSHOWS; else if (m_type.Equals("musicvideos")) type = VIDEODB_CONTENT_MUSICVIDEOS; else if (m_type.Equals("episodes")) type = VIDEODB_CONTENT_EPISODES; int iLabel = 0; if (m_rule.m_field == FieldGenre) { if (m_type.Equals("tvshows") || m_type.Equals("episodes") || m_type.Equals("movies")) videodatabase.GetGenresNav("videodb://2/1/",items,type); else if (m_type.Equals("songs") || m_type.Equals("albums") || m_type.Equals("artists") || m_type.Equals("mixed")) database.GetGenresNav("musicdb://1/",items); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetGenresNav("videodb://3/1/",items2,VIDEODB_CONTENT_MUSICVIDEOS); items.Append(items2); } iLabel = 515; } else if (m_rule.m_field == FieldCountry) { videodatabase.GetCountriesNav("videodb://2/1/",items,type); iLabel = 574; } else if (m_rule.m_field == FieldArtist || m_rule.m_field == FieldAlbumArtist) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums") || m_type.Equals("artists")) database.GetArtistsNav("musicdb://2/", items, m_rule.m_field == FieldAlbumArtist, -1); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetMusicVideoArtistsByName("",items2); items.Append(items2); } iLabel = 557; } else if (m_rule.m_field == FieldAlbum) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums")) database.GetAlbumsNav("musicdb://3/", items); if (m_type.Equals("musicvideos") || m_type.Equals("mixed")) { CFileItemList items2; videodatabase.GetMusicVideoAlbumsByName("",items2); items.Append(items2); } iLabel = 558; } else if (m_rule.m_field == FieldActor) { videodatabase.GetActorsNav("",items,type); iLabel = 20337; } else if (m_rule.m_field == FieldYear) { if (m_type.Equals("songs") || m_type.Equals("mixed") || m_type.Equals("albums")) database.GetYearsNav("musicdb://9/", items); if (!m_type.Equals("songs") && !m_type.Equals("albums")) { CFileItemList items2; videodatabase.GetYearsNav("", items2, type); items.Append(items2); } iLabel = 562; } else if (m_rule.m_field == FieldDirector) { videodatabase.GetDirectorsNav("",items,type); iLabel = 20339; } else if (m_rule.m_field == FieldStudio) { videodatabase.GetStudiosNav("",items,type); iLabel = 572; } else if (m_rule.m_field == FieldWriter) { videodatabase.GetWritersNav("",items,type); iLabel = 20417; } else if (m_rule.m_field == FieldTvShowTitle) { videodatabase.GetTvShowsNav("videodb://2/2/",items); iLabel = 20343; } else if (m_rule.m_field == FieldPlaylist) { // use filebrowser to grab another smart playlist // Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't // think there's any decent way to deal with this, as the infinite loop may be an arbitrary // number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1 CStdString path = "special://videoplaylists/"; if (m_type.Equals("songs") || m_type.Equals("albums")) path = "special://musicplaylists/"; XFILE::CDirectory::GetDirectory(path, items, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS); for (int i = 0; i < items.Size(); i++) { CFileItemPtr item = items[i]; CSmartPlaylist playlist; if (playlist.OpenAndReadName(item->GetPath())) item->SetLabel(playlist.GetName()); } iLabel = 559; } else if (m_rule.m_field == FieldPath) { VECSOURCES sources; if (m_type == "songs" || m_type == "mixed") sources = *g_settings.GetSourcesFromType("music"); if (m_type != "songs") { VECSOURCES sources2 = *g_settings.GetSourcesFromType("video"); sources.insert(sources.end(),sources2.begin(),sources2.end()); } g_mediaManager.GetLocalDrives(sources); CStdString path = m_rule.GetLocalizedParameter(m_type); CGUIDialogFileBrowser::ShowAndGetDirectory(sources, g_localizeStrings.Get(657), path, false); if (m_rule.m_parameter.size() > 0) m_rule.m_parameter.clear(); if (!path.empty()) m_rule.m_parameter.push_back(path); UpdateButtons(); return; } else if (m_rule.m_field == FieldSet) { videodatabase.GetSetsNav("videodb://1/7/", items, VIDEODB_CONTENT_MOVIES); iLabel = 20434; } else if (m_rule.m_field == FieldTag) { if (m_type == "movies") videodatabase.GetTagsNav("videodb://1/9/", items, VIDEODB_CONTENT_MOVIES); else return; iLabel = 20459; } else { // TODO: Add browseability in here. assert(false); } // sort the items items.Sort(SORT_METHOD_LABEL, SortOrderAscending); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&items); CStdString strHeading; strHeading.Format(g_localizeStrings.Get(13401),g_localizeStrings.Get(iLabel)); pDialog->SetHeading(strHeading); pDialog->SetMultiSelection(true); if (!m_rule.m_parameter.empty()) pDialog->SetSelected(m_rule.m_parameter); pDialog->DoModal(); if (pDialog->IsConfirmed()) { const CFileItemList &items = pDialog->GetSelectedItems(); m_rule.m_parameter.clear(); for (int index = 0; index < items.Size(); index++) m_rule.m_parameter.push_back(items[index]->GetLabel()); UpdateButtons(); } pDialog->Reset(); }
// 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(); }
bool CMusicDatabaseDirectory::GetLabel(const CStdString& strDirectory, CStdString& strLabel) { strLabel = ""; CStdString path = CLegacyPathTranslation::TranslateMusicDbPath(strDirectory); auto_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(path)); if (!pNode.get()) return false; // first see if there's any filter criteria CQueryParams params; CDirectoryNode::GetDatabaseInfo(path, params); CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return false; // get genre if (params.GetGenreId() >= 0) strLabel += musicdatabase.GetGenreById(params.GetGenreId()); // get artist if (params.GetArtistId() >= 0) { if (!strLabel.empty()) strLabel += " / "; strLabel += musicdatabase.GetArtistById(params.GetArtistId()); } // get album if (params.GetAlbumId() >= 0) { if (!strLabel.empty()) strLabel += " / "; strLabel += musicdatabase.GetAlbumById(params.GetAlbumId()); } if (strLabel.empty()) { switch (pNode->GetChildType()) { case NODE_TYPE_TOP100: strLabel = g_localizeStrings.Get(271); // Top 100 break; case NODE_TYPE_GENRE: strLabel = g_localizeStrings.Get(135); // Genres break; case NODE_TYPE_ARTIST: strLabel = g_localizeStrings.Get(133); // Artists break; case NODE_TYPE_ALBUM: strLabel = g_localizeStrings.Get(132); // Albums break; case NODE_TYPE_ALBUM_RECENTLY_ADDED: case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS: strLabel = g_localizeStrings.Get(359); // Recently Added Albums break; case NODE_TYPE_ALBUM_RECENTLY_PLAYED: case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS: strLabel = g_localizeStrings.Get(517); // Recently Played Albums break; case NODE_TYPE_ALBUM_TOP100: case NODE_TYPE_ALBUM_TOP100_SONGS: strLabel = g_localizeStrings.Get(10505); // Top 100 Albums break; case NODE_TYPE_SINGLES: strLabel = g_localizeStrings.Get(1050); // Singles break; case NODE_TYPE_SONG: strLabel = g_localizeStrings.Get(134); // Songs break; case NODE_TYPE_SONG_TOP100: strLabel = g_localizeStrings.Get(10504); // Top 100 Songs break; case NODE_TYPE_YEAR: case NODE_TYPE_YEAR_ALBUM: case NODE_TYPE_YEAR_SONG: strLabel = g_localizeStrings.Get(652); // Years break; case NODE_TYPE_ALBUM_COMPILATIONS: case NODE_TYPE_ALBUM_COMPILATIONS_SONGS: strLabel = g_localizeStrings.Get(521); break; case NODE_TYPE_OVERVIEW: strLabel = ""; break; default: CLog::Log(LOGWARNING, "%s - Unknown nodetype requested %d", __FUNCTION__, pNode->GetChildType()); return false; } } return true; }
// 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(); }