diff options
-rw-r--r-- | PVideo.cpp | 48 | ||||
-rw-r--r-- | PVideo.h | 3 |
2 files changed, 51 insertions, 0 deletions
@@ -74,6 +74,7 @@ void Video::Parse(Poco::XML::Node* pNode) Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pNode->attributes(); m_iRatingKey = GetNodeValueAsInt(pAttribs->getNamedItem("ratingKey")); + m_iViewCount = GetNodeValueAsInt(pAttribs->getNamedItem("viewCount")); m_iIndex = GetNodeValueAsInt(pAttribs->getNamedItem("index")); m_iParentIndex = GetNodeValueAsInt(pAttribs->getNamedItem("parentIndex")); m_sKey = GetNodeValue(pAttribs->getNamedItem("key")); @@ -157,4 +158,51 @@ bool Video::SetStream(Stream* stream) } } +bool Video::SetUnwatched() +{ + try { + Poco::Net::HTTPClientSession session(m_Server.GetIpAdress(), m_Server.GetPort()); + + std::string uri = Poco::format("/:/unscrobble?key=%d&identifier=com.plexapp.plugins.library", m_iRatingKey); + Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, uri); + session.sendRequest(req); + + Poco::Net::HTTPResponse resp; + session.receiveResponse(resp); + + if(resp.getStatus() == 200) { + dsyslog("[plex]: Set Unwatched: %s", uri.c_str()); + return true; + } + return false; + } catch (Poco::Exception &exc) { + esyslog("[plex]: %s: %s", __FUNCTION__, exc.displayText().c_str()); + return false; + } +} + +bool Video::SetWatched() +{ + try { + Poco::Net::HTTPClientSession session(m_Server.GetIpAdress(), m_Server.GetPort()); + + std::string uri = Poco::format("/:/scrobble?key=%d&identifier=com.plexapp.plugins.library", m_iRatingKey); + Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, uri); + session.sendRequest(req); + + Poco::Net::HTTPResponse resp; + session.receiveResponse(resp); + + if(resp.getStatus() == 200) { + dsyslog("[plex]: Set Watched: %s", uri.c_str()); + return true; + } + return false; + } catch (Poco::Exception &exc) { + esyslog("[plex]: %s: %s", __FUNCTION__, exc.displayText().c_str()); + return false; + } +} + + } // Namespace @@ -56,6 +56,7 @@ public: std::string m_sThumb; std::string m_sArt; long m_iDuration; + int m_iViewCount; Poco::Timestamp m_tAddedAt; Poco::Timestamp m_tUpdatedAt; @@ -74,6 +75,8 @@ public: std::string GetTitle(); bool SetStream(Stream* stream); bool UpdateFromServer(); + bool SetWatched(); + bool SetUnwatched(); }; } |