summaryrefslogtreecommitdiff
path: root/PVideo.cpp
diff options
context:
space:
mode:
authorchriszero <zerov83@gmail.com>2015-03-05 20:11:09 +0100
committerchriszero <zerov83@gmail.com>2015-03-05 20:11:09 +0100
commita37e5ffb71a36ed841ec7f53ae24cca5b441c6d2 (patch)
treeeab7bea85644b89c5d21a83d9b001353849151e7 /PVideo.cpp
parentf32ddb726d477ea1be41d852932d22b9def83d28 (diff)
downloadvdr-plugin-plex-a37e5ffb71a36ed841ec7f53ae24cca5b441c6d2.tar.gz
vdr-plugin-plex-a37e5ffb71a36ed841ec7f53ae24cca5b441c6d2.tar.bz2
Scobble / Unscrobble function
Diffstat (limited to 'PVideo.cpp')
-rw-r--r--PVideo.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/PVideo.cpp b/PVideo.cpp
index a0da43f..8949666 100644
--- a/PVideo.cpp
+++ b/PVideo.cpp
@@ -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