本文整理汇总了C++中CSmartPlaylist::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ CSmartPlaylist::GetName方法的具体用法?C++ CSmartPlaylist::GetName怎么用?C++ CSmartPlaylist::GetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSmartPlaylist
的用法示例。
在下文中一共展示了CSmartPlaylist::GetName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetPlaylistByName
std::string CSmartPlaylistDirectory::GetPlaylistByName(const std::string& name, const std::string& playlistType)
{
CFileItemList list;
bool filesExist = false;
if (CSmartPlaylist::IsMusicType(playlistType))
filesExist = CDirectory::GetDirectory("special://musicplaylists/", list, ".xsp", false);
else // all others are video
filesExist = CDirectory::GetDirectory("special://videoplaylists/", list, ".xsp", false);
if (filesExist)
{
for (int i = 0; i < list.Size(); i++)
{
CFileItemPtr item = list[i];
CSmartPlaylist playlist;
if (playlist.OpenAndReadName(item->GetURL()))
{
if (StringUtils::EqualsNoCase(playlist.GetName(), name))
return item->GetPath();
}
}
for (int i = 0; i < list.Size(); i++)
{ // check based on filename
CFileItemPtr item = list[i];
if (URIUtils::GetFileName(item->GetPath()) == name)
{ // found :)
return item->GetPath();
}
}
}
return "";
}
示例2: OnBrowse
//.........这里部分代码省略.........
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)
{
示例3: Create
//.........这里部分代码省略.........
URIUtils::CreateArchivePath(strUrl, "zip", strPath, "");
CFileItemList items;
CDirectory::GetDirectory(strUrl, items, strMask);
if (items.Size() == 0) // no files
pItem->m_bIsFolder = true;
else if (items.Size() == 1 && items[0]->m_idepth == 0)
{
// one STORED file - collapse it down
*pItem = *items[0];
}
else
{ // compressed or more than one file -> create a zip dir
pItem->SetPath(strUrl);
return new CZipDirectory;
}
return NULL;
}
if (strExtension.Equals(".rar") || strExtension.Equals(".001"))
{
CStdString strUrl;
URIUtils::CreateArchivePath(strUrl, "rar", strPath, "");
vector<std::string> tokens;
StringUtils::Tokenize(strPath,tokens,".");
if (tokens.size() > 2)
{
if (strExtension.Equals(".001"))
{
if (StringUtils::EqualsNoCase(tokens[tokens.size()-2], "ts")) // .ts.001 - treat as a movie file to scratch some users itch
return NULL;
}
CStdString token = tokens[tokens.size()-2];
if (StringUtils::StartsWithNoCase(token, "part")) // only list '.part01.rar'
{
// need this crap to avoid making mistakes - yeyh for the new rar naming scheme :/
struct __stat64 stat;
int digits = token.size()-4;
CStdString strFormat = StringUtils::Format("part%%0%ii", digits);
CStdString strNumber = StringUtils::Format(strFormat.c_str(), 1);
CStdString strPath2 = strPath;
StringUtils::Replace(strPath2,token,strNumber);
if (atoi(token.substr(4).c_str()) > 1 && CFile::Stat(strPath2,&stat) == 0)
{
pItem->m_bIsFolder = true;
return NULL;
}
}
}
CFileItemList items;
CDirectory::GetDirectory(strUrl, items, strMask);
if (items.Size() == 0) // no files - hide this
pItem->m_bIsFolder = true;
else if (items.Size() == 1 && items[0]->m_idepth == 0x30)
{
// one STORED file - collapse it down
*pItem = *items[0];
}
else
{
#ifdef HAS_FILESYSTEM_RAR
// compressed or more than one file -> create a rar dir
pItem->SetPath(strUrl);
return new CRarDirectory;
#else
return NULL;
#endif
}
return NULL;
}
if (strExtension.Equals(".xsp"))
{ // XBMC Smart playlist - just XML renamed to XSP
// read the name of the playlist in
CSmartPlaylist playlist;
if (playlist.OpenAndReadName(strPath))
{
pItem->SetLabel(playlist.GetName());
pItem->SetLabelPreformated(true);
}
IFileDirectory* pDir=new CSmartPlaylistDirectory;
return pDir; // treat as directory
}
if (CPlayListFactory::IsPlaylist(strPath))
{ // Playlist file
// currently we only return the directory if it contains
// more than one file. Reason is that .pls and .m3u may be used
// for links to http streams etc.
IFileDirectory *pDir = new CPlaylistFileDirectory();
CFileItemList items;
if (pDir->GetDirectory(strPath, items))
{
if (items.Size() > 1)
return pDir;
}
delete pDir;
return NULL;
}
return NULL;
}
示例4: OnBrowse
//.........这里部分代码省略.........
}
else if (m_rule.m_field == FieldPlaylist || m_rule.m_field == FieldVirtualFolder)
{
// use filebrowser to grab another smart playlist
// Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't
// think there's any decent way to deal with this, as the infinite loop may be an arbitrary
// number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1
if (CSmartPlaylist::IsVideoType(m_type))
XFILE::CDirectory::GetDirectory("special://videoplaylists/", items, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS);
if (CSmartPlaylist::IsMusicType(m_type))
{
CFileItemList items2;
XFILE::CDirectory::GetDirectory("special://musicplaylists/", items2, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS);
items.Append(items2);
}
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
CSmartPlaylist playlist;
// don't list unloadable smartplaylists or any referencable smartplaylists
// which do not match the type of the current smartplaylist
if (!playlist.Load(item->GetPath()) ||
(m_rule.m_field == FieldPlaylist &&
(!CSmartPlaylist::CheckTypeCompatibility(m_type, playlist.GetType()) ||
(!playlist.GetGroup().empty() || playlist.IsGroupMixed()))))
{
items.Remove(i);
i -= 1;
continue;
}
if (!playlist.GetName().empty())
item->SetLabel(playlist.GetName());
}
iLabel = 559;
}
else if (m_rule.m_field == FieldPath)
{
VECSOURCES sources;
if (m_type == "songs" || m_type == "mixed")
sources = *CMediaSourceSettings::GetInstance().GetSources("music");
if (CSmartPlaylist::IsVideoType(m_type))
{
VECSOURCES sources2 = *CMediaSourceSettings::GetInstance().GetSources("video");
sources.insert(sources.end(),sources2.begin(),sources2.end());
}
g_mediaManager.GetLocalDrives(sources);
std::string path = m_rule.GetParameter();
CGUIDialogFileBrowser::ShowAndGetDirectory(sources, g_localizeStrings.Get(657), path, false);
if (m_rule.m_parameter.size() > 0)
m_rule.m_parameter.clear();
if (!path.empty())
m_rule.m_parameter.push_back(path);
UpdateButtons();
return;
}
else if (m_rule.m_field == FieldSet)
{
videodatabase.GetSetsNav("videodb://movies/sets/", items, VIDEODB_CONTENT_MOVIES);
iLabel = 20434;
}
else if (m_rule.m_field == FieldTag)
示例5: GetDirectory
//.........这里部分代码省略.........
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;
// 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, SortAttributeIgnoreArticle);
// 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;
}
示例6: Create
//.........这里部分代码省略.........
if (url.IsFileType("rar") || url.IsFileType("001"))
{
std::vector<std::string> tokens;
const std::string strPath = url.Get();
StringUtils::Tokenize(strPath,tokens,".");
if (tokens.size() > 2)
{
if (url.IsFileType("001"))
{
if (StringUtils::EqualsNoCase(tokens[tokens.size()-2], "ts")) // .ts.001 - treat as a movie file to scratch some users itch
return NULL;
}
std::string token = tokens[tokens.size()-2];
if (StringUtils::StartsWith(token, "part")) // only list '.part01.rar'
{
// need this crap to avoid making mistakes - yeyh for the new rar naming scheme :/
struct __stat64 stat;
int digits = token.size()-4;
std::string strFormat = StringUtils::Format("part%%0%ii", digits);
std::string strNumber = StringUtils::Format(strFormat.c_str(), 1);
std::string strPath2 = strPath;
StringUtils::Replace(strPath2,token,strNumber);
if (atoi(token.substr(4).c_str()) > 1 && CFile::Stat(strPath2,&stat) == 0)
{
pItem->m_bIsFolder = true;
return NULL;
}
}
}
CURL rarURL = URIUtils::CreateArchivePath("rar", url);
CFileItemList items;
CDirectory::GetDirectory(rarURL, items, strMask);
if (items.Size() == 0) // no files - hide this
pItem->m_bIsFolder = true;
else if (items.Size() == 1 && items[0]->m_idepth == 0x30 && !items[0]->m_bIsFolder)
{
// one STORED file - collapse it down
*pItem = *items[0];
}
else
{
#ifdef HAS_FILESYSTEM_RAR
// compressed or more than one file -> create a rar dir
pItem->SetURL(rarURL);
return new CRarDirectory;
#else
return NULL;
#endif
}
return NULL;
}
if (url.IsFileType("xbt"))
{
CURL xbtUrl = URIUtils::CreateArchivePath("xbt", url);
pItem->SetURL(xbtUrl);
return new CXbtDirectory();
}
if (url.IsFileType("xsp"))
{ // XBMC Smart playlist - just XML renamed to XSP
// read the name of the playlist in
CSmartPlaylist playlist;
if (playlist.OpenAndReadName(url))
{
pItem->SetLabel(playlist.GetName());
pItem->SetLabelPreformatted(true);
}
IFileDirectory* pDir=new CSmartPlaylistDirectory;
return pDir; // treat as directory
}
if (CPlayListFactory::IsPlaylist(url))
{ // Playlist file
// currently we only return the directory if it contains
// more than one file. Reason is that .pls and .m3u may be used
// for links to http streams etc.
IFileDirectory *pDir = new CPlaylistFileDirectory();
CFileItemList items;
if (pDir->GetDirectory(url, items))
{
if (items.Size() > 1)
return pDir;
}
delete pDir;
return NULL;
}
if (pItem->IsAudioBook())
{
if (!pItem->HasMusicInfoTag() || pItem->m_lEndOffset <= 0)
{
std::unique_ptr<CAudioBookFileDirectory> pDir(new CAudioBookFileDirectory);
if (pDir->ContainsFiles(url))
return pDir.release();
}
return NULL;
}
return NULL;
}
示例7: Create
//.........这里部分代码省略.........
return nullptr;
}
}
}
if (pItem->IsRSS())
return new CRSSDirectory();
if (pItem->IsDiscImage())
return new CUDFDirectory();
#if defined(TARGET_ANDROID)
if (url.IsFileType("apk"))
{
CURL zipURL = URIUtils::CreateArchivePath("apk", url);
CFileItemList items;
CDirectory::GetDirectory(zipURL, items, strMask);
if (items.Size() == 0) // no files
pItem->m_bIsFolder = true;
else if (items.Size() == 1 && items[0]->m_idepth == 0 && !items[0]->m_bIsFolder)
{
// one STORED file - collapse it down
*pItem = *items[0];
}
else
{ // compressed or more than one file -> create a apk dir
pItem->SetURL(zipURL);
return new CAPKDirectory;
}
return NULL;
}
#endif
if (url.IsFileType("zip"))
{
CURL zipURL = URIUtils::CreateArchivePath("zip", url);
CFileItemList items;
CDirectory::GetDirectory(zipURL, items, strMask);
if (items.Size() == 0) // no files
pItem->m_bIsFolder = true;
else if (items.Size() == 1 && items[0]->m_idepth == 0 && !items[0]->m_bIsFolder)
{
// one STORED file - collapse it down
*pItem = *items[0];
}
else
{ // compressed or more than one file -> create a zip dir
pItem->SetURL(zipURL);
return new CZipDirectory;
}
return NULL;
}
if (url.IsFileType("xbt"))
{
CURL xbtUrl = URIUtils::CreateArchivePath("xbt", url);
pItem->SetURL(xbtUrl);
return new CXbtDirectory();
}
if (url.IsFileType("xsp"))
{ // XBMC Smart playlist - just XML renamed to XSP
// read the name of the playlist in
CSmartPlaylist playlist;
if (playlist.OpenAndReadName(url))
{
pItem->SetLabel(playlist.GetName());
pItem->SetLabelPreformatted(true);
}
IFileDirectory* pDir=new CSmartPlaylistDirectory;
return pDir; // treat as directory
}
if (CPlayListFactory::IsPlaylist(url))
{ // Playlist file
// currently we only return the directory if it contains
// more than one file. Reason is that .pls and .m3u may be used
// for links to http streams etc.
IFileDirectory *pDir = new CPlaylistFileDirectory();
CFileItemList items;
if (pDir->GetDirectory(url, items))
{
if (items.Size() > 1)
return pDir;
}
delete pDir;
return NULL;
}
if (pItem->IsAudioBook())
{
if (!pItem->HasMusicInfoTag() || pItem->m_lEndOffset <= 0)
{
std::unique_ptr<CAudioBookFileDirectory> pDir(new CAudioBookFileDirectory);
if (pDir->ContainsFiles(url))
return pDir.release();
}
return NULL;
}
return NULL;
}
示例8: GetDirectory
//.........这里部分代码省略.........
// 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;
}