From 4bf454247a21b684f2bb0ac763adeea18a86d153 Mon Sep 17 00:00:00 2001 From: chriszero Date: Thu, 9 Apr 2015 20:41:33 +0200 Subject: more tokens --- Directory.cpp | 37 ++++++++++++++++------ Directory.h | 7 ++++- MediaContainer.cpp | 14 +++++++++ MediaContainer.h | 5 +++ skins/blackhole/xmlfiles/plug-plex-root.xml | 48 ++++++++++++++++++----------- 5 files changed, 83 insertions(+), 28 deletions(-) diff --git a/Directory.cpp b/Directory.cpp index a598a8f..eeb8c1d 100644 --- a/Directory.cpp +++ b/Directory.cpp @@ -15,6 +15,10 @@ Directory::Directory(Poco::XML::Node* pNode, PlexServer* Server, MediaContainer* m_bAllowSync = GetNodeValueAsBool(pAttribs->getNamedItem("allowSync")); m_iIndex = GetNodeValueAsInt(pAttribs->getNamedItem("index")); + m_iLeafCount = GetNodeValueAsInt(pAttribs->getNamedItem("leafCount")); + m_iViewedLeafCount = GetNodeValueAsInt(pAttribs->getNamedItem("viewedLeafCount")); + m_iChildCount = GetNodeValueAsInt(pAttribs->getNamedItem("childCount")); + m_fRating = GetNodeValueAsDouble(pAttribs->getNamedItem("rating")); m_iYear = GetNodeValueAsInt(pAttribs->getNamedItem("year")); m_sArt = GetNodeValue(pAttribs->getNamedItem("art")); m_sThumb = GetNodeValue(pAttribs->getNamedItem("thumb")); @@ -28,6 +32,7 @@ Directory::Directory(Poco::XML::Node* pNode, PlexServer* Server, MediaContainer* m_tUpdatedAt = GetNodeValueAsTimeStamp(pAttribs->getNamedItem("updatedAt")); m_tCreatedAt = GetNodeValueAsTimeStamp(pAttribs->getNamedItem("createdAt")); m_eType = GetNodeValueAsMediaType(pAttribs->getNamedItem("type")); + m_sSummary = GetNodeValue(pAttribs->getNamedItem("summary")); pAttribs->release(); } @@ -51,24 +56,30 @@ void Directory::AddTokens(std::shared_ptr grid, bool clear, std::fu // Thumb, Cover, Episodepicture bool cached = false; - std::string thumb = cPictureCache::GetInstance().GetPath(ThumbUri(), Config::GetInstance().ThumbWidth(), Config::GetInstance().ThumbHeight(), cached, OnCached, this); + if(!ThumbUri().empty()) { + std::string thumb = cPictureCache::GetInstance().GetPath(ThumbUri(), Config::GetInstance().ThumbWidth(), Config::GetInstance().ThumbHeight(), cached, OnCached, this); + if (cached) grid->AddStringToken("thumb", thumb); + } grid->AddIntToken("hasthumb", cached); - if (cached) grid->AddStringToken("thumb", thumb); // Fanart cached = false; - std::string art = cPictureCache::GetInstance().GetPath(ArtUri(), Config::GetInstance().ArtWidth(), Config::GetInstance().ArtHeight(), cached); + if(!ArtUri().empty()) { + std::string art = cPictureCache::GetInstance().GetPath(ArtUri(), Config::GetInstance().ArtWidth(), Config::GetInstance().ArtHeight(), cached); + if (cached) grid->AddStringToken("art", art); + } grid->AddIntToken("hasart", cached); - if (cached) grid->AddStringToken("art", art); if(m_eType == MediaType::SHOW) { grid->AddIntToken("isshow", true); + grid->AddStringToken("summary", m_sSummary); } if(m_eType == MediaType::SEASON) { grid->AddIntToken("isseason", true); + if(m_pParent) grid->AddStringToken("summary", m_pParent->m_sSummary); } - + // Banner, Seriesbanner if(m_pParent && !m_pParent->m_sBanner.empty()) { cached = false; @@ -82,14 +93,22 @@ void Directory::AddTokens(std::shared_ptr grid, bool clear, std::fu std::string Directory::ArtUri() { - if(m_sArt.find("http://") != std::string::npos) return m_sArt; - return m_pServer->GetUri() + m_sArt; + if(!m_sArt.empty()) { + if(m_sArt.find("http://") != std::string::npos) return m_sArt; + return m_pServer->GetUri() + m_sArt; + } + if(m_pParent) return m_pParent->ArtUri(); + return ""; } std::string Directory::ThumbUri() { - if(m_sThumb.find("http://") != std::string::npos) return m_sThumb; - return m_pServer->GetUri() + m_sThumb; + if(!m_sThumb.empty()) { + if(m_sThumb.find("http://") != std::string::npos) return m_sThumb; + return m_pServer->GetUri() + m_sThumb; + } + if(m_pParent) return m_pParent->ThumbUri(); + return ""; } } diff --git a/Directory.h b/Directory.h index e97b241..8ccea87 100644 --- a/Directory.h +++ b/Directory.h @@ -38,8 +38,13 @@ public: public: bool m_bAllowSync; - int m_iIndex; + int m_iIndex; // Season, Episode number int m_iYear; + int m_iLeafCount; // Total number of Episodes + int m_iViewedLeafCount; // Watched Episodes + int m_iChildCount; // Number of Seasons + double m_fRating; + std::string m_sSummary; std::string m_sTitle; std::string m_sTitle1; std::string m_sTitle2; diff --git a/MediaContainer.cpp b/MediaContainer.cpp index 959c537..8f68300 100644 --- a/MediaContainer.cpp +++ b/MediaContainer.cpp @@ -33,6 +33,8 @@ MediaContainer::MediaContainer(std::istream* response, PlexServer* Server) m_bAllowSync = GetNodeValueAsBool(pAttribs->getNamedItem("allowSync")); m_sArt = GetNodeValue(pAttribs->getNamedItem("art")); m_sSummary = GetNodeValue(pAttribs->getNamedItem("summary")); + m_iParentIndex = GetNodeValueAsInt(pAttribs->getNamedItem("parentIndex")); + m_iParentYear = GetNodeValueAsInt(pAttribs->getNamedItem("parentYear")); pAttribs->release(); } else if(Poco::icompare(pNode->nodeName(), "Directory") == 0) { @@ -49,6 +51,18 @@ MediaContainer::MediaContainer(std::istream* response, PlexServer* Server) } } +std::string MediaContainer::ArtUri() +{ + if(m_sArt.find("http://") != std::string::npos) return m_sArt; + return m_pServer->GetUri() + m_sArt; +} + +std::string MediaContainer::ThumbUri() +{ + if(m_sThumb.find("http://") != std::string::npos) return m_sThumb; + return m_pServer->GetUri() + m_sThumb; +} + void MediaContainer::PreCache() { bool foo; diff --git a/MediaContainer.h b/MediaContainer.h index 0a538ed..14fb29e 100644 --- a/MediaContainer.h +++ b/MediaContainer.h @@ -62,8 +62,13 @@ public: int m_iSize; std::string m_sSummary; int m_iParentIndex; + std::string m_sParentTitle; + int m_iParentYear; + PlexServer* m_pServer; + std::string ThumbUri(); + std::string ArtUri(); void PreCache(); }; diff --git a/skins/blackhole/xmlfiles/plug-plex-root.xml b/skins/blackhole/xmlfiles/plug-plex-root.xml index 67c5a2c..b1c0d83 100644 --- a/skins/blackhole/xmlfiles/plug-plex-root.xml +++ b/skins/blackhole/xmlfiles/plug-plex-root.xml @@ -60,28 +60,40 @@