diff options
author | chriszero <zerov83@gmail.com> | 2015-03-05 20:11:09 +0100 |
---|---|---|
committer | chriszero <zerov83@gmail.com> | 2015-03-05 20:11:09 +0100 |
commit | a37e5ffb71a36ed841ec7f53ae24cca5b441c6d2 (patch) | |
tree | eab7bea85644b89c5d21a83d9b001353849151e7 /PVideo.cpp | |
parent | f32ddb726d477ea1be41d852932d22b9def83d28 (diff) | |
download | vdr-plugin-plex-a37e5ffb71a36ed841ec7f53ae24cca5b441c6d2.tar.gz vdr-plugin-plex-a37e5ffb71a36ed841ec7f53ae24cca5b441c6d2.tar.bz2 |
Scobble / Unscrobble function
Diffstat (limited to 'PVideo.cpp')
-rw-r--r-- | PVideo.cpp | 48 |
1 files changed, 48 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 |