summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Directory.cpp91
-rw-r--r--Directory.h11
-rw-r--r--PVideo.cpp44
-rw-r--r--PVideo.h1
-rw-r--r--XmlObject.cpp30
-rw-r--r--XmlObject.h3
-rw-r--r--templates/plug-plex-root.xml23
7 files changed, 164 insertions, 39 deletions
diff --git a/Directory.cpp b/Directory.cpp
index 83a5f22..4c24b7a 100644
--- a/Directory.cpp
+++ b/Directory.cpp
@@ -10,31 +10,48 @@ Directory::Directory(Poco::XML::Node* pNode, PlexServer* Server, MediaContainer*
{
m_pParent = parent;
m_pServer = Server;
- if(Poco::icompare(pNode->nodeName(), "Directory") == 0) {
- Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pNode->attributes();
-
- 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"));
- m_sKey = GetNodeValue(pAttribs->getNamedItem("key"));
- m_sTitle = GetNodeValue(pAttribs->getNamedItem("title"));
- m_sTitle1 = GetNodeValue(pAttribs->getNamedItem("title1"));
- m_sTitle2 = GetNodeValue(pAttribs->getNamedItem("title2"));
- m_sComposite = GetNodeValue(pAttribs->getNamedItem("composite"));
- m_sLanguage = GetNodeValue(pAttribs->getNamedItem("language"));
- m_sUuid = GetNodeValue(pAttribs->getNamedItem("uuid"));
- 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();
+
+ NodeIterator it(pNode, Poco::XML::NodeFilter::SHOW_ALL);
+ Poco::XML::Node* pChildNode = it.nextNode();
+
+ while(pChildNode) {
+ if(Poco::icompare(pChildNode->nodeName(), "Directory") == 0) {
+ Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pChildNode->attributes();
+
+ 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"));
+ m_sKey = GetNodeValue(pAttribs->getNamedItem("key"));
+ m_sTitle = GetNodeValue(pAttribs->getNamedItem("title"));
+ m_sTitle1 = GetNodeValue(pAttribs->getNamedItem("title1"));
+ m_sTitle2 = GetNodeValue(pAttribs->getNamedItem("title2"));
+ m_sComposite = GetNodeValue(pAttribs->getNamedItem("composite"));
+ m_sLanguage = GetNodeValue(pAttribs->getNamedItem("language"));
+ m_sUuid = GetNodeValue(pAttribs->getNamedItem("uuid"));
+ m_tUpdatedAt = GetNodeValueAsTimeStamp(pAttribs->getNamedItem("updatedAt"));
+ m_tCreatedAt = GetNodeValueAsTimeStamp(pAttribs->getNamedItem("createdAt"));
+ m_eType = GetNodeValueAsMediaType(pAttribs->getNamedItem("type"));
+ m_sSummary = GetNodeValue(pAttribs->getNamedItem("summary"));
+ m_sStudio = GetNodeValue(pAttribs->getNamedItem("studio"));
+
+ pAttribs->release();
+ } else if(Poco::icompare(pChildNode->nodeName(), "Genre") == 0) {
+ Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pChildNode->attributes();
+ m_vGenre.push_back(GetNodeValue(pAttribs->getNamedItem("tag")));
+ pAttribs->release();
+
+ } else if(Poco::icompare(pChildNode->nodeName(), "Role") == 0) {
+ Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pChildNode->attributes();
+ m_vRole.push_back(GetNodeValue(pAttribs->getNamedItem("tag")));
+ pAttribs->release();
+ }
+ pChildNode = it.nextNode();
}
if(m_sTitle2.empty()) m_sTitle2 = parent->m_sTitle2;
}
@@ -79,12 +96,36 @@ void Directory::AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> grid, bo
if(m_eType == MediaType::SHOW) {
grid->AddIntToken("isshow", true);
grid->AddStringToken("summary", m_sSummary);
+ grid->AddIntToken("leafCount", m_iLeafCount);
+ grid->AddIntToken("viewedLeafCount", m_iViewedLeafCount);
+ grid->AddIntToken("childCount", m_iChildCount);
+ grid->AddIntToken("rating", m_fRating*10);
+ grid->AddStringToken("ratingstring", Poco::format("%.1f", m_fRating));
+ grid->AddStringToken("studio", m_sStudio);
+
+ map<string, string> roles;
+ for(auto it = m_vRole.begin(); it != m_vRole.end(); it++) {
+ roles["actor"] = *it;
+ }
+ grid->AddLoopToken("roles", roles);
+
+ map<string, string> gernes;
+ for(auto it = m_vGenre.begin(); it != m_vGenre.end(); it++) {
+ roles["genre"] = *it;
+ }
+ grid->AddLoopToken("genres", gernes);
+
+ grid->AddIntToken("year", m_iYear);
}
if(m_eType == MediaType::SEASON) {
grid->AddIntToken("isseason", true);
if(m_pParent) grid->AddStringToken("summary", m_pParent->m_sSummary);
grid->AddIntToken("season", m_iIndex);
+ grid->AddIntToken("leafCount", m_iLeafCount);
+ grid->AddIntToken("viewedLeafCount", m_iViewedLeafCount);
+ grid->AddStringToken("seriestitle", m_pParent->m_sParentTitle);
+ grid->AddIntToken("year", m_pParent->m_iParentYear);
}
// Banner, Seriesbanner
diff --git a/Directory.h b/Directory.h
index 89406e6..1c4a7a0 100644
--- a/Directory.h
+++ b/Directory.h
@@ -30,9 +30,9 @@ using Poco::Exception;
namespace plexclient
{
class MediaContainer;
-
+
class Directory: private XmlObject, public cGridElement
-{
+{
public:
Directory(Poco::XML::Node* pNode, PlexServer* Server, MediaContainer* parent);
@@ -53,13 +53,18 @@ public:
std::string m_sUuid;
std::string m_sArt;
std::string m_sThumb;
+ std::string m_sStudio;
Poco::Timestamp m_tUpdatedAt;
Poco::Timestamp m_tCreatedAt;
std::string m_sKey;
+
+ std::vector<std::string> m_vGenre;
+ std::vector<std::string> m_vRole;
+
MediaType m_eType;
PlexServer* m_pServer;
MediaContainer* m_pParent;
-
+
virtual std::string GetTitle();
std::string ArtUri();
std::string ThumbUri();
diff --git a/PVideo.cpp b/PVideo.cpp
index 579db3c..f3544b2 100644
--- a/PVideo.cpp
+++ b/PVideo.cpp
@@ -100,23 +100,41 @@ void Video::Parse(Poco::XML::Node* pNode)
m_dRating = GetNodeValueAsDouble(pAttribs->getNamedItem("rating"));
m_tAddedAt = GetNodeValueAsTimeStamp(pAttribs->getNamedItem("addedAt"));
m_tUpdatedAt = GetNodeValueAsTimeStamp(pAttribs->getNamedItem("updatedAt"));
+ m_tOriginallyAvailableAt = GetNodeValueAsDateTime(pAttribs->getNamedItem("originallyAvailableAt"));
pAttribs->release();
} else if(Poco::icompare(pChildNode->nodeName(), "Media") == 0) {
m_Media = Media(pChildNode);
} else if(Poco::icompare(pChildNode->nodeName(), "Genre") == 0) {
- m_vGenre.push_back(GetNodeValue(pChildNode));
+ Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pChildNode->attributes();
+ m_vGenre.push_back(GetNodeValue(pAttribs->getNamedItem("tag")));
+ pAttribs->release();
+
} else if(Poco::icompare(pChildNode->nodeName(), "Writer") == 0) {
+ Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pChildNode->attributes();
m_vWriter.push_back(GetNodeValue(pChildNode));
+ pAttribs->release();
+
} else if(Poco::icompare(pChildNode->nodeName(), "Director") == 0) {
- m_vDirector.push_back(GetNodeValue(pChildNode));
+ Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pChildNode->attributes();
+ m_vDirector.push_back(GetNodeValue(pAttribs->getNamedItem("tag")));
+ pAttribs->release();
+
} else if(Poco::icompare(pChildNode->nodeName(), "Country") == 0) {
- m_vCountry.push_back(GetNodeValue(pChildNode));
+ Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pChildNode->attributes();
+ m_vCountry.push_back(GetNodeValue(pAttribs->getNamedItem("tag")));
+ pAttribs->release();
+
} else if(Poco::icompare(pChildNode->nodeName(), "Role") == 0) {
- m_vRole.push_back(GetNodeValue(pChildNode));
+ Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pChildNode->attributes();
+ m_vRole.push_back(GetNodeValue(pAttribs->getNamedItem("tag")));
+ pAttribs->release();
+
} else if(Poco::icompare(pChildNode->nodeName(), "Collection") == 0) {
- m_sCollection = GetNodeValue(pChildNode);
+ Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pChildNode->attributes();
+ m_sCollection = GetNodeValue(pAttribs->getNamedItem("tag"));
+ pAttribs->release();
}
pChildNode = it.nextNode();
}
@@ -243,6 +261,22 @@ void Video::AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> grid, bool c
if(m_tType == MediaType::MOVIE || m_tType == MediaType::CLIP) {
grid->AddIntToken("ismovie", true);
}
+
+ map<string, string> roles;
+ for(auto it = m_vRole.begin(); it != m_vRole.end(); it++) {
+ roles["actor"] = *it;
+ }
+ grid->AddLoopToken("roles", roles);
+
+ map<string, string> gernes;
+ for(auto it = m_vGenre.begin(); it != m_vGenre.end(); it++) {
+ roles["genre"] = *it;
+ }
+ grid->AddLoopToken("genres", gernes);
+
+ grid->AddIntToken("originallyAvailableYear", m_tOriginallyAvailableAt.year());
+ grid->AddIntToken("originallyAvailableMonth", m_tOriginallyAvailableAt.month());
+ grid->AddIntToken("originallyAvailableDay", m_tOriginallyAvailableAt.day());
if(m_tType == MediaType::EPISODE) {
grid->AddIntToken("isepisode", true);
diff --git a/PVideo.h b/PVideo.h
index 92d992a..46c170f 100644
--- a/PVideo.h
+++ b/PVideo.h
@@ -67,6 +67,7 @@ public:
double m_dRating;
Poco::Timestamp m_tAddedAt;
Poco::Timestamp m_tUpdatedAt;
+ Poco::DateTime m_tOriginallyAvailableAt;
std::vector<std::string> m_vGenre;
std::vector<std::string> m_vWriter;
diff --git a/XmlObject.cpp b/XmlObject.cpp
index d103113..e934980 100644
--- a/XmlObject.cpp
+++ b/XmlObject.cpp
@@ -66,6 +66,20 @@ Poco::Timestamp XmlObject::GetNodeValueAsTimeStamp(Poco::XML::Node* pNode)
return value;
}
+Poco::DateTime XmlObject::GetNodeValueAsDateTime(Poco::XML::Node* pNode)
+{
+ Poco::DateTime value;
+ if(pNode != 0) {
+ try {
+ std::string format = "%Y-%m-%d";
+ std::string val = pNode->nodeValue();
+ int diff;
+ value = Poco::DateTimeParser::parse(format, val, diff);
+ } catch (Poco::Exception) {}
+ }
+ return value;
+}
+
MediaType XmlObject::GetNodeValueAsMediaType(Poco::XML::Node* pNode)
{
MediaType type = UNDEF;
@@ -98,10 +112,18 @@ StreamType XmlObject::GetNodeValueAsStreamType(Poco::XML::Node* pNode)
if(pNode != 0) {
int iType = GetNodeValueAsInt(pNode);
switch(iType) {
- case 1: type = sVIDEO; break;
- case 2: type = sAUDIO; break;
- case 3: type = sSUBTITLE; break;
- default: type = sUNDEF; break;
+ case 1:
+ type = sVIDEO;
+ break;
+ case 2:
+ type = sAUDIO;
+ break;
+ case 3:
+ type = sSUBTITLE;
+ break;
+ default:
+ type = sUNDEF;
+ break;
}
}
return type;
diff --git a/XmlObject.h b/XmlObject.h
index a8619b6..9e65984 100644
--- a/XmlObject.h
+++ b/XmlObject.h
@@ -5,6 +5,8 @@
#include <Poco/DOM/Document.h>
#include <Poco/Timestamp.h>
+#include <Poco/DateTime.h>
+#include <Poco/DateTimeParser.h>
#include <Poco/String.h>
#include <Poco/Exception.h>
@@ -23,6 +25,7 @@ protected:
static double GetNodeValueAsDouble(Poco::XML::Node* pNode);
static bool GetNodeValueAsBool(Poco::XML::Node* pNode);
static Poco::Timestamp GetNodeValueAsTimeStamp(Poco::XML::Node* pNode);
+ static Poco::DateTime GetNodeValueAsDateTime(Poco::XML::Node* pNode);
static MediaType GetNodeValueAsMediaType(Poco::XML::Node* pNode);
static StreamType GetNodeValueAsStreamType(Poco::XML::Node* pNode);
diff --git a/templates/plug-plex-root.xml b/templates/plug-plex-root.xml
index 7959dac..411dfc1 100644
--- a/templates/plug-plex-root.xml
+++ b/templates/plug-plex-root.xml
@@ -67,6 +67,7 @@
Following tokens are avaliable if the item is a directory or video
+ {year} Year of production
{hasthumb} bool
{thumb} string, Image/Cover
{hasart} bool
@@ -79,13 +80,25 @@
{isshow} Condition, Show/Series
{summary} Description, plot, summary
+ {leafCount} Total leafs, episodes
+ {viewedLeafCount} viewed Leafs, episodes
+ {childCount} total childs, seasons
+ {rating} int, starrating 0.0 - 10.0 multiplied by 10 -> 0 - 100
+ {ratingstring} string, rating formated as double %.1f
+ {studio} Studio
+ {roles[actor]} looptoken
+ {genres[genre]} looptoken
{isseason} Condition
{summary} Description, plot, summary
+ {seriestitle} Seriestitle
+ {leafCount} Total leafs, episodes
+ {viewedLeafCount} viewed Leafs, episodes
+ {childCount} total childs, seasons
If the item is a video following tokens are avaliable
The item is a video if one of the following tokens are set: {ismovie}, {isepisode}
- {contentrating} string, FSK, PEGI
+ {contentrating} string, FSK, PEGI -> eg. de/16
{rating} int, starrating 0.0 - 10.0 multiplied by 10 -> 0 - 100
{ratingstring} string, rating formated as double %.1f
{viewoffset} int, minutes, last viewed position
@@ -93,9 +106,15 @@
{orginaltitle} original title
{summary} Description, plot, summary
{studio} Studio
- {year} Year of production
{viewCount} Unseen if less than 1
+ {originallyAvailableYear} Year of release/first aired
+ {originallyAvailableMonth} Month of release/first aired
+ {originallyAvailableDay} Day of release/first aired
+
+ {roles[actor]} looptoken
+ {genres[genre]} looptoken
+
{videoResolution} string (sd, 720, 1080)
{bitrate} int
{width} int