diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-10 18:07:22 +0000 |
commit | c04dcc2e7d834218ef2d4194331e383402495ae1 (patch) | |
tree | 7333e38d10d75386e60f336b80c2443c1166031d /xbmc/filesystem/VideoDatabaseDirectory | |
parent | Initial commit. (diff) | |
download | kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip |
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/filesystem/VideoDatabaseDirectory')
35 files changed, 1908 insertions, 0 deletions
diff --git a/xbmc/filesystem/VideoDatabaseDirectory/CMakeLists.txt b/xbmc/filesystem/VideoDatabaseDirectory/CMakeLists.txt new file mode 100644 index 0000000..149fa5c --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/CMakeLists.txt @@ -0,0 +1,37 @@ +set(SOURCES DirectoryNode.cpp + DirectoryNodeEpisodes.cpp + DirectoryNodeGrouped.cpp + DirectoryNodeInProgressTvShows.cpp + DirectoryNodeMoviesOverview.cpp + DirectoryNodeMusicVideosOverview.cpp + DirectoryNodeOverview.cpp + DirectoryNodeRecentlyAddedEpisodes.cpp + DirectoryNodeRecentlyAddedMovies.cpp + DirectoryNodeRecentlyAddedMusicVideos.cpp + DirectoryNodeRoot.cpp + DirectoryNodeSeasons.cpp + DirectoryNodeTitleMovies.cpp + DirectoryNodeTitleMusicVideos.cpp + DirectoryNodeTitleTvShows.cpp + DirectoryNodeTvShowsOverview.cpp + QueryParams.cpp) + +set(HEADERS DirectoryNode.h + DirectoryNodeEpisodes.h + DirectoryNodeGrouped.h + DirectoryNodeInProgressTvShows.h + DirectoryNodeMoviesOverview.h + DirectoryNodeMusicVideosOverview.h + DirectoryNodeOverview.h + DirectoryNodeRecentlyAddedEpisodes.h + DirectoryNodeRecentlyAddedMovies.h + DirectoryNodeRecentlyAddedMusicVideos.h + DirectoryNodeRoot.h + DirectoryNodeSeasons.h + DirectoryNodeTitleMovies.h + DirectoryNodeTitleMusicVideos.h + DirectoryNodeTitleTvShows.h + DirectoryNodeTvShowsOverview.h + QueryParams.h) + +core_add_library(videodatabasedirectory) diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.cpp new file mode 100644 index 0000000..7f83cff --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.cpp @@ -0,0 +1,271 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNode.h" + +#include "DirectoryNodeEpisodes.h" +#include "DirectoryNodeGrouped.h" +#include "DirectoryNodeInProgressTvShows.h" +#include "DirectoryNodeMoviesOverview.h" +#include "DirectoryNodeMusicVideosOverview.h" +#include "DirectoryNodeOverview.h" +#include "DirectoryNodeRecentlyAddedEpisodes.h" +#include "DirectoryNodeRecentlyAddedMovies.h" +#include "DirectoryNodeRecentlyAddedMusicVideos.h" +#include "DirectoryNodeRoot.h" +#include "DirectoryNodeSeasons.h" +#include "DirectoryNodeTitleMovies.h" +#include "DirectoryNodeTitleMusicVideos.h" +#include "DirectoryNodeTitleTvShows.h" +#include "DirectoryNodeTvShowsOverview.h" +#include "FileItem.h" +#include "QueryParams.h" +#include "URL.h" +#include "utils/StringUtils.h" +#include "utils/URIUtils.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +// Constructor is protected use ParseURL() +CDirectoryNode::CDirectoryNode(NODE_TYPE Type, const std::string& strName, CDirectoryNode* pParent) +{ + m_Type = Type; + m_strName = strName; + m_pParent = pParent; +} + +CDirectoryNode::~CDirectoryNode() +{ + delete m_pParent, m_pParent = nullptr; +} + +// Parses a given path and returns the current node of the path +CDirectoryNode* CDirectoryNode::ParseURL(const std::string& strPath) +{ + CURL url(strPath); + + std::string strDirectory = url.GetFileName(); + URIUtils::RemoveSlashAtEnd(strDirectory); + + std::vector<std::string> Path = StringUtils::Tokenize(strDirectory, '/'); + // we always have a root node, it is special and has a path of "" + Path.insert(Path.begin(), ""); + + CDirectoryNode *pNode = nullptr; + CDirectoryNode *pParent = nullptr; + NODE_TYPE NodeType = NODE_TYPE_ROOT; + // loop down the dir path, creating a node with a parent. + // if we hit a child type of NODE_TYPE_NONE, then we are done. + for (size_t i = 0; i < Path.size() && NodeType != NODE_TYPE_NONE; ++i) + { + pNode = CDirectoryNode::CreateNode(NodeType, Path[i], pParent); + NodeType = pNode ? pNode->GetChildType() : NODE_TYPE_NONE; + pParent = pNode; + } + + // Add all the additional URL options to the last node + if (pNode) + pNode->AddOptions(url.GetOptions()); + + return pNode; +} + +// returns the database ids of the path, +void CDirectoryNode::GetDatabaseInfo(const std::string& strPath, CQueryParams& params) +{ + std::unique_ptr<CDirectoryNode> pNode(CDirectoryNode::ParseURL(strPath)); + + if (!pNode) + return; + + pNode->CollectQueryParams(params); +} + +// Create a node object +CDirectoryNode* CDirectoryNode::CreateNode(NODE_TYPE Type, const std::string& strName, CDirectoryNode* pParent) +{ + switch (Type) + { + case NODE_TYPE_ROOT: + return new CDirectoryNodeRoot(strName, pParent); + case NODE_TYPE_OVERVIEW: + return new CDirectoryNodeOverview(strName, pParent); + case NODE_TYPE_GENRE: + case NODE_TYPE_COUNTRY: + case NODE_TYPE_SETS: + case NODE_TYPE_TAGS: + case NODE_TYPE_YEAR: + case NODE_TYPE_ACTOR: + case NODE_TYPE_DIRECTOR: + case NODE_TYPE_STUDIO: + case NODE_TYPE_MUSICVIDEOS_ALBUM: + return new CDirectoryNodeGrouped(Type, strName, pParent); + case NODE_TYPE_TITLE_MOVIES: + return new CDirectoryNodeTitleMovies(strName, pParent); + case NODE_TYPE_TITLE_TVSHOWS: + return new CDirectoryNodeTitleTvShows(strName, pParent); + case NODE_TYPE_MOVIES_OVERVIEW: + return new CDirectoryNodeMoviesOverview(strName, pParent); + case NODE_TYPE_TVSHOWS_OVERVIEW: + return new CDirectoryNodeTvShowsOverview(strName, pParent); + case NODE_TYPE_SEASONS: + return new CDirectoryNodeSeasons(strName, pParent); + case NODE_TYPE_EPISODES: + return new CDirectoryNodeEpisodes(strName, pParent); + case NODE_TYPE_RECENTLY_ADDED_MOVIES: + return new CDirectoryNodeRecentlyAddedMovies(strName,pParent); + case NODE_TYPE_RECENTLY_ADDED_EPISODES: + return new CDirectoryNodeRecentlyAddedEpisodes(strName,pParent); + case NODE_TYPE_MUSICVIDEOS_OVERVIEW: + return new CDirectoryNodeMusicVideosOverview(strName,pParent); + case NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS: + return new CDirectoryNodeRecentlyAddedMusicVideos(strName,pParent); + case NODE_TYPE_INPROGRESS_TVSHOWS: + return new CDirectoryNodeInProgressTvShows(strName,pParent); + case NODE_TYPE_TITLE_MUSICVIDEOS: + return new CDirectoryNodeTitleMusicVideos(strName,pParent); + default: + break; + } + + return nullptr; +} + +// Current node name +const std::string& CDirectoryNode::GetName() const +{ + return m_strName; +} + +int CDirectoryNode::GetID() const +{ + return atoi(m_strName.c_str()); +} + +std::string CDirectoryNode::GetLocalizedName() const +{ + return ""; +} + +// Current node type +NODE_TYPE CDirectoryNode::GetType() const +{ + return m_Type; +} + +// Return the parent directory node or NULL, if there is no +CDirectoryNode* CDirectoryNode::GetParent() const +{ + return m_pParent; +} + +void CDirectoryNode::RemoveParent() +{ + m_pParent = nullptr; +} + +// should be overloaded by a derived class +// to get the content of a node. Will be called +// by GetChilds() of a parent node +bool CDirectoryNode::GetContent(CFileItemList& items) const +{ + return false; +} + +// Creates a videodb url +std::string CDirectoryNode::BuildPath() const +{ + std::vector<std::string> array; + + if (!m_strName.empty()) + array.insert(array.begin(), m_strName); + + CDirectoryNode* pParent=m_pParent; + while (pParent != nullptr) + { + const std::string& strNodeName=pParent->GetName(); + if (!strNodeName.empty()) + array.insert(array.begin(), strNodeName); + + pParent = pParent->GetParent(); + } + + std::string strPath="videodb://"; + for (int i = 0; i < static_cast<int>(array.size()); ++i) + strPath += array[i]+"/"; + + std::string options = m_options.GetOptionsString(); + if (!options.empty()) + strPath += "?" + options; + + return strPath; +} + +void CDirectoryNode::AddOptions(const std::string &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. +void CDirectoryNode::CollectQueryParams(CQueryParams& params) const +{ + params.SetQueryParam(m_Type, m_strName); + + CDirectoryNode* pParent=m_pParent; + while (pParent != nullptr) + { + params.SetQueryParam(pParent->GetType(), pParent->GetName()); + pParent = pParent->GetParent(); + } +} + +// Should be overloaded by a derived class. +// Returns the NODE_TYPE of the child nodes. +NODE_TYPE CDirectoryNode::GetChildType() const +{ + return NODE_TYPE_NONE; +} + +// Get the child fileitems of this node +bool CDirectoryNode::GetChilds(CFileItemList& items) +{ + if (CanCache() && items.Load()) + return true; + + std::unique_ptr<CDirectoryNode> pNode(CDirectoryNode::CreateNode(GetChildType(), "", this)); + + bool bSuccess=false; + if (pNode) + { + pNode->m_options = m_options; + bSuccess = pNode->GetContent(items); + if (bSuccess) + { + if (CanCache()) + items.SetCacheToDisc(CFileItemList::CACHE_ALWAYS); + } + else + items.Clear(); + + pNode->RemoveParent(); + } + + return bSuccess; +} + +bool CDirectoryNode::CanCache() const +{ + // no caching is required - the list is cached in CGUIMediaWindow::GetDirectory + // if it was slow to fetch anyway. + return false; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.h new file mode 100644 index 0000000..7ab27c5 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNode.h @@ -0,0 +1,99 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "utils/UrlOptions.h" + +#include <string> + +class CFileItemList; + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CQueryParams; + + typedef enum _NODE_TYPE + { + NODE_TYPE_NONE=0, + NODE_TYPE_MOVIES_OVERVIEW, + NODE_TYPE_TVSHOWS_OVERVIEW, + NODE_TYPE_GENRE, + NODE_TYPE_ACTOR, + NODE_TYPE_ROOT, + NODE_TYPE_OVERVIEW, + NODE_TYPE_TITLE_MOVIES, + NODE_TYPE_YEAR, + NODE_TYPE_DIRECTOR, + NODE_TYPE_TITLE_TVSHOWS, + NODE_TYPE_SEASONS, + NODE_TYPE_EPISODES, + NODE_TYPE_RECENTLY_ADDED_MOVIES, + NODE_TYPE_RECENTLY_ADDED_EPISODES, + NODE_TYPE_STUDIO, + NODE_TYPE_MUSICVIDEOS_OVERVIEW, + NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS, + NODE_TYPE_TITLE_MUSICVIDEOS, + NODE_TYPE_MUSICVIDEOS_ALBUM, + NODE_TYPE_SETS, + NODE_TYPE_COUNTRY, + NODE_TYPE_TAGS, + NODE_TYPE_INPROGRESS_TVSHOWS + } NODE_TYPE; + + typedef struct { + NODE_TYPE node; + std::string id; + int label; + } Node; + + class CDirectoryNode + { + public: + static CDirectoryNode* ParseURL(const std::string& strPath); + static void GetDatabaseInfo(const std::string& strPath, CQueryParams& params); + virtual ~CDirectoryNode(); + + NODE_TYPE GetType() const; + + bool GetChilds(CFileItemList& items); + virtual NODE_TYPE GetChildType() const; + virtual std::string GetLocalizedName() const; + void CollectQueryParams(CQueryParams& params) const; + + CDirectoryNode* GetParent() const; + + std::string BuildPath() const; + + virtual bool CanCache() const; + protected: + CDirectoryNode(NODE_TYPE Type, const std::string& strName, CDirectoryNode* pParent); + static CDirectoryNode* CreateNode(NODE_TYPE Type, const std::string& strName, CDirectoryNode* pParent); + + void AddOptions(const std::string& options); + + const std::string& GetName() const; + int GetID() const; + void RemoveParent(); + + virtual bool GetContent(CFileItemList& items) const; + + + private: + NODE_TYPE m_Type; + std::string m_strName; + CDirectoryNode* m_pParent; + CUrlOptions m_options; + }; + } +} + + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeEpisodes.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeEpisodes.cpp new file mode 100644 index 0000000..9f629ba --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeEpisodes.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeEpisodes.h" + +#include "FileItem.h" +#include "QueryParams.h" +#include "video/VideoDatabase.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CDirectoryNodeEpisodes::CDirectoryNodeEpisodes(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_EPISODES, strName, pParent) +{ + +} + +bool CDirectoryNodeEpisodes::GetContent(CFileItemList& items) const +{ + CVideoDatabase videodatabase; + if (!videodatabase.Open()) + return false; + + CQueryParams params; + CollectQueryParams(params); + + int season = (int)params.GetSeason(); + if (season == -2) + season = -1; + + int details = items.HasProperty("set_videodb_details") + ? items.GetProperty("set_videodb_details").asInteger32() + : VideoDbDetailsNone; + + bool bSuccess = videodatabase.GetEpisodesNav( + BuildPath(), items, params.GetGenreId(), params.GetYear(), params.GetActorId(), + params.GetDirectorId(), params.GetTvShowId(), season, SortDescription(), details); + + videodatabase.Close(); + + return bSuccess; +} + +NODE_TYPE CDirectoryNodeEpisodes::GetChildType() const +{ + return NODE_TYPE_EPISODES; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeEpisodes.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeEpisodes.h new file mode 100644 index 0000000..e5a640a --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeEpisodes.h @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeEpisodes : public CDirectoryNode + { + public: + CDirectoryNodeEpisodes(const std::string& strEntryName, CDirectoryNode* pParent); + protected: + bool GetContent(CFileItemList& items) const override; + NODE_TYPE GetChildType() const override; + }; + } +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeGrouped.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeGrouped.cpp new file mode 100644 index 0000000..73ec115 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeGrouped.cpp @@ -0,0 +1,127 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeGrouped.h" + +#include "QueryParams.h" +#include "video/VideoDatabase.h" +#include "video/VideoDbUrl.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CDirectoryNodeGrouped::CDirectoryNodeGrouped(NODE_TYPE type, const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(type, strName, pParent) +{ } + +NODE_TYPE CDirectoryNodeGrouped::GetChildType() const +{ + CQueryParams params; + CollectQueryParams(params); + + VideoDbContentType type = static_cast<VideoDbContentType>(params.GetContentType()); + if (type == VideoDbContentType::MOVIES) + return NODE_TYPE_TITLE_MOVIES; + if (type == VideoDbContentType::MUSICVIDEOS) + { + if (GetType() == NODE_TYPE_ACTOR) + return NODE_TYPE_MUSICVIDEOS_ALBUM; + else + return NODE_TYPE_TITLE_MUSICVIDEOS; + } + + return NODE_TYPE_TITLE_TVSHOWS; +} + +std::string CDirectoryNodeGrouped::GetLocalizedName() const +{ + CVideoDatabase db; + if (db.Open()) + return db.GetItemById(GetContentType(), GetID()); + + return ""; +} + +bool CDirectoryNodeGrouped::GetContent(CFileItemList& items) const +{ + CVideoDatabase videodatabase; + if (!videodatabase.Open()) + return false; + + CQueryParams params; + CollectQueryParams(params); + + std::string itemType = GetContentType(params); + if (itemType.empty()) + return false; + + // make sure to translate all IDs in the path into URL parameters + CVideoDbUrl videoUrl; + if (!videoUrl.FromString(BuildPath())) + return false; + + return videodatabase.GetItems(videoUrl.ToString(), + static_cast<VideoDbContentType>(params.GetContentType()), itemType, + items); +} + +std::string CDirectoryNodeGrouped::GetContentType() const +{ + CQueryParams params; + CollectQueryParams(params); + + return GetContentType(params); +} + +std::string CDirectoryNodeGrouped::GetContentType(const CQueryParams ¶ms) const +{ + switch (GetType()) + { + case NODE_TYPE_GENRE: + return "genres"; + case NODE_TYPE_COUNTRY: + return "countries"; + case NODE_TYPE_SETS: + return "sets"; + case NODE_TYPE_TAGS: + return "tags"; + case NODE_TYPE_YEAR: + return "years"; + case NODE_TYPE_ACTOR: + if (static_cast<VideoDbContentType>(params.GetContentType()) == + VideoDbContentType::MUSICVIDEOS) + return "artists"; + else + return "actors"; + case NODE_TYPE_DIRECTOR: + return "directors"; + case NODE_TYPE_STUDIO: + return "studios"; + case NODE_TYPE_MUSICVIDEOS_ALBUM: + return "albums"; + + case NODE_TYPE_EPISODES: + case NODE_TYPE_MOVIES_OVERVIEW: + case NODE_TYPE_MUSICVIDEOS_OVERVIEW: + case NODE_TYPE_NONE: + case NODE_TYPE_OVERVIEW: + case NODE_TYPE_RECENTLY_ADDED_EPISODES: + case NODE_TYPE_RECENTLY_ADDED_MOVIES: + case NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS: + case NODE_TYPE_INPROGRESS_TVSHOWS: + case NODE_TYPE_ROOT: + case NODE_TYPE_SEASONS: + case NODE_TYPE_TITLE_MOVIES: + case NODE_TYPE_TITLE_MUSICVIDEOS: + case NODE_TYPE_TITLE_TVSHOWS: + case NODE_TYPE_TVSHOWS_OVERVIEW: + default: + break; + } + + return ""; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeGrouped.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeGrouped.h new file mode 100644 index 0000000..63a5929 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeGrouped.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeGrouped : public CDirectoryNode + { + public: + CDirectoryNodeGrouped(NODE_TYPE type, const std::string& strName, CDirectoryNode* pParent); + protected: + NODE_TYPE GetChildType() const override; + bool GetContent(CFileItemList& items) const override; + std::string GetLocalizedName() const override; + + private: + std::string GetContentType() const; + std::string GetContentType(const CQueryParams ¶ms) const; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeInProgressTvShows.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeInProgressTvShows.cpp new file mode 100644 index 0000000..044f8b3 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeInProgressTvShows.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeInProgressTvShows.h" + +#include "FileItem.h" +#include "video/VideoDatabase.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CDirectoryNodeInProgressTvShows::CDirectoryNodeInProgressTvShows(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_INPROGRESS_TVSHOWS, strName, pParent) +{ + +} + +NODE_TYPE CDirectoryNodeInProgressTvShows::GetChildType() const +{ + return NODE_TYPE_SEASONS; +} + +std::string CDirectoryNodeInProgressTvShows::GetLocalizedName() const +{ + CVideoDatabase db; + if (db.Open()) + return db.GetTvShowTitleById(GetID()); + return ""; +} + +bool CDirectoryNodeInProgressTvShows::GetContent(CFileItemList& items) const +{ + CVideoDatabase videodatabase; + if (!videodatabase.Open()) + return false; + + int details = items.HasProperty("set_videodb_details") + ? items.GetProperty("set_videodb_details").asInteger32() + : VideoDbDetailsNone; + bool bSuccess = videodatabase.GetInProgressTvShowsNav(BuildPath(), items, 0, details); + + videodatabase.Close(); + + return bSuccess; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeInProgressTvShows.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeInProgressTvShows.h new file mode 100644 index 0000000..987a166 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeInProgressTvShows.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeInProgressTvShows : public CDirectoryNode + { + public: + CDirectoryNodeInProgressTvShows(const std::string& strEntryName, CDirectoryNode* pParent); + protected: + NODE_TYPE GetChildType() const override; + bool GetContent(CFileItemList& items) const override; + std::string GetLocalizedName() const override; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMoviesOverview.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMoviesOverview.cpp new file mode 100644 index 0000000..20ef46e --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMoviesOverview.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeMoviesOverview.h" + +#include "FileItem.h" +#include "guilib/LocalizeStrings.h" +#include "utils/StringUtils.h" +#include "video/VideoDatabase.h" +#include "video/VideoDbUrl.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +Node MovieChildren[] = { + { NODE_TYPE_GENRE, "genres", 135 }, + { NODE_TYPE_TITLE_MOVIES, "titles", 10024 }, + { NODE_TYPE_YEAR, "years", 652 }, + { NODE_TYPE_ACTOR, "actors", 344 }, + { NODE_TYPE_DIRECTOR, "directors", 20348 }, + { NODE_TYPE_STUDIO, "studios", 20388 }, + { NODE_TYPE_SETS, "sets", 20434 }, + { NODE_TYPE_COUNTRY, "countries", 20451 }, + { NODE_TYPE_TAGS, "tags", 20459 } + }; + +CDirectoryNodeMoviesOverview::CDirectoryNodeMoviesOverview(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_MOVIES_OVERVIEW, strName, pParent) +{ + +} + +NODE_TYPE CDirectoryNodeMoviesOverview::GetChildType() const +{ + for (const Node& node : MovieChildren) + if (GetName() == node.id) + return node.node; + + return NODE_TYPE_NONE; +} + +std::string CDirectoryNodeMoviesOverview::GetLocalizedName() const +{ + for (const Node& node : MovieChildren) + if (GetName() == node.id) + return g_localizeStrings.Get(node.label); + return ""; +} + +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) + { + CVideoDatabase db; + if (db.Open() && !db.HasSets()) + continue; + } + + CVideoDbUrl itemUrl = videoUrl; + std::string strDir = StringUtils::Format("{}/", 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); + } + + return true; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMoviesOverview.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMoviesOverview.h new file mode 100644 index 0000000..0f32e28 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMoviesOverview.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeMoviesOverview : public CDirectoryNode + { + public: + CDirectoryNodeMoviesOverview(const std::string& strName, CDirectoryNode* pParent); + protected: + NODE_TYPE GetChildType() const override; + bool GetContent(CFileItemList& items) const override; + std::string GetLocalizedName() const override; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMusicVideosOverview.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMusicVideosOverview.cpp new file mode 100644 index 0000000..b71d8f1 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMusicVideosOverview.cpp @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeMusicVideosOverview.h" + +#include "FileItem.h" +#include "guilib/LocalizeStrings.h" +#include "utils/StringUtils.h" +#include "video/VideoDbUrl.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +Node MusicVideoChildren[] = { + { NODE_TYPE_GENRE, "genres", 135 }, + { NODE_TYPE_TITLE_MUSICVIDEOS, "titles", 10024 }, + { NODE_TYPE_YEAR, "years", 652 }, + { NODE_TYPE_ACTOR, "artists", 133 }, + { NODE_TYPE_MUSICVIDEOS_ALBUM, "albums", 132 }, + { NODE_TYPE_DIRECTOR, "directors", 20348 }, + { NODE_TYPE_STUDIO, "studios", 20388 }, + { NODE_TYPE_TAGS, "tags", 20459 } + }; + +CDirectoryNodeMusicVideosOverview::CDirectoryNodeMusicVideosOverview(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_MUSICVIDEOS_OVERVIEW, strName, pParent) +{ + +} + +NODE_TYPE CDirectoryNodeMusicVideosOverview::GetChildType() const +{ + for (const Node& node : MusicVideoChildren) + if (GetName() == node.id) + return node.node; + + return NODE_TYPE_NONE; +} + +std::string CDirectoryNodeMusicVideosOverview::GetLocalizedName() const +{ + for (const Node& node : MusicVideoChildren) + if (GetName() == node.id) + return g_localizeStrings.Get(node.label); + return ""; +} + +bool CDirectoryNodeMusicVideosOverview::GetContent(CFileItemList& items) const +{ + CVideoDbUrl videoUrl; + if (!videoUrl.FromString(BuildPath())) + return false; + + for (const Node& node : MusicVideoChildren) + { + CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(node.label))); + + CVideoDbUrl itemUrl = videoUrl; + std::string strDir = StringUtils::Format("{}/", node.id); + itemUrl.AppendPath(strDir); + pItem->SetPath(itemUrl.ToString()); + + pItem->m_bIsFolder = true; + pItem->SetCanQueue(false); + pItem->SetSpecialSort(SortSpecialOnTop); + items.Add(pItem); + } + + return true; +} + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMusicVideosOverview.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMusicVideosOverview.h new file mode 100644 index 0000000..4a79592 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeMusicVideosOverview.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeMusicVideosOverview : public CDirectoryNode + { + public: + CDirectoryNodeMusicVideosOverview(const std::string& strName, CDirectoryNode* pParent); + protected: + NODE_TYPE GetChildType() const override; + bool GetContent(CFileItemList& items) const override; + std::string GetLocalizedName() const override; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeOverview.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeOverview.cpp new file mode 100644 index 0000000..b52ae24 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeOverview.cpp @@ -0,0 +1,106 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeOverview.h" + +#include "FileItem.h" +#include "ServiceBroker.h" +#include "guilib/LocalizeStrings.h" +#include "settings/Settings.h" +#include "settings/SettingsComponent.h" +#include "video/VideoDatabase.h" + +#include <utility> + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +Node OverviewChildren[] = { + { NODE_TYPE_MOVIES_OVERVIEW, "movies", 342 }, + { NODE_TYPE_TVSHOWS_OVERVIEW, "tvshows", 20343 }, + { NODE_TYPE_MUSICVIDEOS_OVERVIEW, "musicvideos", 20389 }, + { NODE_TYPE_RECENTLY_ADDED_MOVIES, "recentlyaddedmovies", 20386 }, + { NODE_TYPE_RECENTLY_ADDED_EPISODES, "recentlyaddedepisodes", 20387 }, + { NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS, "recentlyaddedmusicvideos", 20390 }, + { NODE_TYPE_INPROGRESS_TVSHOWS, "inprogresstvshows", 626 }, + }; + +CDirectoryNodeOverview::CDirectoryNodeOverview(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_OVERVIEW, strName, pParent) +{ + +} + +NODE_TYPE CDirectoryNodeOverview::GetChildType() const +{ + for (const Node& node : OverviewChildren) + if (GetName() == node.id) + return node.node; + + return NODE_TYPE_NONE; +} + +std::string CDirectoryNodeOverview::GetLocalizedName() const +{ + for (const Node& node : OverviewChildren) + if (GetName() == node.id) + return g_localizeStrings.Get(node.label); + return ""; +} + +bool CDirectoryNodeOverview::GetContent(CFileItemList& items) const +{ + CVideoDatabase database; + database.Open(); + bool hasMovies = database.HasContent(VideoDbContentType::MOVIES); + bool hasTvShows = database.HasContent(VideoDbContentType::TVSHOWS); + bool hasMusicVideos = database.HasContent(VideoDbContentType::MUSICVIDEOS); + std::vector<std::pair<const char*, int> > vec; + if (hasMovies) + { + if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_MYVIDEOS_FLATTEN)) + vec.emplace_back("movies/titles", 342); + else + vec.emplace_back("movies", 342); // Movies + } + if (hasTvShows) + { + if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_MYVIDEOS_FLATTEN)) + vec.emplace_back("tvshows/titles", 20343); + else + vec.emplace_back("tvshows", 20343); // TV Shows + } + if (hasMusicVideos) + { + if (CServiceBroker::GetSettingsComponent()->GetSettings()->GetBool(CSettings::SETTING_MYVIDEOS_FLATTEN)) + vec.emplace_back("musicvideos/titles", 20389); + else + vec.emplace_back("musicvideos", 20389); // Music Videos + } + { + if (hasMovies) + vec.emplace_back("recentlyaddedmovies", 20386); // Recently Added Movies + if (hasTvShows) + { + vec.emplace_back("recentlyaddedepisodes", 20387); // Recently Added Episodes + vec.emplace_back("inprogresstvshows", 626); // InProgress TvShows + } + if (hasMusicVideos) + vec.emplace_back("recentlyaddedmusicvideos", 20390); // Recently Added Music Videos + } + std::string path = BuildPath(); + for (unsigned int i = 0; i < vec.size(); ++i) + { + CFileItemPtr pItem(new CFileItem(path + vec[i].first + "/", true)); + pItem->SetLabel(g_localizeStrings.Get(vec[i].second)); + pItem->SetLabelPreformatted(true); + pItem->SetCanQueue(false); + items.Add(pItem); + } + + return true; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeOverview.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeOverview.h new file mode 100644 index 0000000..5ad498b --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeOverview.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeOverview : public CDirectoryNode + { + public: + CDirectoryNodeOverview(const std::string& strName, CDirectoryNode* pParent); + protected: + NODE_TYPE GetChildType() const override; + bool GetContent(CFileItemList& items) const override; + std::string GetLocalizedName() const override; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedEpisodes.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedEpisodes.cpp new file mode 100644 index 0000000..fe50dad --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedEpisodes.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeRecentlyAddedEpisodes.h" + +#include "FileItem.h" +#include "video/VideoDatabase.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CDirectoryNodeRecentlyAddedEpisodes::CDirectoryNodeRecentlyAddedEpisodes(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_RECENTLY_ADDED_EPISODES, strName, pParent) +{ + +} + +bool CDirectoryNodeRecentlyAddedEpisodes::GetContent(CFileItemList& items) const +{ + CVideoDatabase videodatabase; + if (!videodatabase.Open()) + return false; + + int details = items.HasProperty("set_videodb_details") + ? items.GetProperty("set_videodb_details").asInteger32() + : VideoDbDetailsNone; + bool bSuccess = videodatabase.GetRecentlyAddedEpisodesNav(BuildPath(), items, 0, details); + + videodatabase.Close(); + + return bSuccess; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedEpisodes.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedEpisodes.h new file mode 100644 index 0000000..2cb1e6c --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedEpisodes.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeRecentlyAddedEpisodes : public CDirectoryNode + { + public: + CDirectoryNodeRecentlyAddedEpisodes(const std::string& strEntryName, CDirectoryNode* pParent); + protected: + bool GetContent(CFileItemList& items) const override; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMovies.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMovies.cpp new file mode 100644 index 0000000..202d6f7 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMovies.cpp @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeRecentlyAddedMovies.h" + +#include "FileItem.h" +#include "video/VideoDatabase.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CDirectoryNodeRecentlyAddedMovies::CDirectoryNodeRecentlyAddedMovies(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_RECENTLY_ADDED_MOVIES, strName, pParent) +{ + +} + +bool CDirectoryNodeRecentlyAddedMovies::GetContent(CFileItemList& items) const +{ + CVideoDatabase videodatabase; + if (!videodatabase.Open()) + return false; + + int details = items.HasProperty("set_videodb_details") + ? items.GetProperty("set_videodb_details").asInteger32() + : VideoDbDetailsNone; + bool bSuccess = videodatabase.GetRecentlyAddedMoviesNav(BuildPath(), items, 0, details); + + videodatabase.Close(); + + return bSuccess; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMovies.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMovies.h new file mode 100644 index 0000000..318e0fc --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMovies.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeRecentlyAddedMovies : public CDirectoryNode + { + public: + CDirectoryNodeRecentlyAddedMovies(const std::string& strEntryName, CDirectoryNode* pParent); + protected: + bool GetContent(CFileItemList& items) const override; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMusicVideos.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMusicVideos.cpp new file mode 100644 index 0000000..d8ba5ef --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMusicVideos.cpp @@ -0,0 +1,37 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeRecentlyAddedMusicVideos.h" + +#include "FileItem.h" +#include "video/VideoDatabase.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CDirectoryNodeRecentlyAddedMusicVideos::CDirectoryNodeRecentlyAddedMusicVideos(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS, strName, pParent) +{ + +} + +bool CDirectoryNodeRecentlyAddedMusicVideos::GetContent(CFileItemList& items) const +{ + CVideoDatabase videodatabase; + if (!videodatabase.Open()) + return false; + + int details = items.HasProperty("set_videodb_details") + ? items.GetProperty("set_videodb_details").asInteger32() + : VideoDbDetailsNone; + bool bSuccess = videodatabase.GetRecentlyAddedMusicVideosNav(BuildPath(), items, 0, details); + + videodatabase.Close(); + + return bSuccess; +} + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMusicVideos.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMusicVideos.h new file mode 100644 index 0000000..bbc9711 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRecentlyAddedMusicVideos.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeRecentlyAddedMusicVideos : public CDirectoryNode + { + public: + CDirectoryNodeRecentlyAddedMusicVideos(const std::string& strEntryName, CDirectoryNode* pParent); + protected: + bool GetContent(CFileItemList& items) const override; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRoot.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRoot.cpp new file mode 100644 index 0000000..6e1b69c --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRoot.cpp @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeRoot.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CDirectoryNodeRoot::CDirectoryNodeRoot(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_ROOT, strName, pParent) +{ + +} + +NODE_TYPE CDirectoryNodeRoot::GetChildType() const +{ + return NODE_TYPE_OVERVIEW; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRoot.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRoot.h new file mode 100644 index 0000000..99f8e6e --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeRoot.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeRoot : public CDirectoryNode + { + public: + CDirectoryNodeRoot(const std::string& strName, CDirectoryNode* pParent); + protected: + NODE_TYPE GetChildType() const override; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp new file mode 100644 index 0000000..25b8b09 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.cpp @@ -0,0 +1,81 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeSeasons.h" + +#include "FileItem.h" +#include "QueryParams.h" +#include "guilib/LocalizeStrings.h" +#include "utils/StringUtils.h" +#include "video/VideoDatabase.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CDirectoryNodeSeasons::CDirectoryNodeSeasons(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_SEASONS, strName, pParent) +{ + +} + +NODE_TYPE CDirectoryNodeSeasons::GetChildType() const +{ + return NODE_TYPE_EPISODES; +} + +std::string CDirectoryNodeSeasons::GetLocalizedName() const +{ + switch (GetID()) + { + case 0: + return g_localizeStrings.Get(20381); // Specials + case -1: + return g_localizeStrings.Get(20366); // All Seasons + case -2: + { + CDirectoryNode* pParent = GetParent(); + if (pParent) + return pParent->GetLocalizedName(); + return ""; + } + default: + return GetSeasonTitle(); + } +} + +std::string CDirectoryNodeSeasons::GetSeasonTitle() const +{ + std::string season; + CVideoDatabase db; + if (db.Open()) + { + CQueryParams params; + CollectQueryParams(params); + + season = db.GetTvShowNamedSeasonById(params.GetTvShowId(), params.GetSeason()); + } + if (season.empty()) + season = StringUtils::Format(g_localizeStrings.Get(20358), GetID()); // Season <n> + + return season; +} + +bool CDirectoryNodeSeasons::GetContent(CFileItemList& items) const +{ + CVideoDatabase videodatabase; + if (!videodatabase.Open()) + return false; + + CQueryParams params; + CollectQueryParams(params); + + bool bSuccess=videodatabase.GetSeasonsNav(BuildPath(), items, params.GetActorId(), params.GetDirectorId(), params.GetGenreId(), params.GetYear(), params.GetTvShowId()); + + videodatabase.Close(); + + return bSuccess; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.h new file mode 100644 index 0000000..d5dd3a1 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeSeasons.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeSeasons : public CDirectoryNode + { + public: + CDirectoryNodeSeasons(const std::string& strName, CDirectoryNode* pParent); + protected: + NODE_TYPE GetChildType() const override; + bool GetContent(CFileItemList& items) const override; + std::string GetLocalizedName() const override; + + private: + /*! + * \brief Get the title of choosen season. + * \return The season title. + */ + std::string GetSeasonTitle() const; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMovies.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMovies.cpp new file mode 100644 index 0000000..45a83ce --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMovies.cpp @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeTitleMovies.h" + +#include "FileItem.h" +#include "QueryParams.h" +#include "video/VideoDatabase.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CDirectoryNodeTitleMovies::CDirectoryNodeTitleMovies(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_TITLE_MOVIES, strName, pParent) +{ + +} + +bool CDirectoryNodeTitleMovies::GetContent(CFileItemList& items) const +{ + CVideoDatabase videodatabase; + if (!videodatabase.Open()) + return false; + + CQueryParams params; + CollectQueryParams(params); + + int details = items.HasProperty("set_videodb_details") + ? items.GetProperty("set_videodb_details").asInteger32() + : VideoDbDetailsNone; + + bool bSuccess = videodatabase.GetMoviesNav( + BuildPath(), items, params.GetGenreId(), params.GetYear(), params.GetActorId(), + params.GetDirectorId(), params.GetStudioId(), params.GetCountryId(), params.GetSetId(), + params.GetTagId(), SortDescription(), details); + + videodatabase.Close(); + + return bSuccess; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMovies.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMovies.h new file mode 100644 index 0000000..7166ac8 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMovies.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeTitleMovies : public CDirectoryNode + { + public: + CDirectoryNodeTitleMovies(const std::string& strEntryName, CDirectoryNode* pParent); + protected: + bool GetContent(CFileItemList& items) const override; + }; + } +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMusicVideos.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMusicVideos.cpp new file mode 100644 index 0000000..95fe300 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMusicVideos.cpp @@ -0,0 +1,43 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeTitleMusicVideos.h" + +#include "FileItem.h" +#include "QueryParams.h" +#include "video/VideoDatabase.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CDirectoryNodeTitleMusicVideos::CDirectoryNodeTitleMusicVideos(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_TITLE_MUSICVIDEOS, strName, pParent) +{ + +} + +bool CDirectoryNodeTitleMusicVideos::GetContent(CFileItemList& items) const +{ + CVideoDatabase videodatabase; + if (!videodatabase.Open()) + return false; + + CQueryParams params; + CollectQueryParams(params); + + int details = items.HasProperty("set_videodb_details") + ? items.GetProperty("set_videodb_details").asInteger32() + : VideoDbDetailsNone; + bool bSuccess = videodatabase.GetMusicVideosNav( + BuildPath(), items, params.GetGenreId(), params.GetYear(), params.GetActorId(), + params.GetDirectorId(), params.GetStudioId(), params.GetAlbumId(), params.GetTagId(), + SortDescription(), details); + + videodatabase.Close(); + + return bSuccess; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMusicVideos.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMusicVideos.h new file mode 100644 index 0000000..88c54fe --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleMusicVideos.h @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeTitleMusicVideos : public CDirectoryNode + { + public: + CDirectoryNodeTitleMusicVideos(const std::string& strEntryName, CDirectoryNode* pParent); + protected: + bool GetContent(CFileItemList& item) const override; + }; + } +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleTvShows.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleTvShows.cpp new file mode 100644 index 0000000..b1a247c --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleTvShows.cpp @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeTitleTvShows.h" + +#include "FileItem.h" +#include "QueryParams.h" +#include "video/VideoDatabase.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CDirectoryNodeTitleTvShows::CDirectoryNodeTitleTvShows(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_TITLE_TVSHOWS, strName, pParent) +{ + +} + +NODE_TYPE CDirectoryNodeTitleTvShows::GetChildType() const +{ + return NODE_TYPE_SEASONS; +} + +std::string CDirectoryNodeTitleTvShows::GetLocalizedName() const +{ + CVideoDatabase db; + if (db.Open()) + return db.GetTvShowTitleById(GetID()); + return ""; +} + +bool CDirectoryNodeTitleTvShows::GetContent(CFileItemList& items) const +{ + CVideoDatabase videodatabase; + if (!videodatabase.Open()) + return false; + + CQueryParams params; + CollectQueryParams(params); + + int details = items.HasProperty("set_videodb_details") + ? items.GetProperty("set_videodb_details").asInteger32() + : VideoDbDetailsNone; + + bool bSuccess = videodatabase.GetTvShowsNav( + BuildPath(), items, params.GetGenreId(), params.GetYear(), params.GetActorId(), + params.GetDirectorId(), params.GetStudioId(), params.GetTagId(), SortDescription(), details); + + videodatabase.Close(); + + return bSuccess; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleTvShows.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleTvShows.h new file mode 100644 index 0000000..697d572 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTitleTvShows.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeTitleTvShows : public CDirectoryNode + { + public: + CDirectoryNodeTitleTvShows(const std::string& strName, CDirectoryNode* pParent); + protected: + NODE_TYPE GetChildType() const override; + bool GetContent(CFileItemList& items) const override; + std::string GetLocalizedName() const override; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTvShowsOverview.cpp b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTvShowsOverview.cpp new file mode 100644 index 0000000..07e5ff4 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTvShowsOverview.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "DirectoryNodeTvShowsOverview.h" + +#include "FileItem.h" +#include "guilib/LocalizeStrings.h" +#include "utils/StringUtils.h" +#include "video/VideoDbUrl.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +Node TvShowChildren[] = { + { NODE_TYPE_GENRE, "genres", 135 }, + { NODE_TYPE_TITLE_TVSHOWS, "titles", 10024 }, + { NODE_TYPE_YEAR, "years", 652 }, + { NODE_TYPE_ACTOR, "actors", 344 }, + { NODE_TYPE_STUDIO, "studios", 20388 }, + { NODE_TYPE_TAGS, "tags", 20459 } + }; + +CDirectoryNodeTvShowsOverview::CDirectoryNodeTvShowsOverview(const std::string& strName, CDirectoryNode* pParent) + : CDirectoryNode(NODE_TYPE_TVSHOWS_OVERVIEW, strName, pParent) +{ + +} + +NODE_TYPE CDirectoryNodeTvShowsOverview::GetChildType() const +{ + if (GetName()=="0") + return NODE_TYPE_EPISODES; + + for (const Node& node : TvShowChildren) + if (GetName() == node.id) + return node.node; + + return NODE_TYPE_NONE; +} + +std::string CDirectoryNodeTvShowsOverview::GetLocalizedName() const +{ + for (const Node& node : TvShowChildren) + if (GetName() == node.id) + return g_localizeStrings.Get(node.label); + return ""; +} + +bool CDirectoryNodeTvShowsOverview::GetContent(CFileItemList& items) const +{ + CVideoDbUrl videoUrl; + if (!videoUrl.FromString(BuildPath())) + return false; + + for (const Node& node : TvShowChildren) + { + CFileItemPtr pItem(new CFileItem(g_localizeStrings.Get(node.label))); + + CVideoDbUrl itemUrl = videoUrl; + std::string strDir = StringUtils::Format("{}/", node.id); + itemUrl.AppendPath(strDir); + pItem->SetPath(itemUrl.ToString()); + + pItem->m_bIsFolder = true; + pItem->SetCanQueue(false); + items.Add(pItem); + } + + return true; +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTvShowsOverview.h b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTvShowsOverview.h new file mode 100644 index 0000000..4394e1f --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/DirectoryNodeTvShowsOverview.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CDirectoryNodeTvShowsOverview : public CDirectoryNode + { + public: + CDirectoryNodeTvShowsOverview(const std::string& strName, CDirectoryNode* pParent); + protected: + NODE_TYPE GetChildType() const override; + bool GetContent(CFileItemList& items) const override; + std::string GetLocalizedName() const override; + }; + } +} + + diff --git a/xbmc/filesystem/VideoDatabaseDirectory/QueryParams.cpp b/xbmc/filesystem/VideoDatabaseDirectory/QueryParams.cpp new file mode 100644 index 0000000..d4c78ff --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/QueryParams.cpp @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2016-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#include "QueryParams.h" + +#include "video/VideoDatabase.h" + +using namespace XFILE::VIDEODATABASEDIRECTORY; + +CQueryParams::CQueryParams() +{ + m_idMovie = -1; + m_idGenre = -1; + m_idCountry = -1; + m_idYear = -1; + m_idActor = -1; + m_idDirector = -1; + m_idContent = static_cast<long>(VideoDbContentType::UNKNOWN); + m_idShow = -1; + m_idSeason = -1; + m_idEpisode = -1; + m_idStudio = -1; + m_idMVideo = -1; + m_idAlbum = -1; + m_idSet = -1; + m_idTag = -1; +} + +void CQueryParams::SetQueryParam(NODE_TYPE NodeType, const std::string& strNodeName) +{ + long idDb=atol(strNodeName.c_str()); + + switch (NodeType) + { + case NODE_TYPE_OVERVIEW: + if (strNodeName == "tvshows") + m_idContent = static_cast<long>(VideoDbContentType::TVSHOWS); + else if (strNodeName == "musicvideos") + m_idContent = static_cast<long>(VideoDbContentType::MUSICVIDEOS); + else + m_idContent = static_cast<long>(VideoDbContentType::MOVIES); + break; + case NODE_TYPE_GENRE: + m_idGenre = idDb; + break; + case NODE_TYPE_COUNTRY: + m_idCountry = idDb; + break; + case NODE_TYPE_YEAR: + m_idYear = idDb; + break; + case NODE_TYPE_ACTOR: + m_idActor = idDb; + break; + case NODE_TYPE_DIRECTOR: + m_idDirector = idDb; + break; + case NODE_TYPE_TITLE_MOVIES: + case NODE_TYPE_RECENTLY_ADDED_MOVIES: + m_idMovie = idDb; + break; + case NODE_TYPE_TITLE_TVSHOWS: + case NODE_TYPE_INPROGRESS_TVSHOWS: + m_idShow = idDb; + break; + case NODE_TYPE_SEASONS: + m_idSeason = idDb; + break; + case NODE_TYPE_EPISODES: + case NODE_TYPE_RECENTLY_ADDED_EPISODES: + m_idEpisode = idDb; + break; + case NODE_TYPE_STUDIO: + m_idStudio = idDb; + break; + case NODE_TYPE_TITLE_MUSICVIDEOS: + case NODE_TYPE_RECENTLY_ADDED_MUSICVIDEOS: + m_idMVideo = idDb; + break; + case NODE_TYPE_MUSICVIDEOS_ALBUM: + m_idAlbum = idDb; + break; + case NODE_TYPE_SETS: + m_idSet = idDb; + break; + case NODE_TYPE_TAGS: + m_idTag = idDb; + break; + default: + break; + } +} diff --git a/xbmc/filesystem/VideoDatabaseDirectory/QueryParams.h b/xbmc/filesystem/VideoDatabaseDirectory/QueryParams.h new file mode 100644 index 0000000..f9d7e45 --- /dev/null +++ b/xbmc/filesystem/VideoDatabaseDirectory/QueryParams.h @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2005-2018 Team Kodi + * This file is part of Kodi - https://kodi.tv + * + * SPDX-License-Identifier: GPL-2.0-or-later + * See LICENSES/README.md for more information. + */ + +#pragma once + +#include "DirectoryNode.h" + +namespace XFILE +{ + namespace VIDEODATABASEDIRECTORY + { + class CQueryParams + { + public: + CQueryParams(); + long GetContentType() const { return m_idContent; } + long GetMovieId() const { return m_idMovie; } + long GetYear() const { return m_idYear; } + long GetGenreId() const { return m_idGenre; } + long GetCountryId() const { return m_idCountry; } + long GetActorId() const { return m_idActor; } + long GetAlbumId() const { return m_idAlbum; } + long GetDirectorId() const { return m_idDirector; } + long GetTvShowId() const { return m_idShow; } + long GetSeason() const { return m_idSeason; } + long GetEpisodeId() const { return m_idEpisode; } + long GetStudioId() const { return m_idStudio; } + long GetMVideoId() const { return m_idMVideo; } + long GetSetId() const { return m_idSet; } + long GetTagId() const { return m_idTag; } + + protected: + void SetQueryParam(NODE_TYPE NodeType, const std::string& strNodeName); + + friend class CDirectoryNode; + private: + long m_idContent; + long m_idMovie; + long m_idGenre; + long m_idCountry; + long m_idYear; + long m_idActor; + long m_idDirector; + long m_idShow; + long m_idSeason; + long m_idEpisode; + long m_idStudio; + long m_idMVideo; + long m_idAlbum; + long m_idSet; + long m_idTag; + }; + } +} |