本文整理汇总了C++中CMusicDbUrl::FromString方法的典型用法代码示例。如果您正苦于以下问题:C++ CMusicDbUrl::FromString方法的具体用法?C++ CMusicDbUrl::FromString怎么用?C++ CMusicDbUrl::FromString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMusicDbUrl
的用法示例。
在下文中一共展示了CMusicDbUrl::FromString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetArtistDetails
JSONRPC_STATUS CAudioLibrary::GetArtistDetails(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
int artistID = (int)parameterObject["artistid"].asInteger();
CMusicDbUrl musicUrl;
if (!musicUrl.FromString("musicdb://2/"))
return InternalError;
CMusicDatabase musicdatabase;
if (!musicdatabase.Open())
return InternalError;
musicUrl.AddOption("artistid", artistID);
CFileItemList items;
CDatabase::Filter filter;
if (!musicdatabase.GetArtistsByWhere(musicUrl.ToString(), filter, items) || items.Size() != 1)
return InvalidParams;
// Add "artist" to "properties" array by default
CVariant param = parameterObject;
if (!param.isMember("properties"))
param["properties"] = CVariant(CVariant::VariantTypeArray);
param["properties"].append("artist");
HandleFileItem("artistid", false, "artistdetails", items[0], param, param["properties"], result, false);
return OK;
}
示例2: GetDirectory
bool CGUIWindowMusicBase::GetDirectory(const CStdString &strDirectory, CFileItemList &items)
{
CStdString directory = strDirectory;
// check if the path contains a filter and if so load it and
// remove it from the path to get proper GUI view states etc
CSmartPlaylist filterXsp;
CMusicDbUrl musicUrl;
if (musicUrl.FromString(strDirectory))
{
CVariant filter;
if (musicUrl.GetOption("filter", filter))
{
// load the filter and if it's type does not match the
// path's item type reset it
if (filterXsp.LoadFromJson(filter.asString()) && !filterXsp.GetType().Equals(musicUrl.GetType().c_str()))
filterXsp.Reset();
// remove the "filter" option from the path
musicUrl.AddOption("filter", "");
}
directory = musicUrl.ToString();
}
items.SetArt("thumb", "");
bool bResult = CGUIMediaWindow::GetDirectory(directory, items);
if (bResult)
CMusicThumbLoader::FillThumb(items);
// (re-)apply the previously retrieved filter
// because it was reset in CGUIMediaWindow::GetDirectory()
if (!filterXsp.IsEmpty())
m_filter = filterXsp;
// add in the "New Playlist" item if we're in the playlists folder
if ((items.GetPath() == "special://musicplaylists/") && !items.Contains("newplaylist://"))
{
CFileItemPtr newPlaylist(new CFileItem(g_settings.GetUserDataItem("PartyMode.xsp"),false));
newPlaylist->SetLabel(g_localizeStrings.Get(16035));
newPlaylist->SetLabelPreformated(true);
newPlaylist->m_bIsFolder = true;
items.Add(newPlaylist);
newPlaylist.reset(new CFileItem("newplaylist://", false));
newPlaylist->SetLabel(g_localizeStrings.Get(525));
newPlaylist->SetLabelPreformated(true);
newPlaylist->SetSpecialSort(SortSpecialOnBottom);
newPlaylist->SetCanQueue(false);
items.Add(newPlaylist);
newPlaylist.reset(new CFileItem("newsmartplaylist://music", false));
newPlaylist->SetLabel(g_localizeStrings.Get(21437));
newPlaylist->SetLabelPreformated(true);
newPlaylist->SetSpecialSort(SortSpecialOnBottom);
newPlaylist->SetCanQueue(false);
items.Add(newPlaylist);
}
return bResult;
}
示例3: GetAlbums
JSONRPC_STATUS CAudioLibrary::GetAlbums(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CMusicDatabase musicdatabase;
if (!musicdatabase.Open())
return InternalError;
CMusicDbUrl musicUrl;
musicUrl.FromString("musicdb://3/");
int artistID = -1, genreID = -1;
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("artistid"))
artistID = (int)filter["artistid"].asInteger();
if (filter.isMember("artist"))
musicUrl.AddOption("artist", filter["artist"].asString());
if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
SortDescription sorting;
ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd);
if (!ParseSorting(parameterObject, sorting.sortBy, sorting.sortOrder, sorting.sortAttributes))
return InvalidParams;
CFileItemList items;
if (!musicdatabase.GetAlbumsNav(musicUrl.ToString(), items, genreID, artistID, sorting))
return InternalError;
int size = items.Size();
if (items.HasProperty("total") && items.GetProperty("total").asInteger() > size)
size = (int)items.GetProperty("total").asInteger();
HandleFileItemList("albumid", false, "albums", items, parameterObject, result, size, false);
return OK;
}
示例4: GetSongs
JSONRPC_STATUS CAudioLibrary::GetSongs(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://songs/"))
return InternalError;
if (!parameterObject["includesingles"].asBoolean())
musicUrl.AddOption("singles", false);
int genreID = -1, albumID = -1, artistID = -1;
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("artistid"))
artistID = (int)filter["artistid"].asInteger();
else if (filter.isMember("artist"))
musicUrl.AddOption("artist", filter["artist"].asString());
else if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
else if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
else if (filter.isMember("albumid"))
albumID = (int)filter["albumid"].asInteger();
else if (filter.isMember("album"))
musicUrl.AddOption("album", filter["album"].asString());
else if (filter.isObject())
{
std::string xsp;
if (!GetXspFiltering("songs", 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;
CFileItemList items;
if (!musicdatabase.GetSongsNav(musicUrl.ToString(), items, genreID, artistID, albumID, sorting))
return InternalError;
JSONRPC_STATUS ret = GetAdditionalSongDetails(parameterObject, items, musicdatabase);
if (ret != OK)
return ret;
int size = items.Size();
if (items.HasProperty("total") && items.GetProperty("total").asInteger() > size)
size = (int)items.GetProperty("total").asInteger();
HandleFileItemList("songid", true, "songs", items, parameterObject, result, size, false);
return OK;
}
示例5: GetArtists
JSONRPC_STATUS CAudioLibrary::GetArtists(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://artists/"))
return InternalError;
int genreID = -1, albumID = -1, songID = -1;
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
else if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
else if (filter.isMember("albumid"))
albumID = (int)filter["albumid"].asInteger();
else if (filter.isMember("album"))
musicUrl.AddOption("album", filter["album"].asString());
else if (filter.isMember("songid"))
songID = (int)filter["songid"].asInteger();
else if (filter.isObject())
{
std::string xsp;
if (!GetXspFiltering("artists", filter, xsp))
return InvalidParams;
musicUrl.AddOption("xsp", xsp);
}
bool albumArtistsOnly = !CSettings::GetInstance().GetBool(CSettings::SETTING_MUSICLIBRARY_SHOWCOMPILATIONARTISTS);
if (parameterObject["albumartistsonly"].isBoolean())
albumArtistsOnly = parameterObject["albumartistsonly"].asBoolean();
SortDescription sorting;
ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd);
if (!ParseSorting(parameterObject, sorting.sortBy, sorting.sortOrder, sorting.sortAttributes))
return InvalidParams;
CFileItemList items;
if (!musicdatabase.GetArtistsNav(musicUrl.ToString(), items, albumArtistsOnly, genreID, albumID, songID, CDatabase::Filter(), sorting))
return InternalError;
// Add "artist" to "properties" array by default
CVariant param = parameterObject;
if (!param.isMember("properties"))
param["properties"] = CVariant(CVariant::VariantTypeArray);
param["properties"].append("artist");
int size = items.Size();
if (items.HasProperty("total") && items.GetProperty("total").asInteger() > size)
size = (int)items.GetProperty("total").asInteger();
HandleFileItemList("artistid", false, "artists", items, param, result, size, false);
return OK;
}
示例6: GetArtists
JSONRPC_STATUS CAudioLibrary::GetArtists(const CStdString &method, ITransportLayer *transport, IClient *client, const CVariant ¶meterObject, CVariant &result)
{
CMusicDatabase musicdatabase;
if (!musicdatabase.Open())
return InternalError;
CMusicDbUrl musicUrl;
musicUrl.FromString("musicdb://2/");
int genreID = -1, albumID = -1, songID = -1;
const CVariant &filter = parameterObject["filter"];
if (filter.isMember("genreid"))
genreID = (int)filter["genreid"].asInteger();
if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
if (filter.isMember("albumid"))
albumID = (int)filter["albumid"].asInteger();
if (filter.isMember("album"))
musicUrl.AddOption("album", filter["album"].asString());
if (filter.isMember("songid"))
songID = (int)filter["songid"].asInteger();
bool albumArtistsOnly = !g_guiSettings.GetBool("musiclibrary.showcompilationartists");
if (parameterObject["albumartistsonly"].isBoolean())
albumArtistsOnly = parameterObject["albumartistsonly"].asBoolean();
SortDescription sorting;
ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd);
if (!ParseSorting(parameterObject, sorting.sortBy, sorting.sortOrder, sorting.sortAttributes))
return InvalidParams;
CFileItemList items;
if (!musicdatabase.GetArtistsNav(musicUrl.ToString(), items, albumArtistsOnly, genreID, albumID, songID, sorting))
return InternalError;
// Add "artist" to "properties" array by default
CVariant param = parameterObject;
if (!param.isMember("properties"))
param["properties"] = CVariant(CVariant::VariantTypeArray);
param["properties"].append("artist");
HandleFileItemList("artistid", false, "artists", items, param, result, false);
return OK;
}
示例7: AddQueuingFolder
// 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);
}
}
示例8: GetDirectory
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::Get().GetBool("filelists.ignorethewhensorting"))
sorting.sortAttributes = (SortAttribute)(sorting.sortAttributes | SortAttributeIgnoreArticle);
items.SetSortIgnoreFolders((sorting.sortAttributes & SortAttributeIgnoreFolders) == SortAttributeIgnoreFolders);
std::string option = !filter ? "xsp" : "filter";
const 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());
//.........这里部分代码省略.........
示例9: GetArtists
JSONRPC_STATUS CAudioLibrary::GetArtists(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://artists/"))
return InternalError;
bool allroles = false;
if (parameterObject["allroles"].isBoolean())
allroles = parameterObject["allroles"].asBoolean();
const CVariant &filter = parameterObject["filter"];
if (allroles)
musicUrl.AddOption("roleid", -1000); //All roles, any negative parameter overrides implicit roleid=1 filter required for backward compatibility
else if (filter.isMember("roleid"))
musicUrl.AddOption("roleid", static_cast<int>(filter["roleid"].asInteger()));
else if (filter.isMember("role"))
musicUrl.AddOption("role", filter["role"].asString());
// Only one of (song) genreid/genre, albumid/album or songid/song or rules type filter is allowed by filter syntax
if (filter.isMember("genreid")) //Deprecated. Use "songgenre" or "artistgenre"
musicUrl.AddOption("genreid", static_cast<int>(filter["genreid"].asInteger()));
else if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
if (filter.isMember("songgenreid"))
musicUrl.AddOption("genreid", static_cast<int>(filter["songgenreid"].asInteger()));
else if (filter.isMember("songgenre"))
musicUrl.AddOption("genre", filter["songgenre"].asString());
else if (filter.isMember("albumid"))
musicUrl.AddOption("albumid", static_cast<int>(filter["albumid"].asInteger()));
else if (filter.isMember("album"))
musicUrl.AddOption("album", filter["album"].asString());
else if (filter.isMember("songid"))
musicUrl.AddOption("songid", static_cast<int>(filter["songid"].asInteger()));
else if (filter.isObject())
{
std::string xsp;
if (!GetXspFiltering("artists", filter, xsp))
return InvalidParams;
musicUrl.AddOption("xsp", xsp);
}
bool albumArtistsOnly = !CServiceBroker::GetSettings().GetBool(CSettings::SETTING_MUSICLIBRARY_SHOWCOMPILATIONARTISTS);
if (parameterObject["albumartistsonly"].isBoolean())
albumArtistsOnly = parameterObject["albumartistsonly"].asBoolean();
musicUrl.AddOption("albumartistsonly", albumArtistsOnly);
SortDescription sorting;
ParseLimits(parameterObject, sorting.limitStart, sorting.limitEnd);
if (!ParseSorting(parameterObject, sorting.sortBy, sorting.sortOrder, sorting.sortAttributes))
return InvalidParams;
int total;
std::set<std::string> fields;
if (parameterObject.isMember("properties") && parameterObject["properties"].isArray())
{
for (CVariant::const_iterator_array field = parameterObject["properties"].begin_array();
field != parameterObject["properties"].end_array(); field++)
fields.insert(field->asString());
}
musicdatabase.SetTranslateBlankArtist(false);
if (!musicdatabase.GetArtistsByWhereJSON(fields, musicUrl.ToString(), result, total, sorting))
return InternalError;
int start, end;
HandleLimits(parameterObject, result, total, start, end);
return OK;
}
示例10: GetSongs
JSONRPC_STATUS CAudioLibrary::GetSongs(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://songs/"))
return InternalError;
if (parameterObject["singlesonly"].asBoolean())
musicUrl.AddOption("singles", true);
else if (!parameterObject["includesingles"].asBoolean())
musicUrl.AddOption("singles", false);
bool allroles = false;
if (parameterObject["allroles"].isBoolean())
allroles = parameterObject["allroles"].asBoolean();
const CVariant &filter = parameterObject["filter"];
if (allroles)
musicUrl.AddOption("roleid", -1000); //All roles, override implicit roleid=1 filter required for backward compatibility
else if (filter.isMember("roleid"))
musicUrl.AddOption("roleid", static_cast<int>(filter["roleid"].asInteger()));
else if (filter.isMember("role"))
musicUrl.AddOption("role", filter["role"].asString());
// Only one of genreid/genre, artistid/artist, albumid/album or rules type filter is allowed by filter syntax
if (filter.isMember("artistid"))
musicUrl.AddOption("artistid", static_cast<int>(filter["artistid"].asInteger()));
else if (filter.isMember("artist"))
musicUrl.AddOption("artist", filter["artist"].asString());
else if (filter.isMember("genreid"))
musicUrl.AddOption("genreid", static_cast<int>(filter["genreid"].asInteger()));
else if (filter.isMember("genre"))
musicUrl.AddOption("genre", filter["genre"].asString());
else if (filter.isMember("albumid"))
musicUrl.AddOption("albumid", static_cast<int>(filter["albumid"].asInteger()));
else if (filter.isMember("album"))
musicUrl.AddOption("album", filter["album"].asString());
else if (filter.isObject())
{
std::string xsp;
if (!GetXspFiltering("songs", 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;
std::set<std::string> fields;
if (parameterObject.isMember("properties") && parameterObject["properties"].isArray())
{
for (CVariant::const_iterator_array field = parameterObject["properties"].begin_array();
field != parameterObject["properties"].end_array(); field++)
fields.insert(field->asString());
}
if (!musicdatabase.GetSongsByWhereJSON(fields, musicUrl.ToString(), result, total, sorting))
return InternalError;
if (!result.isNull())
{
bool bFetchArt = fields.find("art") != fields.end();
bool bFetchFanart = fields.find("fanart") != fields.end();
bool bFetchThumb = fields.find("thumbnail") != fields.end();
if (bFetchArt || bFetchFanart || bFetchThumb)
{
CThumbLoader* thumbLoader = new CMusicThumbLoader();
thumbLoader->OnLoaderStart();
std::set<std::string> artfields;
if (bFetchArt)
artfields.insert("art");
if (bFetchFanart)
artfields.insert("fanart");
if (bFetchThumb)
artfields.insert("thumbnail");
for (unsigned int index = 0; index < result["songs"].size(); index++)
{
CFileItem item;
// Only needs song and album id (if we have it) set to get art
// Getting art is quicker if "albumid" has been fetched
item.GetMusicInfoTag()->SetDatabaseId(result["songs"][index]["songid"].asInteger(), MediaTypeSong);
if (result["songs"][index].isMember("albumid"))
item.GetMusicInfoTag()->SetAlbumId(result["songs"][index]["albumid"].asInteger());
else
item.GetMusicInfoTag()->SetAlbumId(-1);
// Could use FillDetails, but it does unnecessary serialization of empty MusiInfoTag
// CFileItemPtr itemptr(new CFileItem(item));
// FillDetails(item.GetMusicInfoTag(), itemptr, artfields, result["songs"][index], thumbLoader);
thumbLoader->FillLibraryArt(item);
//.........这里部分代码省略.........
示例11: GetAlbums
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;
}
示例12: GetDirectory
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;
//.........这里部分代码省略.........