Skip to content

Commit

Permalink
VideoDatabaseDirectory: retrieve, store and use videodb:// URL options
Browse files Browse the repository at this point in the history
  • Loading branch information
Montellese committed Aug 5, 2012
1 parent 5c10987 commit 973831c
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 32 deletions.
16 changes: 16 additions & 0 deletions xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.cpp
Expand Up @@ -94,6 +94,9 @@ CDirectoryNode* CDirectoryNode::ParseURL(const CStdString& strPath)
pParent=pNode;
}

// Add all the additional URL options to the last node
pNode->AddOptions(url.GetOptions());

return pNode;
}

Expand Down Expand Up @@ -227,9 +230,21 @@ CStdString CDirectoryNode::BuildPath() const
for (int i=0; i<(int)array.size(); ++i)
strPath+=array[i]+"/";

string options = m_options.GetOptionsString();
if (!options.empty())
strPath += "?" + options;

return strPath;
}

void CDirectoryNode::AddOptions(const CStdString &options)
{
if (options.empty())
return;

m_options.AddOptions(options);
}

// Collects Query params from this and all parent nodes. If a NODE_TYPE can
// be used as a database parameter, it will be added to the
// params object.
Expand Down Expand Up @@ -263,6 +278,7 @@ bool CDirectoryNode::GetChilds(CFileItemList& items)
bool bSuccess=false;
if (pNode.get())
{
pNode->m_options = m_options;
bSuccess=pNode->GetContent(items);
if (bSuccess)
{
Expand Down
4 changes: 3 additions & 1 deletion xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.h
Expand Up @@ -20,8 +20,8 @@
*
*/


#include "utils/StdString.h"
#include "utils/UrlOptions.h"

class CFileItemList;

Expand Down Expand Up @@ -84,6 +84,7 @@ namespace XFILE
CDirectoryNode(NODE_TYPE Type, const CStdString& strName, CDirectoryNode* pParent);
static CDirectoryNode* CreateNode(NODE_TYPE Type, const CStdString& strName, CDirectoryNode* pParent);

void AddOptions(const CStdString &options);
void CollectQueryParams(CQueryParams& params) const;

const CStdString& GetName() const;
Expand All @@ -101,6 +102,7 @@ namespace XFILE
NODE_TYPE m_Type;
CStdString m_strName;
CDirectoryNode* m_pParent;
CUrlOptions m_options;
};
}
}
Expand Down
Expand Up @@ -40,13 +40,11 @@ bool CDirectoryNodeEpisodes::GetContent(CFileItemList& items) const
CQueryParams params;
CollectQueryParams(params);

CStdString strBaseDir=BuildPath();

int season = (int)params.GetSeason();
if (season == -2)
season = -1;

bool bSuccess=videodatabase.GetEpisodesNav(strBaseDir, items, params.GetGenreId(), params.GetYear(), params.GetActorId(), params.GetDirectorId(), params.GetTvShowId(), season);
bool bSuccess=videodatabase.GetEpisodesNav(BuildPath(), items, params.GetGenreId(), params.GetYear(), params.GetActorId(), params.GetDirectorId(), params.GetTvShowId(), season);

videodatabase.Close();

Expand Down
Expand Up @@ -23,6 +23,7 @@
#include "FileItem.h"
#include "guilib/LocalizeStrings.h"
#include "video/VideoDatabase.h"
#include "video/VideoDbUrl.h"

using namespace XFILE::VIDEODATABASEDIRECTORY;
using namespace std;
Expand Down Expand Up @@ -64,6 +65,10 @@ CStdString CDirectoryNodeMoviesOverview::GetLocalizedName() const

bool CDirectoryNodeMoviesOverview::GetContent(CFileItemList& items) const
{
CVideoDbUrl videoUrl;
if (!videoUrl.FromString(BuildPath()))
return false;

for (unsigned int i = 0; i < sizeof(MovieChildren) / sizeof(Node); ++i)
{
if (i == 6)
Expand All @@ -72,9 +77,12 @@ bool CDirectoryNodeMoviesOverview::GetContent(CFileItemList& items) const
if (db.Open() && !db.HasSets())
continue;
}
CStdString path;
path.Format("%s%ld/", BuildPath().c_str(), MovieChildren[i].id);
CFileItemPtr pItem(new CFileItem(path, true));

CVideoDbUrl itemUrl = videoUrl;
CStdString strDir; strDir.Format("%ld/", MovieChildren[i].id);
itemUrl.AppendPath(strDir);

CFileItemPtr pItem(new CFileItem(itemUrl.ToString(), true));
pItem->SetLabel(g_localizeStrings.Get(MovieChildren[i].label));
pItem->SetCanQueue(false);
items.Add(pItem);
Expand Down
Expand Up @@ -22,6 +22,7 @@
#include "DirectoryNodeMusicVideosOverview.h"
#include "FileItem.h"
#include "guilib/LocalizeStrings.h"
#include "video/VideoDbUrl.h"

using namespace XFILE::VIDEODATABASEDIRECTORY;

Expand Down Expand Up @@ -60,12 +61,19 @@ CStdString CDirectoryNodeMusicVideosOverview::GetLocalizedName() const

bool CDirectoryNodeMusicVideosOverview::GetContent(CFileItemList& items) const
{
CVideoDbUrl videoUrl;
if (!videoUrl.FromString(BuildPath()))
return false;

for (unsigned int i = 0; i < sizeof(MusicVideoChildren) / sizeof(Node); ++i)
{
CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(MusicVideoChildren[i].label)));
CStdString strDir;
strDir.Format("%ld/", MusicVideoChildren[i].id);
pItem->SetPath(BuildPath() + strDir);

CVideoDbUrl itemUrl = videoUrl;
CStdString strDir; strDir.Format("%ld/", MusicVideoChildren[i].id);
itemUrl.AppendPath(strDir);
pItem->SetPath(itemUrl.ToString());

pItem->m_bIsFolder = true;
pItem->SetCanQueue(false);
items.Add(pItem);
Expand Down
13 changes: 11 additions & 2 deletions xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeOverview.cpp
Expand Up @@ -25,6 +25,7 @@
#include "settings/Settings.h"
#include "FileItem.h"
#include "guilib/LocalizeStrings.h"
#include "video/VideoDbUrl.h"

using namespace XFILE::VIDEODATABASEDIRECTORY;
using namespace std;
Expand Down Expand Up @@ -64,6 +65,10 @@ CStdString CDirectoryNodeOverview::GetLocalizedName() const

bool CDirectoryNodeOverview::GetContent(CFileItemList& items) const
{
CVideoDbUrl videoUrl;
if (!videoUrl.FromString(BuildPath()))
return false;

CVideoDatabase database;
database.Open();
bool hasMovies = database.HasContent(VIDEODB_CONTENT_MOVIES);
Expand Down Expand Up @@ -100,10 +105,14 @@ bool CDirectoryNodeOverview::GetContent(CFileItemList& items) const
if (hasMusicVideos)
vec.push_back(make_pair("6", 20390)); // Recently Added Music Videos
}
CStdString path = BuildPath();

for (unsigned int i = 0; i < vec.size(); ++i)
{
CFileItemPtr pItem(new CFileItem(path + vec[i].first + "/", true));
CVideoDbUrl itemUrl = videoUrl;
CStdString strDir; strDir.Format("%s/", vec[i].first);
itemUrl.AppendPath(strDir);

CFileItemPtr pItem(new CFileItem(itemUrl.ToString()));
pItem->SetLabel(g_localizeStrings.Get(vec[i].second));
pItem->SetLabelPreformated(true);
pItem->SetCanQueue(false);
Expand Down
Expand Up @@ -41,9 +41,8 @@ bool CDirectoryNodeRecentlyAddedEpisodes::GetContent(CFileItemList& items) const
CVideoDatabase videodatabase;
if (!videodatabase.Open())
return false;

CStdString strBaseDir=BuildPath();
bool bSuccess=videodatabase.GetRecentlyAddedEpisodesNav(strBaseDir, items);

bool bSuccess=videodatabase.GetRecentlyAddedEpisodesNav(BuildPath(), items);

videodatabase.Close();

Expand Down
Expand Up @@ -41,9 +41,8 @@ bool CDirectoryNodeRecentlyAddedMovies::GetContent(CFileItemList& items) const
CVideoDatabase videodatabase;
if (!videodatabase.Open())
return false;

CStdString strBaseDir=BuildPath();
bool bSuccess=videodatabase.GetRecentlyAddedMoviesNav(strBaseDir, items);

bool bSuccess=videodatabase.GetRecentlyAddedMoviesNav(BuildPath(), items);

videodatabase.Close();

Expand Down
Expand Up @@ -41,9 +41,8 @@ bool CDirectoryNodeRecentlyAddedMusicVideos::GetContent(CFileItemList& items) co
CVideoDatabase videodatabase;
if (!videodatabase.Open())
return false;

CStdString strBaseDir=BuildPath();
bool bSuccess=videodatabase.GetRecentlyAddedMusicVideosNav(strBaseDir, items);

bool bSuccess=videodatabase.GetRecentlyAddedMusicVideosNav(BuildPath(), items);

videodatabase.Close();

Expand Down
11 changes: 9 additions & 2 deletions xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp
Expand Up @@ -22,6 +22,7 @@
#include "DirectoryNodeSeasons.h"
#include "QueryParams.h"
#include "video/VideoDatabase.h"
#include "video/VideoDbUrl.h"
#include "settings/GUISettings.h"
#include "settings/Settings.h"
#include "FileItem.h"
Expand Down Expand Up @@ -92,8 +93,14 @@ bool CDirectoryNodeSeasons::GetContent(CFileItemList& items) const
if (bFlatten)
{ // flatten if one season or flatten always
items.Clear();
bSuccess=videodatabase.GetEpisodesNav(BuildPath()+"-2/",items,params.GetGenreId(),params.GetYear(),params.GetActorId(),params.GetDirectorId(),params.GetTvShowId());
items.SetPath(BuildPath()+"-2/");

CVideoDbUrl videoUrl;
if (!videoUrl.FromString(BuildPath()))
return false;

videoUrl.AppendPath("-2/");
bSuccess=videodatabase.GetEpisodesNav(videoUrl.ToString(), items, params.GetGenreId(), params.GetYear(), params.GetActorId(), params.GetDirectorId(), params.GetTvShowId());
items.SetPath(videoUrl.ToString());
}

videodatabase.Close();
Expand Down
Expand Up @@ -40,8 +40,7 @@ bool CDirectoryNodeTitleMovies::GetContent(CFileItemList& items) const
CQueryParams params;
CollectQueryParams(params);

CStdString strBaseDir=BuildPath();
bool bSuccess=videodatabase.GetMoviesNav(strBaseDir, items, params.GetGenreId(), params.GetYear(), params.GetActorId(), params.GetDirectorId(), params.GetStudioId(), params.GetCountryId(), params.GetSetId(), params.GetTagId());
bool bSuccess=videodatabase.GetMoviesNav(BuildPath(), items, params.GetGenreId(), params.GetYear(), params.GetActorId(), params.GetDirectorId(), params.GetStudioId(), params.GetCountryId(), params.GetSetId(), params.GetTagId());

videodatabase.Close();

Expand Down
Expand Up @@ -40,8 +40,7 @@ bool CDirectoryNodeTitleMusicVideos::GetContent(CFileItemList& items) const
CQueryParams params;
CollectQueryParams(params);

CStdString strBaseDir=BuildPath();
bool bSuccess=videodatabase.GetMusicVideosNav(strBaseDir, items, params.GetGenreId(), params.GetYear(), params.GetActorId(), params.GetDirectorId(),params.GetStudioId(),params.GetAlbumId());
bool bSuccess=videodatabase.GetMusicVideosNav(BuildPath(), items, params.GetGenreId(), params.GetYear(), params.GetActorId(), params.GetDirectorId(),params.GetStudioId(),params.GetAlbumId());

videodatabase.Close();

Expand Down
Expand Up @@ -22,6 +22,7 @@
#include "DirectoryNodeTvShowsOverview.h"
#include "FileItem.h"
#include "guilib/LocalizeStrings.h"
#include "video/VideoDbUrl.h"

using namespace XFILE::VIDEODATABASEDIRECTORY;

Expand Down Expand Up @@ -61,12 +62,19 @@ CStdString CDirectoryNodeTvShowsOverview::GetLocalizedName() const

bool CDirectoryNodeTvShowsOverview::GetContent(CFileItemList& items) const
{
CVideoDbUrl videoUrl;
if (!videoUrl.FromString(BuildPath()))
return false;

for (unsigned int i = 0; i < sizeof(TvShowChildren) / sizeof(Node); ++i)
{
CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(TvShowChildren[i].label)));
CStdString strDir;
strDir.Format("%ld/", TvShowChildren[i].id);
pItem->SetPath(BuildPath() + strDir);

CVideoDbUrl itemUrl = videoUrl;
CStdString strDir; strDir.Format("%ld/", TvShowChildren[i].id);
itemUrl.AppendPath(strDir);
pItem->SetPath(itemUrl.ToString());

pItem->m_bIsFolder = true;
pItem->SetCanQueue(false);
items.Add(pItem);
Expand Down
3 changes: 1 addition & 2 deletions xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeYear.cpp
Expand Up @@ -57,8 +57,7 @@ bool CDirectoryNodeYear::GetContent(CFileItemList& items) const
CQueryParams params;
CollectQueryParams(params);

CStdString strBaseDir=BuildPath();
bool bSuccess=videodatabase.GetYearsNav(strBaseDir, items, params.GetContentType());
bool bSuccess=videodatabase.GetYearsNav(BuildPath(), items, params.GetContentType());

videodatabase.Close();

Expand Down

0 comments on commit 973831c

Please sign in to comment.