// Add an "* All ..." folder to the CFileItemList // depending on the child node void CDirectoryNode::AddQueuingFolder(CFileItemList& items) const { CFileItemPtr pItem; CMusicDbUrl musicUrl; if (!musicUrl.FromString(BuildPath())) return; // always hide "all" items if (g_advancedSettings.m_bMusicLibraryHideAllItems) return; // no need for "all" item when only one item if (items.GetObjectCount() <= 1) return; switch (GetChildType()) { // Have no queuing folder case NODE_TYPE_ROOT: case NODE_TYPE_OVERVIEW: case NODE_TYPE_TOP100: break; /* no need for all genres case NODE_TYPE_GENRE: pItem.reset(new CFileItem(g_localizeStrings.Get(15105))); // "All Genres" musicUrl.AppendPath("-1/"); pItem->SetPath(musicUrl.ToString()); break; */ case NODE_TYPE_ARTIST: if (GetType() == NODE_TYPE_OVERVIEW) return; pItem.reset(new CFileItem(g_localizeStrings.Get(15103))); // "All Artists" musicUrl.AppendPath("-1/"); pItem->SetPath(musicUrl.ToString()); break; // All album related nodes case NODE_TYPE_ALBUM: if (GetType() == NODE_TYPE_OVERVIEW) return; case NODE_TYPE_ALBUM_RECENTLY_PLAYED: case NODE_TYPE_ALBUM_RECENTLY_ADDED: case NODE_TYPE_ALBUM_COMPILATIONS: case NODE_TYPE_ALBUM_TOP100: case NODE_TYPE_YEAR_ALBUM: pItem.reset(new CFileItem(g_localizeStrings.Get(15102))); // "All Albums" musicUrl.AppendPath("-1/"); pItem->SetPath(musicUrl.ToString()); break; // All song related nodes /* case NODE_TYPE_ALBUM_RECENTLY_PLAYED_SONGS: case NODE_TYPE_ALBUM_RECENTLY_ADDED_SONGS: case NODE_TYPE_ALBUM_COMPILATIONS_SONGS: case NODE_TYPE_ALBUM_TOP100_SONGS: case NODE_TYPE_SONG_TOP100: case NODE_TYPE_SONG: pItem = new CFileItem(g_localizeStrings.Get(15104)); // "All Songs" musicUrl.AppendPath("-1/"); pItem->SetPath(musicUrl.ToString()); break;*/ default: break; } if (pItem) { pItem->m_bIsFolder = true; pItem->SetSpecialSort(g_advancedSettings.m_bMusicLibraryAllItemsOnBottom ? SortSpecialOnBottom : SortSpecialOnTop); pItem->SetCanQueue(false); pItem->SetLabelPreformated(true); if (g_advancedSettings.m_bMusicLibraryAllItemsOnBottom) items.Add(pItem); else items.AddFront(pItem, (items.Size() > 0 && items[0]->IsParentFolder()) ? 1 : 0); } }
/// \brief Add unique file and folders and its subfolders to playlist /// \param pItem The file item to add void CGUIWindowMusicBase::AddItemToPlayList(const CFileItemPtr &pItem, CFileItemList &queuedItems) { if (!pItem->CanQueue() || pItem->IsRAR() || pItem->IsZIP() || pItem->IsParentFolder()) // no zip/rar enques thank you! return; // fast lookup is needed here queuedItems.SetFastLookup(true); if (pItem->IsMusicDb() && pItem->m_bIsFolder && !pItem->IsParentFolder()) { // we have a music database folder, just grab the "all" item underneath it CMusicDatabaseDirectory dir; if (!dir.ContainsSongs(pItem->GetPath())) { // grab the ALL item in this category // Genres will still require 2 lookups, and queuing the entire Genre folder // will require 3 lookups (genre, artist, album) CMusicDbUrl musicUrl; musicUrl.FromString(pItem->GetPath()); musicUrl.AppendPath("-1/"); CFileItemPtr item(new CFileItem(musicUrl.ToString(), true)); item->SetCanQueue(true); // workaround for CanQueue() check above AddItemToPlayList(item, queuedItems); return; } } if (pItem->m_bIsFolder || (g_windowManager.GetActiveWindow() == WINDOW_MUSIC_NAV && pItem->IsPlayList())) { // Check if we add a locked share if ( pItem->m_bIsShareOrDrive ) { CFileItem item = *pItem; if ( !g_passwordManager.IsItemUnlocked( &item, "music" ) ) return ; } // recursive CFileItemList items; GetDirectory(pItem->GetPath(), items); //OnRetrieveMusicInfo(items); FormatAndSort(items); for (int i = 0; i < items.Size(); ++i) AddItemToPlayList(items[i], queuedItems); } else { if (pItem->IsPlayList()) { auto_ptr<CPlayList> pPlayList (CPlayListFactory::Create(*pItem)); if (pPlayList.get()) { // load it if (!pPlayList->Load(pItem->GetPath())) { CGUIDialogOK::ShowAndGetInput(6, 0, 477, 0); return; //hmmm unable to load playlist? } CPlayList playlist = *pPlayList; for (int i = 0; i < (int)playlist.size(); ++i) { AddItemToPlayList(playlist[i], queuedItems); } return; } } else if(pItem->IsInternetStream()) { // just queue the internet stream, it will be expanded on play queuedItems.Add(pItem); } else if (pItem->IsPlugin() && pItem->GetProperty("isplayable") == "true") { // python files can be played queuedItems.Add(pItem); } else if (!pItem->IsNFO() && pItem->IsAudio()) { CFileItemPtr itemCheck = queuedItems.Get(pItem->GetPath()); if (!itemCheck || itemCheck->m_lStartOffset != pItem->m_lStartOffset) { // add item CFileItemPtr item(new CFileItem(*pItem)); m_musicdatabase.SetPropertiesForFileItem(*item); queuedItems.Add(item); } } } }
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; }