// 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(); }
bool CGUIDialogSongInfo::OnMessage(CGUIMessage& message) { switch (message.GetMessage()) { case GUI_MSG_WINDOW_DEINIT: { if (!m_cancelled && m_startRating != m_song->GetMusicInfoTag()->GetRating()) { CMusicDatabase db; if (db.Open()) // OpenForWrite() ? { db.SetSongRating(m_song->GetPath(), m_song->GetMusicInfoTag()->GetRating()); db.Close(); } m_needsUpdate = true; } else { // cancelled - reset the song rating SetRating(m_startRating); m_needsUpdate = false; } break; } case GUI_MSG_WINDOW_INIT: m_cancelled = false; break; case GUI_MSG_CLICKED: { int iControl = message.GetSenderId(); if (iControl == CONTROL_CANCEL) { m_cancelled = true; Close(); return true; } else if (iControl == CONTROL_OK) { m_cancelled = false; Close(); return true; } else if (iControl == CONTROL_ALBUMINFO) { CGUIWindowMusicBase *window = (CGUIWindowMusicBase *)g_windowManager.GetWindow(g_windowManager.GetActiveWindow()); if (window) { CFileItem item(*m_song); CStdString path; path.Format("musicdb://3/%li",m_albumId); item.SetPath(path); item.m_bIsFolder = true; window->OnInfo(&item, true); } return true; } else if (iControl == CONTROL_GETTHUMB) { OnGetThumb(); return true; } } break; } return CGUIDialog::OnMessage(message); }
void CAnnouncementManager::Announce(EAnnouncementFlag 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->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(); } } 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["title"] = item->GetVideoInfoTag()->m_strTitle; switch (item->GetVideoContentType()) { case VIDEODB_CONTENT_MOVIES: if (item->GetVideoInfoTag()->m_iYear > 0) object["year"] = item->GetVideoInfoTag()->m_iYear; break; case VIDEODB_CONTENT_EPISODES: if (item->GetVideoInfoTag()->m_iEpisode >= 0) object["episode"] = item->GetVideoInfoTag()->m_iEpisode; if (item->GetVideoInfoTag()->m_iSeason >= 0) object["season"] = item->GetVideoInfoTag()->m_iSeason; if (!item->GetVideoInfoTag()->m_strShowTitle.empty()) object["showtitle"] = item->GetVideoInfoTag()->m_strShowTitle; break; case VIDEODB_CONTENT_MUSICVIDEOS: if (!item->GetVideoInfoTag()->m_strAlbum.empty()) object["album"] = item->GetVideoInfoTag()->m_strAlbum; if (!item->GetVideoInfoTag()->m_strArtist.empty()) object["artist"] = item->GetVideoInfoTag()->m_strArtist; 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->GetMusicInfoTag()->SetSong(song); item->SetMusicThumb(); 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); object["title"] = item->GetMusicInfoTag()->GetTitle(); if (item->GetMusicInfoTag()->GetTrackNumber() > 0) object["track"] = item->GetMusicInfoTag()->GetTrackNumber(); if (!item->GetMusicInfoTag()->GetAlbum().empty()) object["album"] = item->GetMusicInfoTag()->GetAlbum(); if (!item->GetMusicInfoTag()->GetArtist().empty()) object["artist"] = item->GetMusicInfoTag()->GetArtist(); } } else type = "unknown"; object["item"]["type"] = type; if (id > 0) object["item"]["id"] = id; Announce(flag, sender, message, object); }
JSONRPC_STATUS CAudioLibrary::GetAlbums(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return InternalError; CMusicDbUrl musicUrl; if (!musicUrl.FromString("musicdb://albums/")) return InternalError; if (parameterObject["includesingles"].asBoolean()) musicUrl.AddOption("show_singles", true); const CVariant &filter = parameterObject["filter"]; if (filter.isMember("artistid")) musicUrl.AddOption("artistid", (int)filter["artistid"].asInteger()); else if (filter.isMember("artist")) musicUrl.AddOption("artist", filter["artist"].asString()); else if (filter.isMember("genreid")) musicUrl.AddOption("genreid", (int)filter["genreid"].asInteger()); else if (filter.isMember("genre")) musicUrl.AddOption("genre", filter["genre"].asString()); else if (filter.isObject()) { std::string xsp; if (!GetXspFiltering("albums", filter, xsp)) return InvalidParams; musicUrl.AddOption("xsp", xsp); } SortDescription sorting; ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd); if (!ParseSorting(parameterObject, sorting.sortBy, sorting.sortOrder, sorting.sortAttributes)) return InvalidParams; int total; VECALBUMS albums; if (!musicdatabase.GetAlbumsByWhere(musicUrl.ToString(), CDatabase::Filter(), albums, total, sorting)) return InternalError; CFileItemList items; items.Reserve(albums.size()); for (unsigned int index = 0; index < albums.size(); index++) { CMusicDbUrl itemUrl = musicUrl; std::string path = StringUtils::Format("%i/", albums[index].idAlbum); itemUrl.AppendPath(path); CFileItemPtr pItem; FillAlbumItem(albums[index], itemUrl.ToString(), pItem); items.Add(pItem); } //Get Genre IDs JSONRPC_STATUS ret = GetAdditionalAlbumDetails(parameterObject, items, musicdatabase); if (ret != OK) return ret; int size = items.Size(); if (total > size) size = total; HandleFileItemList("albumid", false, "albums", items, parameterObject, result, size, false); return OK; }
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(); }
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 (StringUtils::EqualsNoCase(m_type, "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 (StringUtils::EqualsNoCase(m_type, "songs") || StringUtils::EqualsNoCase(m_type, "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<std::string,std::string> 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, (std::string)"Cannot get songs from database. Aborting."); return false; } } else { OnError(16033, (std::string)"Party mode could not open database. Aborting."); return false; } database.Close(); } if (StringUtils::EqualsNoCase(m_type, "musicvideos") || StringUtils::EqualsNoCase(m_type, "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<std::string,std::string> 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, (std::string)"Cannot get songs from database. Aborting."); return false; } } else { OnError(16033, (std::string)"Party mode could not open database. Aborting."); return false; } database.Close(); } return true; }
bool CVideoThumbLoader::FillLibraryArt(CFileItem &item) { CVideoInfoTag &tag = *item.GetVideoInfoTag(); if (tag.m_iDbId > -1 && !tag.m_type.empty()) { std::map<std::string, std::string> artwork; m_videoDatabase->Open(); if (m_videoDatabase->GetArtForItem(tag.m_iDbId, tag.m_type, artwork)) SetArt(item, artwork); else if (tag.m_type == "actor" && !tag.m_artist.empty()) { // 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); } if (tag.m_type == MediaTypeEpisode || tag.m_type == MediaTypeSeason) { // For episodes and seasons, we want to set fanart for that of the show if (!item.HasArt("tvshow.fanart") && tag.m_iIdShow >= 0) { ArtCache::const_iterator i = m_showArt.find(tag.m_iIdShow); if (i == m_showArt.end()) { std::map<std::string, std::string> showArt; m_videoDatabase->GetArtForItem(tag.m_iIdShow, MediaTypeTvShow, showArt); i = m_showArt.insert(std::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"); } } if (!item.HasArt("season.poster") && tag.m_iSeason > -1) { ArtCache::const_iterator i = m_seasonArt.find(tag.m_iIdSeason); if (i == m_seasonArt.end()) { std::map<std::string, std::string> seasonArt; m_videoDatabase->GetArtForItem(tag.m_iIdSeason, MediaTypeSeason, seasonArt); i = m_seasonArt.insert(std::make_pair(tag.m_iIdSeason, seasonArt)).first; } if (i != m_seasonArt.end()) item.AppendArt(i->second, MediaTypeSeason); } } m_videoDatabase->Close(); } return !item.GetArt().empty(); }
void CMediaSettings::OnSettingAction(const CSetting *setting) { if (setting == NULL) return; const std::string &settingId = setting->GetId(); if (settingId == CSettings::SETTING_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::GetInstance().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 == CSettings::SETTING_KARAOKE_IMPORTCSV) { std::string path(CProfilesManager::GetInstance().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 == CSettings::SETTING_MUSICLIBRARY_CLEANUP) { if (CGUIDialogYesNo::ShowAndGetInput(CVariant{313}, CVariant{333})) g_application.StartMusicCleanup(true); } else if (settingId == CSettings::SETTING_MUSICLIBRARY_EXPORT) CBuiltins::Execute("exportlibrary(music)"); else if (settingId == CSettings::SETTING_MUSICLIBRARY_IMPORT) { std::string path; VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); g_mediaManager.GetNetworkLocations(shares); g_mediaManager.GetRemovableDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetFile(shares, "musicdb.xml", g_localizeStrings.Get(651) , path)) { CMusicDatabase musicdatabase; musicdatabase.Open(); musicdatabase.ImportFromXML(path); musicdatabase.Close(); } } else if (settingId == CSettings::SETTING_VIDEOLIBRARY_CLEANUP) { if (CGUIDialogYesNo::ShowAndGetInput(CVariant{313}, CVariant{333})) g_application.StartVideoCleanup(true); } else if (settingId == CSettings::SETTING_VIDEOLIBRARY_EXPORT) CBuiltins::Execute("exportlibrary(video)"); else if (settingId == CSettings::SETTING_VIDEOLIBRARY_IMPORT) { std::string path; VECSOURCES shares; g_mediaManager.GetLocalDrives(shares); g_mediaManager.GetNetworkLocations(shares); g_mediaManager.GetRemovableDrives(shares); if (CGUIDialogFileBrowser::ShowAndGetDirectory(shares, g_localizeStrings.Get(651) , path)) { CVideoDatabase videodatabase; videodatabase.Open(); videodatabase.ImportFromXML(path); videodatabase.Close(); } } }
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() + " " + playlist.GetOrderClause(); 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() + " " + playlist.GetOrderClause(); success = db.GetEpisodesByWhere("videodb://2/2/", whereOrder, items); items.SetContent("episodes"); db.Close(); } else if (playlist.GetType().Equals("movies")) { CVideoDatabase db; db.Open(); CStdString whereOrder = playlist.GetWhereClause() + " " + playlist.GetOrderClause(); success = db.GetMoviesByWhere("videodb://1/2/", whereOrder, items); items.SetContent("movies"); db.Close(); } else if (playlist.GetType().Equals("albums")) { CMusicDatabase db; db.Open(); success = db.GetAlbumsByWhere("musicdb://3/", playlist.GetWhereClause(), playlist.GetOrderClause(), 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() + " " + playlist.GetOrderClause(); 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() + " " + playlist.GetOrderClause(); 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; }
// 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 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->SetArt("thumb", 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)) localThumb = URIUtils::AddFileToFolder(strArtistPath, "folder.jpg"); } else localThumb = m_albumItem->GetUserMusicThumb(); if (CFile::Exists(localThumb)) { 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); } CStdString result; bool flip=false; VECSOURCES sources(*CMediaSourceSettings::Get().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 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->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++) { CStdString strItemPath; strItemPath.Format("fanart://Remote%i",i); CFileItemPtr item(new CFileItem(strItemPath, false)); CStdString thumb = m_artist.fanart.GetPreviewURL(i); item->SetArt("thumb", 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->SetArt("thumb", 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 = *CMediaSourceSettings::Get().GetSources("music"); 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(); } 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 CGUIDialogMediaFilter::OnBrowse(const Filter &filter, CFileItemList &items, bool countOnly /* = false */) { CFileItemList selectItems; if (m_mediaType == "movies" || m_mediaType == "tvshows" || m_mediaType == "episodes" || m_mediaType == "musicvideos") { CVideoDatabase videodb; if (!videodb.Open()) return; CSmartPlaylist tmpFilter = *m_filter; for (vector<CSmartPlaylistRule>::iterator rule = tmpFilter.m_ruleCombination.m_rules.begin(); rule != tmpFilter.m_ruleCombination.m_rules.end(); rule++) { if (rule->m_field == filter.field) { tmpFilter.m_ruleCombination.m_rules.erase(rule); break; } } std::set<CStdString> playlists; CDatabase::Filter dbfilter; dbfilter.where = tmpFilter.GetWhereClause(videodb, playlists); VIDEODB_CONTENT_TYPE type = VIDEODB_CONTENT_MOVIES; if (m_mediaType == "tvshows") type = VIDEODB_CONTENT_TVSHOWS; else if (m_mediaType == "episodes") type = VIDEODB_CONTENT_EPISODES; else if (m_mediaType == "musicvideos") type = VIDEODB_CONTENT_MUSICVIDEOS; if (filter.field == FieldGenre) videodb.GetGenresNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly); else if (filter.field == FieldActor || filter.field == FieldArtist) videodb.GetActorsNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly); else if (filter.field == FieldDirector) videodb.GetDirectorsNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly); else if (filter.field == FieldStudio) videodb.GetStudiosNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly); else if (filter.field == FieldAlbum) videodb.GetMusicVideoAlbumsNav(m_dbUrl->ToString(), selectItems, -1, dbfilter, countOnly); else if (filter.field == FieldTag) videodb.GetTagsNav(m_dbUrl->ToString(), selectItems, type, dbfilter, countOnly); } else if (m_mediaType == "artists" || m_mediaType == "albums" || m_mediaType == "songs") { CMusicDatabase musicdb; if (!musicdb.Open()) return; CSmartPlaylist tmpFilter = *m_filter; for (vector<CSmartPlaylistRule>::iterator rule = tmpFilter.m_ruleCombination.m_rules.begin(); rule != tmpFilter.m_ruleCombination.m_rules.end(); rule++) { if (rule->m_field == filter.field) { tmpFilter.m_ruleCombination.m_rules.erase(rule); break; } } std::set<CStdString> playlists; CDatabase::Filter dbfilter; dbfilter.where = tmpFilter.GetWhereClause(musicdb, playlists); if (filter.field == FieldGenre) musicdb.GetGenresNav(m_dbUrl->ToString(), selectItems, dbfilter, countOnly); else if (filter.field == FieldArtist) musicdb.GetArtistsNav(m_dbUrl->ToString(), selectItems, m_mediaType == "albums", -1, -1, -1, dbfilter, SortDescription(), countOnly); else if (filter.field == FieldAlbum) musicdb.GetAlbumsNav(m_dbUrl->ToString(), selectItems, -1, -1, dbfilter, SortDescription(), countOnly); else if (filter.field == FieldAlbumType) musicdb.GetAlbumTypesNav(m_dbUrl->ToString(), selectItems, dbfilter, countOnly); else if (filter.field == FieldMusicLabel) musicdb.GetMusicLabelsNav(m_dbUrl->ToString(), selectItems, dbfilter, countOnly); } if (selectItems.Size() <= 0) return; if (countOnly) { items.Copy(selectItems); return; } // sort the items selectItems.Sort(SORT_METHOD_LABEL, SortOrderAscending); CGUIDialogSelect* pDialog = (CGUIDialogSelect*)g_windowManager.GetWindow(WINDOW_DIALOG_SELECT); pDialog->Reset(); pDialog->SetItems(&selectItems); CStdString strHeading; strHeading.Format(g_localizeStrings.Get(13401), g_localizeStrings.Get(filter.label)); pDialog->SetHeading(strHeading); pDialog->SetMultiSelection(true); if (filter.rule != NULL && !filter.rule->m_parameter.empty()) pDialog->SetSelected(filter.rule->m_parameter); pDialog->DoModal(); if (pDialog->IsConfirmed()) items.Copy(pDialog->GetSelectedItems()); else items.Clear(); 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 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(); }
bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items, const std::string &strBaseDir /* = "" */, bool filter /* = false */) { bool success = false, success2 = false; std::vector<std::string> virtualFolders; SortDescription sorting; sorting.limitEnd = playlist.GetLimit(); sorting.sortBy = playlist.GetOrder(); sorting.sortOrder = playlist.GetOrderAscending() ? SortOrderAscending : SortOrderDescending; sorting.sortAttributes = playlist.GetOrderAttributes(); if (CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING)) sorting.sortAttributes = (SortAttribute)(sorting.sortAttributes | SortAttributeIgnoreArticle); items.SetSortIgnoreFolders((sorting.sortAttributes & SortAttributeIgnoreFolders) == SortAttributeIgnoreFolders); std::string option = !filter ? "xsp" : "filter"; std::string group = playlist.GetGroup(); bool isGrouped = !group.empty() && !StringUtils::EqualsNoCase(group, "none") && !playlist.IsGroupMixed(); // get all virtual folders and add them to the item list playlist.GetVirtualFolders(virtualFolders); for (std::vector<std::string>::const_iterator virtualFolder = virtualFolders.begin(); virtualFolder != virtualFolders.end(); ++virtualFolder) { CFileItemPtr pItem = CFileItemPtr(new CFileItem(*virtualFolder, true)); IFileDirectory *dir = CFileDirectoryFactory::Create(pItem->GetURL(), pItem.get()); if (dir != NULL) { pItem->SetSpecialSort(SortSpecialOnTop); items.Add(pItem); delete dir; } } if (playlist.GetType() == "movies" || playlist.GetType() == "tvshows" || playlist.GetType() == "episodes") { CVideoDatabase db; if (db.Open()) { MediaType mediaType = MediaTypes::FromString(playlist.GetType()); std::string baseDir = strBaseDir; if (strBaseDir.empty()) { if (mediaType == MediaTypeTvShow || mediaType == MediaTypeEpisode) baseDir = "videodb://tvshows/"; else if (mediaType == MediaTypeMovie) baseDir = "videodb://movies/"; else return false; if (!isGrouped) baseDir += "titles"; else baseDir += group; URIUtils::AddSlashAtEnd(baseDir); if (mediaType == MediaTypeEpisode) baseDir += "-1/-1/"; } CVideoDbUrl videoUrl; if (!videoUrl.FromString(baseDir)) return false; // store the smartplaylist as JSON in the URL as well std::string xsp; if (!playlist.IsEmpty(filter)) { if (!playlist.SaveAsJson(xsp, !filter)) return false; } if (!xsp.empty()) videoUrl.AddOption(option, xsp); else videoUrl.RemoveOption(option); CDatabase::Filter dbfilter; success = db.GetItems(videoUrl.ToString(), items, dbfilter, sorting); db.Close(); // if we retrieve a list of episodes and we didn't receive // a pre-defined base path, we need to fix it if (strBaseDir.empty() && mediaType == MediaTypeEpisode && !isGrouped) videoUrl.AppendPath("-1/-1/"); items.SetProperty(PROPERTY_PATH_DB, videoUrl.ToString()); } } else if (playlist.IsMusicType() || playlist.GetType().empty()) { CMusicDatabase db; if (db.Open()) { CSmartPlaylist plist(playlist); if (playlist.GetType() == "mixed" || playlist.GetType().empty()) plist.SetType("songs"); MediaType mediaType = MediaTypes::FromString(plist.GetType()); std::string baseDir = strBaseDir; if (strBaseDir.empty()) { baseDir = "musicdb://"; if (!isGrouped) { if (mediaType == MediaTypeArtist) baseDir += "artists"; else if (mediaType == MediaTypeAlbum) baseDir += "albums"; else if (mediaType == MediaTypeSong) baseDir += "songs"; else return false; } else baseDir += group; URIUtils::AddSlashAtEnd(baseDir); } CMusicDbUrl musicUrl; if (!musicUrl.FromString(baseDir)) return false; // store the smartplaylist as JSON in the URL as well std::string xsp; if (!plist.IsEmpty(filter)) { if (!plist.SaveAsJson(xsp, !filter)) return false; } if (!xsp.empty()) musicUrl.AddOption(option, xsp); else musicUrl.RemoveOption(option); CDatabase::Filter dbfilter; success = db.GetItems(musicUrl.ToString(), items, dbfilter, sorting); db.Close(); items.SetProperty(PROPERTY_PATH_DB, musicUrl.ToString()); } } if (playlist.GetType() == "musicvideos" || playlist.GetType() == "mixed") { CVideoDatabase db; if (db.Open()) { CSmartPlaylist mvidPlaylist(playlist); if (playlist.GetType() == "mixed") mvidPlaylist.SetType("musicvideos"); std::string baseDir = strBaseDir; if (baseDir.empty()) { baseDir = "videodb://musicvideos/"; if (!isGrouped) baseDir += "titles"; else baseDir += group; URIUtils::AddSlashAtEnd(baseDir); } CVideoDbUrl videoUrl; if (!videoUrl.FromString(baseDir)) return false; // adjust the group in case we're retrieving a grouped playlist // based on artists. This is needed because the video library // is using the actorslink table for artists. if (isGrouped && group == "artists") { group = "actors"; mvidPlaylist.SetGroup(group); } // store the smartplaylist as JSON in the URL as well std::string xsp; if (!mvidPlaylist.IsEmpty(filter)) { if (!mvidPlaylist.SaveAsJson(xsp, !filter)) return false; } if (!xsp.empty()) videoUrl.AddOption(option, xsp); else videoUrl.RemoveOption(option); CFileItemList items2; CDatabase::Filter dbfilter; success2 = db.GetItems(videoUrl.ToString(), items2, dbfilter, sorting); db.Close(); if (items.Size() <= 0) items.SetPath(videoUrl.ToString()); items.Append(items2); if (items2.Size()) { if (items.Size() > items2.Size()) items.SetContent("mixed"); else items.SetContent("musicvideos"); } items.SetProperty(PROPERTY_PATH_DB, videoUrl.ToString()); } } items.SetLabel(playlist.GetName()); if (isGrouped) items.SetContent(group); else items.SetContent(playlist.GetType()); items.SetProperty(PROPERTY_SORT_ORDER, (int)playlist.GetOrder()); items.SetProperty(PROPERTY_SORT_ASCENDING, playlist.GetOrderDirection() == SortOrderAscending); if (!group.empty()) { items.SetProperty(PROPERTY_GROUP_BY, group); items.SetProperty(PROPERTY_GROUP_MIXED, playlist.IsGroupMixed()); } // sort grouped list by label if (items.Size() > 1 && !group.empty()) items.Sort(SortByLabel, SortOrderAscending, CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_IGNORETHEWHENSORTING) ? SortAttributeIgnoreArticle : SortAttributeNone); // 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() == "mixed") return success || success2; else if (playlist.GetType() == "musicvideos") return success2; else return success; }
bool CSaveFileStateJob::DoWork() { std::string progressTrackingFile = m_item.GetPath(); if (m_item.HasVideoInfoTag() && StringUtils::StartsWith(m_item.GetVideoInfoTag()->m_strFileNameAndPath, "removable://")) progressTrackingFile = m_item.GetVideoInfoTag()->m_strFileNameAndPath; // this variable contains removable:// suffixed by disc label+uniqueid or is empty if label not uniquely identified else if (m_item.HasProperty("original_listitem_url")) { // only use original_listitem_url for Python, UPnP and Bluray sources std::string original = m_item.GetProperty("original_listitem_url").asString(); if (URIUtils::IsPlugin(original) || URIUtils::IsUPnP(original) || URIUtils::IsBluray(m_item.GetPath())) progressTrackingFile = original; } if (progressTrackingFile != "") { #ifdef HAS_UPNP // checks if UPnP server of this file is available and supports updating if (URIUtils::IsUPnP(progressTrackingFile) && UPNP::CUPnP::SaveFileState(m_item, m_bookmark, m_updatePlayCount)) { return true; } #endif if (m_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 { bool updateListing = false; // No resume & watched status for livetv if (!m_item.IsLiveTV()) { if (m_updatePlayCount) { CLog::Log(LOGDEBUG, "%s - Marking video item %s as watched", __FUNCTION__, redactPath.c_str()); // consider this item as played videodatabase.IncrementPlayCount(m_item); m_item.GetVideoInfoTag()->m_playCount++; // PVR: Set recording's play count on the backend (if supported) if (m_item.HasPVRRecordingInfoTag()) m_item.GetPVRRecordingInfoTag()->IncrementPlayCount(); m_item.SetOverlayImage(CGUIListItem::ICON_OVERLAY_UNWATCHED, true); updateListing = true; } else videodatabase.UpdateLastPlayed(m_item); if (!m_item.HasVideoInfoTag() || m_item.GetVideoInfoTag()->m_resumePoint.timeInSeconds != m_bookmark.timeInSeconds) { if (m_bookmark.timeInSeconds <= 0.0f) videodatabase.ClearBookMarksOfFile(progressTrackingFile, CBookmark::RESUME); else videodatabase.AddBookMarkToFile(progressTrackingFile, m_bookmark, CBookmark::RESUME); if (m_item.HasVideoInfoTag()) m_item.GetVideoInfoTag()->m_resumePoint = m_bookmark; // PVR: Set/clear recording's resume bookmark on the backend (if supported) if (m_item.HasPVRRecordingInfoTag()) { PVR::CPVRRecordingPtr recording = m_item.GetPVRRecordingInfoTag(); recording->SetLastPlayedPosition(m_bookmark.timeInSeconds <= 0.0f ? 0 : (int)m_bookmark.timeInSeconds); recording->m_resumePoint = m_bookmark; } // UPnP announce resume point changes to clients // however not if playcount is modified as that already announces if (m_item.IsVideoDb() && !m_updatePlayCount) { CVariant data; data["id"] = m_item.GetVideoInfoTag()->m_iDbId; data["type"] = m_item.GetVideoInfoTag()->m_type; ANNOUNCEMENT::CAnnouncementManager::Get().Announce(ANNOUNCEMENT::VideoLibrary, "xbmc", "OnUpdate", data); } updateListing = true; } } if (m_videoSettings != CMediaSettings::Get().GetDefaultVideoSettings()) { videodatabase.SetVideoSettings(progressTrackingFile, m_videoSettings); } if (m_item.HasVideoInfoTag() && m_item.GetVideoInfoTag()->HasStreamDetails()) { CFileItem dbItem(m_item); // Check whether the item's db streamdetails need updating if (!videodatabase.GetStreamDetails(dbItem) || dbItem.GetVideoInfoTag()->m_streamDetails != m_item.GetVideoInfoTag()->m_streamDetails) { videodatabase.SetStreamDetailsForFile(m_item.GetVideoInfoTag()->m_streamDetails, progressTrackingFile); updateListing = true; } } // in order to properly update the the list, we need to update the stack item which is held in g_application.m_stackFileItemToUpdate if (m_item.HasProperty("stackFileItemToUpdate")) { m_item = m_item_discstack; // as of now, the item is replaced by the discstack item videodatabase.GetResumePoint(*m_item.GetVideoInfoTag()); } videodatabase.Close(); if (updateListing) { CUtil::DeleteVideoDatabaseDirectoryCache(); CFileItemPtr msgItem(new CFileItem(m_item)); if (m_item.HasProperty("original_listitem_url")) msgItem->SetPath(m_item.GetProperty("original_listitem_url").asString()); CGUIMessage message(GUI_MSG_NOTIFY_ALL, g_windowManager.GetActiveWindow(), 0, GUI_MSG_UPDATE_ITEM, 1, msgItem); // 1 to update the listing as well g_windowManager.SendThreadMessage(message); } } } if (m_item.IsAudio()) { std::string redactPath = CURL::GetRedacted(progressTrackingFile); CLog::Log(LOGDEBUG, "%s - Saving file state for audio item %s", __FUNCTION__, redactPath.c_str()); if (m_updatePlayCount) { #if 0 // Can't write to the musicdatabase while scanning for music info CGUIDialogMusicScan *dialog = (CGUIDialogMusicScan *)g_windowManager.GetWindow(WINDOW_DIALOG_MUSIC_SCAN); if (dialog && !dialog->IsDialogRunning()) #endif { CMusicDatabase musicdatabase; 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(m_item); musicdatabase.Close(); } } } } } return true; }
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::Get().GetSources("music"); if (CSmartPlaylist::IsVideoType(m_type)) { VECSOURCES sources2 = *CMediaSourceSettings::Get().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::Get().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()) { 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(); }
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(313, 333, 0, 0)) 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(313, 333, 0, 0)) 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 CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUSIC*/, const std::string& strXspPath /*= ""*/) { // Filter using our PartyMode xml file CSmartPlaylist playlist; std::string partyModePath; bool playlistLoaded; m_bIsVideo = context == PARTYMODECONTEXT_VIDEO; if (!strXspPath.empty()) //if a path to a smartplaylist is supplied use it partyModePath = strXspPath; else if (m_bIsVideo) partyModePath = CProfilesManager::Get().GetUserDataItem("PartyMode-Video.xsp"); else partyModePath = CProfilesManager::Get().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 = (StringUtils::EqualsNoCase(m_type, "video") || StringUtils::EqualsNoCase(m_type, "musicvideos") || StringUtils::EqualsNoCase(m_type, "mixed")); } if (StringUtils::EqualsNoCase(m_type, "mixed")) playlist.SetType("songs"); if (StringUtils::EqualsNoCase(m_type, "mixed")) playlist.SetType("video"); playlist.SetType(m_type); } else { m_strCurrentFilterMusic.clear(); m_strCurrentFilterVideo.clear(); 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(CVariant{iHeading}); pDialog->SetLine(0, CVariant{iLine0}); pDialog->SetLine(1, CVariant{""}); pDialog->SetLine(2, CVariant{""}); pDialog->Open(); ClearState(); unsigned int time = XbmcThreads::SystemClockMillis(); vector< pair<int,int> > songIDs; if (StringUtils::EqualsNoCase(m_type, "songs") || StringUtils::EqualsNoCase(m_type, "mixed")) { CMusicDatabase db; if (db.Open()) { set<std::string> 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 && StringUtils::EqualsNoCase(m_type, "songs")) { pDialog->Close(); db.Close(); OnError(16031, (std::string)"Party mode found no matching songs. Aborting."); return false; } } else { pDialog->Close(); OnError(16033, (std::string)"Party mode could not open database. Aborting."); return false; } db.Close(); } if (StringUtils::EqualsNoCase(m_type, "musicvideos") || StringUtils::EqualsNoCase(m_type, "mixed")) { vector< pair<int,int> > songIDs2; CVideoDatabase db; if (db.Open()) { set<std::string> 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, (std::string)"Party mode found no matching songs. Aborting."); return false; } } else { pDialog->Close(); OnError(16033, (std::string)"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, CVariant{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 (StringUtils::EqualsNoCase(m_type, "songs")) { if (g_windowManager.GetActiveWindow() != WINDOW_MUSIC_PLAYLIST) g_windowManager.ActivateWindow(WINDOW_MUSIC_PLAYLIST); } // done m_bEnabled = true; Announce(); return true; }
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 = StringUtils::Join(item->GetMusicInfoTag()->GetArtist(), g_advancedSettings.m_musicItemSeparator); 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", "strArtists", 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; }
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(); } } } }
void CGUIWindowVideoNav::GetContextButtons(int itemNumber, CContextButtons &buttons) { CFileItemPtr item; if (itemNumber >= 0 && itemNumber < m_vecItems->Size()) item = m_vecItems->Get(itemNumber); CGUIWindowVideoBase::GetContextButtons(itemNumber, buttons); if (item && item->GetProperty("pluginreplacecontextitems").asBoolean()) return; CVideoDatabaseDirectory dir; NODE_TYPE node = dir.GetDirectoryChildType(m_vecItems->GetPath()); if (!item) { // nothing to do here } else if (m_vecItems->IsPath("sources://video/")) { // get the usual shares CGUIDialogContextMenu::GetContextButtons("video", item, buttons); 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 ((CSettings::GetInstance().GetBool(CSettings::SETTING_FILELISTS_ALLOWFILEDELETION) && CUtil::SupportsWriteFileOperations(item->GetPath())) || (inPlaylists && URIUtils::GetFileName(item->GetPath()) != "PartyMode-Video.xsp" && (item->IsPlayList() || item->IsSmartPlayList()))) { buttons.Add(CONTEXT_BUTTON_DELETE, 117); buttons.Add(CONTEXT_BUTTON_RENAME, 118); } // add "Set/Change content" to folders if (item->m_bIsFolder && !item->IsVideoDb() && !item->IsPlayList() && !item->IsSmartPlayList() && !item->IsLibraryFolder() && !item->IsLiveTV() && !item->IsPlugin() && !item->IsAddonsPath() && !URIUtils::IsUPnP(item->GetPath())) { if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20442); else buttons.Add(CONTEXT_BUTTON_SET_CONTENT, 20333); if (info && info->Content() != CONTENT_NONE) buttons.Add(CONTEXT_BUTTON_SCAN, 13349); } } } } }
JSONRPC_STATUS CAudioLibrary::SetSongDetails(const std::string &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result) { int id = (int)parameterObject["songid"].asInteger(); CMusicDatabase musicdatabase; if (!musicdatabase.Open()) return InternalError; CSong song; if (!musicdatabase.GetSong(id, song) || song.idSong != id) return InvalidParams; if (ParameterNotNull(parameterObject, "title")) song.strTitle = parameterObject["title"].asString(); // Artist names, along with MusicbrainzArtistID needs to update artist credits // As temp fix just set the artist description string if (ParameterNotNull(parameterObject, "artist")) { std::vector<std::string> artist; CopyStringArray(parameterObject["artist"], artist); song.strArtistDesc = StringUtils::Join(artist, g_advancedSettings.m_musicItemSeparator); } //Albumartist not part of song, belongs to album so not changed as a song detail?? //if (ParameterNotNull(parameterObject, "albumartist")) // CopyStringArray(parameterObject["albumartist"], song.albumArtist); // song_genre table needs updating too when genre string changes. This needs fixing too. if (ParameterNotNull(parameterObject, "genre")) CopyStringArray(parameterObject["genre"], song.genre); if (ParameterNotNull(parameterObject, "year")) song.iYear = (int)parameterObject["year"].asInteger(); if (ParameterNotNull(parameterObject, "rating")) song.rating = parameterObject["rating"].asFloat(); if (ParameterNotNull(parameterObject, "userrating")) song.userrating = parameterObject["userrating"].asInteger(); //Album title is not part of song, it belongs to album so not changed as a song detail?? if (ParameterNotNull(parameterObject, "album")) song.strAlbum = parameterObject["album"].asString(); if (ParameterNotNull(parameterObject, "track")) song.iTrack = (song.iTrack & 0xffff0000) | ((int)parameterObject["track"].asInteger() & 0xffff); if (ParameterNotNull(parameterObject, "disc")) song.iTrack = (song.iTrack & 0xffff) | ((int)parameterObject["disc"].asInteger() << 16); if (ParameterNotNull(parameterObject, "duration")) song.iDuration = (int)parameterObject["duration"].asInteger(); if (ParameterNotNull(parameterObject, "comment")) song.strComment = parameterObject["comment"].asString(); if (ParameterNotNull(parameterObject, "musicbrainztrackid")) song.strMusicBrainzTrackID = parameterObject["musicbrainztrackid"].asString(); if (ParameterNotNull(parameterObject, "playcount")) song.iTimesPlayed = static_cast<int>(parameterObject["playcount"].asInteger()); if (ParameterNotNull(parameterObject, "lastplayed")) song.lastPlayed.SetFromDBDateTime(parameterObject["lastplayed"].asString()); // This overlay of UpdateSong needs to be deprecated. // Also need to update artist credits and propagate changes // to song_artist and song_genre tables. if (musicdatabase.UpdateSong(id, song) <= 0) return InternalError; CJSONRPCUtils::NotifyItemUpdated(); return ACK; }
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; } default: break; } return CGUIWindowVideoBase::OnContextButton(itemNumber, button); }
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; std::string type; int id = 0; if(item->HasPVRChannelInfoTag()) { const PVR::CPVRChannelPtr 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()) { std::string path = item->GetPath(); std::string videoInfoTagPath(item->GetVideoInfoTag()->m_strFileNameAndPath); if (StringUtils::StartsWith(videoInfoTagPath, "removable://")) path = videoInfoTagPath; if (videodatabase.LoadVideoInfo(path, *item->GetVideoInfoTag(), VideoDbDetailsNone)) 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); std::string title = item->GetVideoInfoTag()->m_strTitle; if (title.empty()) title = item->GetLabel(); object["item"]["title"] = title; 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 = MediaTypeSong; // 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); std::string title = item->GetMusicInfoTag()->GetTitle(); if (title.empty()) 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->IsVideo()) { // video item but has no video info tag. type = "movies"; object["item"]["title"] = item->GetLabel(); } 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); }
bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items, const CStdString &strBaseDir /* = "" */, bool filter /* = false */) { bool success = false, success2 = false; std::set<CStdString> playlists; SortDescription sorting; sorting.limitEnd = playlist.GetLimit(); sorting.sortBy = playlist.GetOrder(); sorting.sortOrder = playlist.GetOrderAscending() ? SortOrderAscending : SortOrderDescending; if (g_guiSettings.GetBool("filelists.ignorethewhensorting")) sorting.sortAttributes = SortAttributeIgnoreArticle; std::string option = !filter ? "xsp" : "filter"; if (playlist.GetType().Equals("movies") || playlist.GetType().Equals("tvshows") || playlist.GetType().Equals("episodes")) { CVideoDatabase db; if (db.Open()) { MediaType mediaType = DatabaseUtils::MediaTypeFromString(playlist.GetType()); CStdString baseDir = strBaseDir; if (strBaseDir.empty()) { switch (mediaType) { case MediaTypeTvShow: case MediaTypeEpisode: baseDir = "videodb://2/2/"; break; case MediaTypeMovie: baseDir = "videodb://1/2/"; break; default: return false; } } CVideoDbUrl videoUrl; if (!videoUrl.FromString(baseDir)) return false; // store the smartplaylist as JSON in the URL as well CStdString xsp; if (!playlist.IsEmpty(filter)) { if (!playlist.SaveAsJson(xsp, !filter)) return false; } videoUrl.AddOption(option, xsp); CDatabase::Filter dbfilter; success = db.GetSortedVideos(mediaType, videoUrl.ToString(), sorting, items, dbfilter, true); db.Close(); // if we retrieve a list of episodes and we didn't receive // a pre-defined base path, we need to fix it if (strBaseDir.empty() && mediaType == MediaTypeEpisode) videoUrl.AppendPath("-1/-1/"); items.SetProperty(PROPERTY_PATH_DB, videoUrl.ToString()); } } else if (playlist.GetType().Equals("albums")) { CMusicDatabase db; if (db.Open()) { CMusicDbUrl musicUrl; if (!musicUrl.FromString(!strBaseDir.empty() ? strBaseDir : "musicdb://3/")) return false; // store the smartplaylist as JSON in the URL as well CStdString xsp; if (!playlist.IsEmpty(filter)) { if (!playlist.SaveAsJson(xsp, !filter)) return false; } musicUrl.AddOption(option, xsp); CDatabase::Filter dbfilter; success = db.GetAlbumsByWhere(musicUrl.ToString(), dbfilter, items, sorting); db.Close(); items.SetContent("albums"); items.SetProperty(PROPERTY_PATH_DB, musicUrl.ToString()); } } else if (playlist.GetType().Equals("artists")) { CMusicDatabase db; if (db.Open()) { CMusicDbUrl musicUrl; if (!musicUrl.FromString("musicdb://2/")) return false; // store the smartplaylist as JSON in the URL as well CStdString xsp; if (!playlist.IsEmpty(filter)) { if (!playlist.SaveAsJson(xsp, !filter)) return false; } musicUrl.AddOption(option, xsp); CDatabase::Filter dbfilter; success = db.GetArtistsNav(musicUrl.ToString(), items, !g_guiSettings.GetBool("musiclibrary.showcompilationartists"), -1, -1, -1, dbfilter, sorting); db.Close(); items.SetContent("artists"); items.SetProperty(PROPERTY_PATH_DB, musicUrl.ToString()); } } if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty()) { CMusicDatabase db; if (db.Open()) { CSmartPlaylist songPlaylist(playlist); if (playlist.GetType().IsEmpty() || playlist.GetType().Equals("mixed")) songPlaylist.SetType("songs"); CMusicDbUrl musicUrl; if (!musicUrl.FromString(!strBaseDir.empty() ? strBaseDir : "musicdb://4/")) return false; // store the smartplaylist as JSON in the URL as well CStdString xsp; if (!songPlaylist.IsEmpty(filter)) { if (!songPlaylist.SaveAsJson(xsp, !filter)) return false; } musicUrl.AddOption(option, xsp); CDatabase::Filter dbfilter; success = db.GetSongsByWhere(musicUrl.ToString(), dbfilter, items, sorting); db.Close(); items.SetContent("songs"); items.SetProperty(PROPERTY_PATH_DB, musicUrl.ToString()); } } if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed")) { CVideoDatabase db; if (db.Open()) { CSmartPlaylist mvidPlaylist(playlist); if (playlist.GetType().Equals("mixed")) mvidPlaylist.SetType("musicvideos"); CVideoDbUrl videoUrl; if (!videoUrl.FromString(!strBaseDir.empty() ? strBaseDir : "videodb://3/2/")) return false; // store the smartplaylist as JSON in the URL as well CStdString xsp; if (!mvidPlaylist.IsEmpty(filter)) { if (!mvidPlaylist.SaveAsJson(xsp, !filter)) return false; } videoUrl.AddOption(option, xsp); CFileItemList items2; success2 = db.GetSortedVideos(MediaTypeMusicVideo, videoUrl.ToString(), sorting, items2); db.Close(); items.Append(items2); if (items2.Size()) { if (items.Size() > items2.Size()) items.SetContent("mixed"); else items.SetContent("musicvideos"); } items.SetProperty(PROPERTY_PATH_DB, videoUrl.ToString()); } } items.SetLabel(playlist.GetName()); // 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; }
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("musicdb://songs/", musicItems, NUM_ITEMS)) { long idAlbum = -1; CStdString strAlbumThumb; CStdString strAlbumFanart; for (; i < musicItems.Size(); ++i) { CFileItemPtr item = musicItems.Get(i); CStdString value = StringUtils::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 = StringUtils::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 = 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]; CStdString value = StringUtils::Format("%i", i + 1); CStdString strThumb = musicdatabase.GetArtForItem(album.idAlbum, MediaTypeAlbum, "thumb"); CStdString strFanart = musicdatabase.GetArtistArtForItem(album.idAlbum, MediaTypeAlbum, "fanart"); CStdString strDBpath = StringUtils::Format("musicdb://albums/%i/", album.idAlbum); CStdString strSQLAlbum = StringUtils::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 = 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 CMusicDatabaseDirectory::GetLabel(const std::string& strDirectory, std::string& strLabel) { strLabel = ""; std::string path = CLegacyPathTranslation::TranslateMusicDbPath(strDirectory); unique_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: return false; } } return true; }
//! @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 CGUIDialogSongInfo::OnGetThumb() { CFileItemList items; // Grab the thumbnail from the web /* std::string thumbFromWeb; thumbFromWeb = URIUtils::AddFileToFolder(g_advancedSettings.m_cachePath, "allmusicThumb.jpg"); if (DownloadThumbnail(thumbFromWeb)) { CFileItemPtr item(new CFileItem("thumb://allmusic.com", false)); item->SetArt("thumb", thumbFromWeb); item->SetLabel(g_localizeStrings.Get(20055)); items.Add(item); }*/ // Current thumb if (CFile::Exists(m_song->GetArt("thumb"))) { CFileItemPtr item(new CFileItem("thumb://Current", false)); item->SetArt("thumb", m_song->GetArt("thumb")); item->SetLabel(g_localizeStrings.Get(20016)); items.Add(item); } // local thumb std::string cachedLocalThumb; std::string localThumb(m_song->GetUserMusicThumb(true)); if (m_song->IsMusicDb()) { CFileItem item(m_song->GetMusicInfoTag()->GetURL(), false); localThumb = item.GetUserMusicThumb(true); } if (CFile::Exists(localThumb)) { CFileItemPtr item(new CFileItem("thumb://Local", false)); item->SetArt("thumb", localThumb); item->SetLabel(g_localizeStrings.Get(20017)); items.Add(item); } else { // no local thumb exists, so we are just using the allmusic.com thumb or cached thumb // which is probably the allmusic.com thumb. These could be wrong, so allow the user // to delete the incorrect thumb CFileItemPtr item(new CFileItem("thumb://None", false)); item->SetArt("thumb", "DefaultAlbumCover.png"); item->SetLabel(g_localizeStrings.Get(20018)); items.Add(item); } std::string result; VECSOURCES sources(*CMediaSourceSettings::GetInstance().GetSources("music")); CGUIDialogMusicInfo::AddItemPathToFileBrowserSources(sources, *m_song); g_mediaManager.GetLocalDrives(sources); if (!CGUIDialogFileBrowser::ShowAndGetImage(items, sources, 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 std::string newThumb; if (result == "thumb://None") newThumb = "-"; else if (result == "thumb://allmusic.com") newThumb.clear(); else if (result == "thumb://Local") newThumb = localThumb; else newThumb = result; // update thumb in the database CMusicDatabase db; if (db.Open()) { db.SetArtForItem(m_song->GetMusicInfoTag()->GetDatabaseId(), m_song->GetMusicInfoTag()->GetType(), "thumb", newThumb); db.Close(); } m_song->SetArt("thumb", newThumb); // 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); // m_hasUpdatedThumb = true; }
bool CMusicDatabaseDirectory::GetLabel(const CStdString& strDirectory, CStdString& strLabel) { strLabel = ""; auto_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(strDirectory)); if (!pNode.get()) return false; // first see if there's any filter criteria CQueryParams params; CDirectoryNode::GetDatabaseInfo(strDirectory, 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.IsEmpty()) strLabel += " / "; strLabel += musicdatabase.GetArtistById(params.GetArtistId()); } // get album if (params.GetAlbumId() >= 0) { if (!strLabel.IsEmpty()) strLabel += " / "; strLabel += musicdatabase.GetAlbumById(params.GetAlbumId()); } if (strLabel.IsEmpty()) { 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; }