Skip to content

Commit

Permalink
CSmartPlaylistDirectory: add an optional parameter for the basedir to…
Browse files Browse the repository at this point in the history
… GetDirectory()
  • Loading branch information
Montellese committed Oct 8, 2012
1 parent 3b33950 commit dd7c497
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
33 changes: 18 additions & 15 deletions xbmc/filesystem/SmartPlaylistDirectory.cpp
Expand Up @@ -50,7 +50,7 @@ namespace XFILE
return GetDirectory(playlist, items);
}

bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items)
bool CSmartPlaylistDirectory::GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items, const CStdString &strBaseDir /* = "" */)
{
bool success = false, success2 = false;
std::set<CStdString> playlists;
Expand All @@ -71,20 +71,23 @@ namespace XFILE
{
MediaType mediaType = DatabaseUtils::MediaTypeFromString(playlist.GetType());

CStdString strBaseDir;
switch (mediaType)
CStdString baseDir = strBaseDir;
if (strBaseDir.empty())
{
case MediaTypeTvShow:
case MediaTypeEpisode:
strBaseDir = "videodb://2/2/";
break;
switch (mediaType)
{
case MediaTypeTvShow:
case MediaTypeEpisode:
baseDir = "videodb://2/2/";
break;

case MediaTypeMovie:
strBaseDir = "videodb://1/2/";
break;
case MediaTypeMovie:
baseDir = "videodb://1/2/";
break;

default:
return false;
default:
return false;
}
}

CVideoDbUrl videoUrl;
Expand All @@ -107,7 +110,7 @@ namespace XFILE
{
CMusicDbUrl musicUrl;
CStdString xsp;
if (!musicUrl.FromString("musicdb://3/") || !playlist.SaveAsJson(xsp, false))
if (!musicUrl.FromString(!strBaseDir.empty() ? strBaseDir : "musicdb://3/") || !playlist.SaveAsJson(xsp, false))
return false;

// store the smartplaylist as JSON in the URL as well
Expand Down Expand Up @@ -151,7 +154,7 @@ namespace XFILE

CMusicDbUrl musicUrl;
CStdString xsp;
if (!musicUrl.FromString("musicdb://4/") || !songPlaylist.SaveAsJson(xsp, false))
if (!musicUrl.FromString(!strBaseDir.empty() ? strBaseDir : "musicdb://4/") || !songPlaylist.SaveAsJson(xsp, false))
return false;

// store the smartplaylist as JSON in the URL as well
Expand All @@ -174,7 +177,7 @@ namespace XFILE

CVideoDbUrl videoUrl;
CStdString xsp;
if (!videoUrl.FromString("videodb://3/2/") || !mvidPlaylist.SaveAsJson(xsp, false))
if (!videoUrl.FromString(!strBaseDir.empty() ? strBaseDir : "videodb://3/2/") || !mvidPlaylist.SaveAsJson(xsp, false))
return false;

// store the smartplaylist as JSON in the URL as well
Expand Down
2 changes: 1 addition & 1 deletion xbmc/filesystem/SmartPlaylistDirectory.h
Expand Up @@ -36,7 +36,7 @@ namespace XFILE
virtual bool ContainsFiles(const CStdString& strPath);
virtual bool Remove(const char *strPath);

static bool GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items);
static bool GetDirectory(const CSmartPlaylist &playlist, CFileItemList& items, const CStdString &strBaseDir = "");

static CStdString GetPlaylistByName(const CStdString& name, const CStdString& playlistType);
};
Expand Down

0 comments on commit dd7c497

Please sign in to comment.