本文整理汇总了C++中CSmartPlaylist::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ CSmartPlaylist::GetType方法的具体用法?C++ CSmartPlaylist::GetType怎么用?C++ CSmartPlaylist::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CSmartPlaylist
的用法示例。
在下文中一共展示了CSmartPlaylist::GetType方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: validateOption
bool CMusicDbUrl::validateOption(const std::string &key, const CVariant &value)
{
if (!CDbUrl::validateOption(key, value))
return false;
// if the value is empty it will remove the option which is ok
// otherwise we only care about the "filter" option here
if (value.empty() || !StringUtils::EqualsNoCase(key, "filter"))
return true;
if (!value.isString())
return false;
CSmartPlaylist xspFilter;
if (!xspFilter.LoadFromJson(value.asString()))
return false;
// check if the filter playlist matches the item type
return xspFilter.GetType() == m_type;
}
示例3: GetWhereClause
//.........这里部分代码省略.........
query = "idFile " + negate + " in (select idFile from bookmark where type = 1)";
else if (m_field == FIELD_SET)
query = "idMovie" + negate + " in (select idMovie from setlinkmovie join sets on sets.idSet=setlinkmovie.idSet where sets.strSet" + parameter + ")";
}
else if (strType == "musicvideos")
{
if (m_field == FIELD_GENRE)
query = "idMVideo" + negate + " in (select idMVideo from genrelinkmusicvideo join genre on genre.idGenre=genrelinkmusicvideo.idGenre where genre.strGenre" + parameter + ")";
else if (m_field == FIELD_ARTIST)
query = "idMVideo" + negate + " in (select idMVideo from artistlinkmusicvideo join actors on actors.idActor=artistlinkmusicvideo.idArtist where actors.strActor" + parameter + ")";
else if (m_field == FIELD_STUDIO)
query = "idMVideo" + negate + " in (select idMVideo from studiolinkmusicvideo join studio on studio.idStudio=studiolinkmusicvideo.idStudio where studio.strStudio" + parameter + ")";
else if (m_field == FIELD_DIRECTOR)
query = "idMVideo" + negate + " in (select idMVideo from directorlinkmusicvideo join actors on actors.idActor=directorlinkmusicvideo.idDirector where actors.strActor" + parameter + ")";
else if (m_field == FIELD_LASTPLAYED && (m_operator == OPERATOR_LESS_THAN || m_operator == OPERATOR_BEFORE || m_operator == OPERATOR_NOT_IN_THE_LAST))
query = "lastPlayed is NULL or lastPlayed" + parameter;
}
else if (strType == "tvshows")
{
if (m_field == FIELD_GENRE)
query = "idShow" + negate + " in (select idShow from genrelinktvshow join genre on genre.idGenre=genrelinktvshow.idGenre where genre.strGenre" + parameter + ")";
else if (m_field == FIELD_DIRECTOR)
query = "idShow" + negate + " in (select idShow from directorlinktvshow join actors on actors.idActor=directorlinktvshow.idDirector where actors.strActor" + parameter + ")";
else if (m_field == FIELD_ACTOR)
query = "idShow" + negate + " in (select idShow from actorlinktvshow join actors on actors.idActor=actorlinktvshow.idActor where actors.strActor" + parameter + ")";
else if (m_field == FIELD_STUDIO)
query = "idShow" + negate + " IN (SELECT idShow FROM tvshowview WHERE " + GetDatabaseField(m_field, strType) + parameter + ")";
else if (m_field == FIELD_MPAA)
query = "idShow" + negate + " IN (SELECT idShow FROM tvshowview WHERE " + GetDatabaseField(m_field, strType) + parameter + ")";
}
else if (strType == "episodes")
{
if (m_field == FIELD_GENRE)
query = "idShow" + negate + " in (select idShow from genrelinktvshow join genre on genre.idGenre=genrelinktvshow.idGenre where genre.strGenre" + parameter + ")";
else if (m_field == FIELD_DIRECTOR)
query = "idEpisode" + negate + " in (select idEpisode from directorlinkepisode join actors on actors.idActor=directorlinkepisode.idDirector where actors.strActor" + parameter + ")";
else if (m_field == FIELD_ACTOR)
query = "idEpisode" + negate + " in (select idEpisode from actorlinkepisode join actors on actors.idActor=actorlinkepisode.idActor where actors.strActor" + parameter + ")";
else if (m_field == FIELD_WRITER)
query = "idEpisode" + negate + " in (select idEpisode from writerlinkepisode join actors on actors.idActor=writerlinkepisode.idWriter where actors.strActor" + parameter + ")";
else if (m_field == FIELD_LASTPLAYED && (m_operator == OPERATOR_LESS_THAN || m_operator == OPERATOR_BEFORE || m_operator == OPERATOR_NOT_IN_THE_LAST))
query = "lastPlayed is NULL or lastPlayed" + parameter;
else if (m_field == FIELD_INPROGRESS)
query = "idFile " + negate + " in (select idFile from bookmark where type = 1)";
else if (m_field == FIELD_STUDIO)
query = "idEpisode" + negate + " IN (SELECT idEpisode FROM episodeview WHERE strStudio" + parameter + ")";
else if (m_field == FIELD_MPAA)
query = "idEpisode" + negate + " IN (SELECT idEpisode FROM episodeview WHERE mpaa" + parameter + ")";
}
if (m_field == FIELD_VIDEORESOLUTION)
query = "idFile" + negate + GetVideoResolutionQuery();
else if (m_field == FIELD_AUDIOCHANNELS)
query = "idFile" + negate + " in (select distinct idFile from streamdetails where iAudioChannels " + parameter + ")";
else if (m_field == FIELD_VIDEOCODEC)
query = "idFile" + negate + " in (select distinct idFile from streamdetails where strVideoCodec " + parameter + ")";
else if (m_field == FIELD_AUDIOCODEC)
query = "idFile" + negate + " in (select distinct idFile from streamdetails where strAudioCodec " + parameter + ")";
else if (m_field == FIELD_AUDIOLANGUAGE)
query = "idFile" + negate + " in (select distinct idFile from streamdetails where strAudioLanguage " + parameter + ")";
else if (m_field == FIELD_SUBTITLELANGUAGE)
query = "idFile" + negate + " in (select distinct idFile from streamdetails where strSubtitleLanguage " + parameter + ")";
else if (m_field == FIELD_VIDEOASPECT)
query = "idFile" + negate + " in (select distinct idFile from streamdetails where fVideoAspect " + parameter + ")";
else if (m_field == FIELD_PLAYLIST)
{ // playlist field - grab our playlist and add to our where clause
CStdString playlistFile = CSmartPlaylistDirectory::GetPlaylistByName(m_parameter, strType);
if (!playlistFile.IsEmpty())
{
CSmartPlaylist playlist;
playlist.Load(playlistFile);
CStdString playlistQuery;
// only playlists of same type will be part of the query
if (playlist.GetType().Equals(strType) || (playlist.GetType().Equals("mixed") && (strType == "songs" || strType == "musicvideos")) || playlist.GetType().IsEmpty())
{
playlist.SetType(strType);
playlistQuery = playlist.GetWhereClause(db, false);
}
if (m_operator == OPERATOR_DOES_NOT_EQUAL && playlist.GetType().Equals(strType))
query.Format("NOT (%s)", playlistQuery.c_str());
else if (m_operator == OPERATOR_EQUALS && playlist.GetType().Equals(strType))
query = playlistQuery;
}
}
if (m_field == FIELD_PLAYCOUNT && strType != "songs" && strType != "albums")
{ // playcount is stored as NULL or number in video db
if ((m_operator == OPERATOR_EQUALS && m_parameter == "0") ||
(m_operator == OPERATOR_DOES_NOT_EQUAL && m_parameter != "0") ||
(m_operator == OPERATOR_LESS_THAN))
{
CStdString field = GetDatabaseField(FIELD_PLAYCOUNT, strType);
query = field + " is NULL or " + field + parameter;
}
}
if (query.IsEmpty() && m_field != FIELD_NONE)
query = GetDatabaseField(m_field,strType) + negate + parameter;
// if we fail to get a dbfield, we empty query so it doesn't fail
if (query.Equals(negate + parameter))
query = "";
return query;
}
示例4: OnBrowse
//.........这里部分代码省略.........
format.FormatLabel(items[i].get());
iLabel = 20360;
}
if (m_type == "musicvideos" || m_type == "mixed")
{
videodatabase.GetMusicVideosNav(basePath + "titles/", items);
iLabel = 20389;
}
}
else if (m_rule.m_field == FieldPlaylist || m_rule.m_field == FieldVirtualFolder)
{
// use filebrowser to grab another smart playlist
// Note: This can cause infinite loops (playlist that refers to the same playlist) but I don't
// think there's any decent way to deal with this, as the infinite loop may be an arbitrary
// number of playlists deep, eg playlist1 -> playlist2 -> playlist3 ... -> playlistn -> playlist1
if (CSmartPlaylist::IsVideoType(m_type))
XFILE::CDirectory::GetDirectory("special://videoplaylists/", items, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS);
if (CSmartPlaylist::IsMusicType(m_type))
{
CFileItemList items2;
XFILE::CDirectory::GetDirectory("special://musicplaylists/", items2, ".xsp", XFILE::DIR_FLAG_NO_FILE_DIRS);
items.Append(items2);
}
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
CSmartPlaylist playlist;
// don't list unloadable smartplaylists or any referencable smartplaylists
// which do not match the type of the current smartplaylist
if (!playlist.Load(item->GetPath()) ||
(m_rule.m_field == FieldPlaylist &&
(!CSmartPlaylist::CheckTypeCompatibility(m_type, playlist.GetType()) ||
(!playlist.GetGroup().empty() || playlist.IsGroupMixed()))))
{
items.Remove(i);
i -= 1;
continue;
}
if (!playlist.GetName().empty())
item->SetLabel(playlist.GetName());
}
iLabel = 559;
}
else if (m_rule.m_field == FieldPath)
{
VECSOURCES sources;
if (m_type == "songs" || m_type == "mixed")
sources = *CMediaSourceSettings::GetInstance().GetSources("music");
if (CSmartPlaylist::IsVideoType(m_type))
{
VECSOURCES sources2 = *CMediaSourceSettings::GetInstance().GetSources("video");
sources.insert(sources.end(),sources2.begin(),sources2.end());
}
g_mediaManager.GetLocalDrives(sources);
std::string path = m_rule.GetParameter();
CGUIDialogFileBrowser::ShowAndGetDirectory(sources, g_localizeStrings.Get(657), path, false);
if (m_rule.m_parameter.size() > 0)
m_rule.m_parameter.clear();
if (!path.empty())
m_rule.m_parameter.push_back(path);
UpdateButtons();
示例5: GetDirectory
bool CSmartPlaylistDirectory::GetDirectory(const CStdString& strPath, CFileItemList& items)
{
// Load in the SmartPlaylist and get the WHERE query
CSmartPlaylist playlist;
if (!playlist.Load(strPath))
return false;
bool success = false, success2 = false;
if (playlist.GetType().Equals("tvshows"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
success = db.GetTvShowsByWhere("videodb://2/2/", whereOrder, items);
items.SetContent("tvshows");
db.Close();
}
else if (playlist.GetType().Equals("episodes"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
success = db.GetEpisodesByWhere("videodb://2/2/", whereOrder, items);
items.SetContent("episodes");
db.Close();
}
else if (playlist.GetType().Equals("movies"))
{
CVideoDatabase db;
db.Open();
success = db.GetMoviesByWhere("videodb://1/2/", playlist.GetWhereClause(db), playlist.GetOrderClause(db), items, true);
items.SetContent("movies");
db.Close();
}
else if (playlist.GetType().Equals("albums"))
{
CMusicDatabase db;
db.Open();
success = db.GetAlbumsByWhere("musicdb://3/", playlist.GetWhereClause(db), playlist.GetOrderClause(db), items);
items.SetContent("albums");
db.Close();
}
if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty())
{
CMusicDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (type.IsEmpty())
type = "songs";
if (playlist.GetType().Equals("mixed"))
playlist.SetType("songs");
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
success = db.GetSongsByWhere("", whereOrder, items);
items.SetContent("songs");
db.Close();
playlist.SetType(type);
}
if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed"))
{
CVideoDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (playlist.GetType().Equals("mixed"))
playlist.SetType("musicvideos");
CStdString whereOrder = playlist.GetWhereClause(db) + " " + playlist.GetOrderClause(db);
CFileItemList items2;
success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2, false); // TODO: SMARTPLAYLISTS Don't check locks???
db.Close();
items.Append(items2);
if (items2.Size())
items.SetContent("musicvideos");
playlist.SetType(type);
}
// go through and set the playlist order
for (int i = 0; i < items.Size(); i++)
{
CFileItemPtr item = items[i];
item->m_iprogramCount = i; // hack for playlist order
}
if (playlist.GetType().Equals("mixed"))
return success || success2;
else if (playlist.GetType().Equals("musicvideos"))
return success2;
else
return success;
}
示例6: Enable
bool CPartyModeManager::Enable(PartyModeContext context /*= PARTYMODECONTEXT_MUSIC*/, const CStdString& strXspPath /*= ""*/)
{
// Filter using our PartyMode xml file
CSmartPlaylist playlist;
CStdString partyModePath;
bool playlistLoaded;
m_bIsVideo = context == PARTYMODECONTEXT_VIDEO;
if (!strXspPath.IsEmpty()) //if a path to a smartplaylist is supplied use it
partyModePath = strXspPath;
else if (m_bIsVideo)
partyModePath = g_settings.GetUserDataItem("PartyMode-Video.xsp");
else
partyModePath = g_settings.GetUserDataItem("PartyMode.xsp");
playlistLoaded=playlist.Load(partyModePath);
if ( playlistLoaded )
{
m_type = playlist.GetType();
if (context == PARTYMODECONTEXT_UNKNOWN)
{
//get it from the xsp file
m_bIsVideo = (m_type.Equals("video") || m_type.Equals("musicvideos") || m_type.Equals("mixed"));
}
if (m_type.Equals("mixed"))
playlist.SetType("songs");
if (m_type.Equals("mixed"))
playlist.SetType("video");
playlist.SetType(m_type);
}
else
{
m_strCurrentFilterMusic.Empty();
m_strCurrentFilterVideo.Empty();
m_type = m_bIsVideo ? "musicvideos" : "songs";
}
CGUIDialogProgress* pDialog = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
int iHeading = (m_bIsVideo ? 20250 : 20121);
int iLine0 = (m_bIsVideo ? 20251 : 20123);
pDialog->SetHeading(iHeading);
pDialog->SetLine(0, iLine0);
pDialog->SetLine(1, "");
pDialog->SetLine(2, "");
pDialog->StartModal();
ClearState();
unsigned int time = XbmcThreads::SystemClockMillis();
vector< pair<int,int> > songIDs;
if (m_type.Equals("songs") || m_type.Equals("mixed"))
{
CMusicDatabase db;
if (db.Open())
{
set<CStdString> playlists;
if ( playlistLoaded )
m_strCurrentFilterMusic = playlist.GetWhereClause(db, playlists);
CLog::Log(LOGINFO, "PARTY MODE MANAGER: Registering filter:[%s]", m_strCurrentFilterMusic.c_str());
m_iMatchingSongs = (int)db.GetSongIDs(m_strCurrentFilterMusic, songIDs);
if (m_iMatchingSongs < 1 && m_type.Equals("songs"))
{
pDialog->Close();
db.Close();
OnError(16031, (CStdString)"Party mode found no matching songs. Aborting.");
return false;
}
}
else
{
pDialog->Close();
OnError(16033, (CStdString)"Party mode could not open database. Aborting.");
return false;
}
db.Close();
}
if (m_type.Equals("musicvideos") || m_type.Equals("mixed"))
{
vector< pair<int,int> > songIDs2;
CVideoDatabase db;
if (db.Open())
{
set<CStdString> playlists;
if ( playlistLoaded )
m_strCurrentFilterVideo = playlist.GetWhereClause(db, playlists);
CLog::Log(LOGINFO, "PARTY MODE MANAGER: Registering filter:[%s]", m_strCurrentFilterVideo.c_str());
m_iMatchingSongs += (int)db.GetMusicVideoIDs(m_strCurrentFilterVideo, songIDs2);
if (m_iMatchingSongs < 1)
{
pDialog->Close();
db.Close();
OnError(16031, (CStdString)"Party mode found no matching songs. Aborting.");
return false;
}
//.........这里部分代码省略.........
示例7: 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());
//.........这里部分代码省略.........
示例8: 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;
//.........这里部分代码省略.........
示例9: GetDirectory
bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items)
{
bool success = false, success2 = false;
std::set<CStdString> playlists;
if (playlist.GetType().Equals("tvshows"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db);
success = db.GetTvShowsByWhere("videodb://2/2/", whereOrder, items);
items.SetContent("tvshows");
db.Close();
}
else if (playlist.GetType().Equals("episodes"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db);
success = db.GetEpisodesByWhere("videodb://2/2/", whereOrder, items);
items.SetContent("episodes");
db.Close();
}
else if (playlist.GetType().Equals("movies"))
{
CVideoDatabase db;
db.Open();
success = db.GetMoviesByWhere("videodb://1/2/", playlist.GetWhereClause(db, playlists), playlist.GetOrderClause(db), items, true);
items.SetContent("movies");
db.Close();
}
else if (playlist.GetType().Equals("albums"))
{
CMusicDatabase db;
db.Open();
success = db.GetAlbumsByWhere("musicdb://3/", playlist.GetWhereClause(db, playlists), playlist.GetOrderClause(db), items);
items.SetContent("albums");
db.Close();
}
if (playlist.GetType().Equals("songs") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty())
{
CMusicDatabase db;
db.Open();
CStdString whereOrder;
if (playlist.GetType().IsEmpty() || playlist.GetType().Equals("mixed"))
{
CSmartPlaylist songPlaylist(playlist);
songPlaylist.SetType("songs");
whereOrder = songPlaylist.GetWhereClause(db, playlists) + " " + songPlaylist.GetOrderClause(db);
}
else
whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db);
success = db.GetSongsByWhere("", whereOrder, items);
items.SetContent("songs");
db.Close();
}
if (playlist.GetType().Equals("musicvideos") || playlist.GetType().Equals("mixed"))
{
CVideoDatabase db;
db.Open();
CStdString whereOrder;
if (playlist.GetType().Equals("mixed"))
{
CSmartPlaylist mvidPlaylist(playlist);
mvidPlaylist.SetType("musicvideos");
whereOrder = mvidPlaylist.GetWhereClause(db, playlists) + " " + mvidPlaylist.GetOrderClause(db);
}
else
whereOrder = playlist.GetWhereClause(db, playlists) + " " + playlist.GetOrderClause(db);
CFileItemList items2;
success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2, false); // TODO: SMARTPLAYLISTS Don't check locks???
db.Close();
items.Append(items2);
if (items2.Size())
items.SetContent("musicvideos");
}
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;
}
示例10: GetDirectory
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("music") || playlist.GetType().Equals("mixed") || playlist.GetType().IsEmpty())
{
CMusicDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (type.IsEmpty())
type = "music";
if (playlist.GetType().Equals("mixed"))
playlist.SetType("music");
CStdString whereOrder = playlist.GetWhereClause() + " " + playlist.GetOrderClause();
success = db.GetSongsByWhere("", whereOrder, items);
db.Close();
playlist.SetType(type);
}
if (playlist.GetType().Equals("video") || playlist.GetType().Equals("mixed"))
{
CVideoDatabase db;
db.Open();
CStdString type=playlist.GetType();
if (playlist.GetType().Equals("mixed"))
playlist.SetType("video");
CStdString whereOrder = playlist.GetWhereClause() + " " + playlist.GetOrderClause();
CFileItemList items2;
success2 = db.GetMusicVideosByWhere("videodb://3/2/", whereOrder, items2);
db.Close();
items.Append(items2);
playlist.SetType(type);
}
if (playlist.GetType().Equals("mixed"))
return success || success2;
else if (playlist.GetType().Equals("video"))
return success2;
else
return success;
}