summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchriszero <zerov83@gmail.com>2015-12-15 22:15:35 +0100
committerchriszero <zerov83@gmail.com>2015-12-15 22:15:35 +0100
commit7b64bf5062f3eb6ddff5d7606e44367bd5077e4c (patch)
tree258cbbc0d4edbe3bcabf58c6dee495d19384ed14
parent135ed5d0ce1613f70f4b2ddcb9e8bca721ffca9e (diff)
downloadvdr-plugin-plex-7b64bf5062f3eb6ddff5d7606e44367bd5077e4c.tar.gz
vdr-plugin-plex-7b64bf5062f3eb6ddff5d7606e44367bd5077e4c.tar.bz2
Added SSL support, started support for remote
resources (servers). Browsing remote servers is working. plex.tv login is mandatory.
-rw-r--r--Makefile3
-rw-r--r--MediaContainer.cpp4
-rw-r--r--MediaContainer.h4
-rw-r--r--PVideo.cpp6
-rw-r--r--PlexServer.cpp72
-rw-r--r--PlexServer.h31
-rw-r--r--Plexservice.cpp102
-rw-r--r--Plexservice.h4
-rw-r--r--SubscriptionManager.cpp8
-rw-r--r--browserGrid.cpp2
-rw-r--r--device.cpp62
-rw-r--r--device.h59
-rw-r--r--hlsPlayer.cpp7
-rw-r--r--mpvWrapper.cpp4
-rw-r--r--mpvWrapper.h2
-rw-r--r--pictureCache.cpp2
-rw-r--r--plex.cpp24
-rw-r--r--plexgdm.cpp26
-rw-r--r--plexgdm.h2
-rw-r--r--po/de_DE.mobin2980 -> 4189 bytes
-rw-r--r--po/de_DE.po2
21 files changed, 371 insertions, 55 deletions
diff --git a/Makefile b/Makefile
index b11e68e..f9821f2 100644
--- a/Makefile
+++ b/Makefile
@@ -95,7 +95,8 @@ OBJS = $(PLUGIN).o \
browserGrid.o \
viewHeader.o \
detailView.o \
- pictureCache.o
+ pictureCache.o \
+ device.o
SRCS = $(wildcard $(OBJS:.o=.c)) $(PLUGIN).cpp
diff --git a/MediaContainer.cpp b/MediaContainer.cpp
index ba46fe8..10096ce 100644
--- a/MediaContainer.cpp
+++ b/MediaContainer.cpp
@@ -3,6 +3,8 @@
namespace plexclient
{
+MediaContainer::MediaContainer(std::istream* response) : MediaContainer(response, NULL) {}
+
MediaContainer::MediaContainer(std::istream* response, PlexServer* Server)
{
m_pServer = Server;
@@ -43,6 +45,8 @@ MediaContainer::MediaContainer(std::istream* response, PlexServer* Server)
m_vDirectories.push_back(Directory(pNode, m_pServer, this));
} else if(Poco::icompare(pNode->nodeName(), "Video") == 0) {
m_vVideos.push_back(Video(pNode, m_pServer, this));
+ } else if(Poco::icompare(pNode->nodeName(), "Device") == 0) {
+ m_vDevices.push_back(Device(pNode, this));
}
pNode = it.nextNode();
diff --git a/MediaContainer.h b/MediaContainer.h
index 947a647..02b8b96 100644
--- a/MediaContainer.h
+++ b/MediaContainer.h
@@ -19,6 +19,7 @@
#include "PVideo.h"
#include "PlexServer.h"
#include "Config.h"
+#include "device.h"
using Poco::XML::DOMParser;
using Poco::XML::InputSource;
@@ -33,11 +34,13 @@ namespace plexclient
{
class Video;
class Directory;
+class Device;
class MediaContainer: XmlObject
{
public:
MediaContainer(std::istream *response, PlexServer* Server);
+ MediaContainer(std::istream *response);
protected:
@@ -45,6 +48,7 @@ protected:
public:
std::vector<Directory> m_vDirectories;
std::vector<Video> m_vVideos;
+ std::vector<Device> m_vDevices;
bool m_bAllowSync;
std::string m_sArt;
diff --git a/PVideo.cpp b/PVideo.cpp
index 4fbcda1..d92caae 100644
--- a/PVideo.cpp
+++ b/PVideo.cpp
@@ -163,7 +163,7 @@ std::string Video::GetTitle()
bool Video::SetStream(Stream* stream)
{
try {
- Poco::Net::HTTPClientSession session(m_pServer->GetIpAdress(), m_pServer->GetPort());
+ Poco::Net::HTTPClientSession session(m_pServer->GetHost(), m_pServer->GetPort());
std::string uri = Poco::format("/library/parts/%d?%s", m_Media.m_iPartId, stream->GetSetStreamQuery());
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_PUT, uri);
@@ -186,7 +186,7 @@ bool Video::SetStream(Stream* stream)
bool Video::SetUnwatched()
{
try {
- Poco::Net::HTTPClientSession session(m_pServer->GetIpAdress(), m_pServer->GetPort());
+ Poco::Net::HTTPClientSession session(m_pServer->GetHost(), m_pServer->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);
@@ -209,7 +209,7 @@ bool Video::SetUnwatched()
bool Video::SetWatched()
{
try {
- Poco::Net::HTTPClientSession session(m_pServer->GetIpAdress(), m_pServer->GetPort());
+ Poco::Net::HTTPClientSession session(m_pServer->GetHost(), m_pServer->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);
diff --git a/PlexServer.cpp b/PlexServer.cpp
index 6b3f0ae..687c8d1 100644
--- a/PlexServer.cpp
+++ b/PlexServer.cpp
@@ -3,15 +3,45 @@
namespace plexclient
{
+
+PlexServer::PlexServer(std::string ip, int port)
+{
+ m_httpSession = NULL;
+
+ Poco::URI uri;
+ uri.setHost(ip);
+ uri.setPort(port);
+ uri.setScheme("http");
+ m_uri = uri.toString();
+}
PlexServer::PlexServer(std::string data, std::string ip)
{
+ m_httpSession = NULL;
ParseData(data, ip);
}
+PlexServer::PlexServer(std::string uri, std::string name, std::string uuid, std::string accessToken, bool owned, bool local)
+{
+ m_httpSession = NULL;
+ m_sServerName = name;
+ m_sUuid = uuid;
+ m_nOwned = owned;
+ m_bLocal = local;
+ m_authToken = accessToken;
+
+ m_uri = uri;
+}
+
+PlexServer::~PlexServer()
+{
+ delete m_httpSession;
+ m_httpSession = NULL;
+}
+
void PlexServer::ParseData(std::string data, std::string ip)
{
- m_sIpAddress = ip;
+ int port = 0;
std::istringstream f(data);
std::string s;
Offline = false;
@@ -27,7 +57,7 @@ void PlexServer::ParseData(std::string data, std::string ip)
} else if (name == "Name") {
m_sServerName = val;
} else if (name == "Port") {
- m_nPort = atoi(val.c_str());
+ port = atoi(val.c_str());
} else if (name == "Updated-At") {
m_nUpdated = atol(val.c_str());
} else if (name == "Version") {
@@ -35,17 +65,47 @@ void PlexServer::ParseData(std::string data, std::string ip)
}
}
}
+ delete m_httpSession;
+ m_httpSession = NULL;
+
+ Poco::URI uri;
+
+ uri.setHost(ip);
+ uri.setPort(port);
+ uri.setScheme("http");
+
+ m_uri = uri.toString();
}
-PlexServer::PlexServer(std::string ip, int port)
+std::string PlexServer::GetHost()
{
- m_sIpAddress = ip;
- m_nPort = port;
+ Poco::URI uri(m_uri);
+ return uri.getHost();
+}
+
+int PlexServer::GetPort()
+{
+ Poco::URI uri(m_uri);
+ return uri.getPort();
+}
+
+Poco::Net::HTTPClientSession* PlexServer::GetClientSession()
+{
+ Poco::URI uri(m_uri);
+ if(m_httpSession == NULL) {
+ if(uri.getScheme().find("https") != std::string::npos) {
+ m_httpSession = new Poco::Net::HTTPSClientSession(uri.getHost(), uri.getPort());
+ }
+ else {
+ m_httpSession = new Poco::Net::HTTPClientSession(uri.getHost(), uri.getPort());
+ }
+ }
+ return m_httpSession;
}
std::string PlexServer::GetUri()
{
- return std::string("http://") + m_sIpAddress + ":" + std::string(itoa(m_nPort));
+ return m_uri;
}
}
diff --git a/PlexServer.h b/PlexServer.h
index 0a36adb..e530aa9 100644
--- a/PlexServer.h
+++ b/PlexServer.h
@@ -10,6 +10,7 @@
#include <Poco/String.h>
#include <Poco/Net/HTTPClientSession.h>
+#include <Poco/Net/HTTPSClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/MessageHeader.h>
#include <Poco/URI.h>
@@ -21,17 +22,17 @@ class PlexServer
{
friend class plexgdm;
-public:
+ public:
+ PlexServer(std::string uri, std::string name, std::string uuid, std::string accessToken, bool owned, bool local);
+ ~PlexServer();
+
int GetMaster() const {
return m_nMaster;
}
- int GetOwned() const {
+ int IsOwned() const {
return m_nOwned;
}
- int GetPort() const {
- return m_nPort;
- }
const std::string& GetContentType() const {
return m_sContentType;
}
@@ -53,11 +54,19 @@ public:
const std::string& GetVersion() const {
return m_sVersion;
}
- const std::string& GetIpAdress() const {
- return m_sIpAddress;
+ const std::string& GetAuthToken() const {
+ return m_authToken;
}
-
+ const bool& IsLocal() const {
+ return m_bLocal;
+ }
+
+ std::string GetHost();
+ int GetPort();
+
std::string GetUri();
+
+ Poco::Net::HTTPClientSession* GetClientSession();
void DiscoverSettings();
bool Offline;
@@ -73,15 +82,17 @@ private:
std::string m_sDiscovery;
int m_nOwned;
+ bool m_bLocal;
int m_nMaster;
std::string m_sRole;
std::string m_sContentType;
std::string m_sUuid;
std::string m_sServerName;
- std::string m_sIpAddress;
- int m_nPort;
+ std::string m_uri;
+ std::string m_authToken;
long m_nUpdated;
std::string m_sVersion;
+ Poco::Net::HTTPClientSession* m_httpSession;
};
diff --git a/Plexservice.cpp b/Plexservice.cpp
index bae8ed2..3e08613 100644
--- a/Plexservice.cpp
+++ b/Plexservice.cpp
@@ -53,6 +53,7 @@ std::string Plexservice::GetMyPlexToken()
// parse the XML Response
user u(&rs);
myToken = u.authenticationToken;
+ isyslog("[plex] plex.tv login successfull.");
} else {
esyslog("[plex] plex.tv Login failed, check you creditials.");
}
@@ -74,7 +75,7 @@ void Plexservice::Authenticate()
std::string token = GetMyPlexToken();
auto pRequest = CreateRequest("/?X-Plex-Token=" + token);
- Poco::Net::HTTPClientSession session(pServer->GetIpAdress(), pServer->GetPort());
+ Poco::Net::HTTPClientSession session(pServer->GetHost(), pServer->GetPort());
session.sendRequest(*pRequest);
Poco::Net::HTTPResponse response;
/*std::istream &rs = */
@@ -87,6 +88,37 @@ void Plexservice::Authenticate()
}
}
+void Plexservice::UpdateResources()
+{
+ // We must be autenticated
+ // https://plex.tv/api/resources?includeHttps=1
+ if(!Config::GetInstance().UsePlexAccount) {
+ isyslog("[plex] To access remote servers, please login with your plex.tv account.");
+ return; // Plugin is used without plex.tv login
+ }
+ isyslog("[plex] Updating remote resources...");
+
+ std::shared_ptr<MediaContainer> pContainer = GetMediaContainer("https://plex.tv/api/resources?includeHttps=1");
+
+ for(std::vector<Device>::iterator d_it = pContainer->m_vDevices.begin(); d_it != pContainer->m_vDevices.end(); ++d_it) {
+
+ // check device is a server
+ if(d_it->m_sProvides.find("server") != std::string::npos) {
+ // is it a remote server?
+ if(d_it->m_bPublicAddressMatches == false) {
+ // pick remote connection
+ for(std::vector<Connection>::iterator c_it = d_it->m_vConnections.begin(); c_it != d_it->m_vConnections.end(); ++c_it) {
+ if(c_it->m_bLocal == false) {
+ dsyslog("[plex] Found remote server: %s", d_it->m_sName.c_str());
+ // a remote Server
+ plexgdm::GetInstance().AddServer(PlexServer(c_it->m_sUri, d_it->m_sName, d_it->m_sClientIdentifier, d_it->m_sAccessToken, d_it->m_bOwned, c_it->m_bLocal));
+ }
+ }
+ }
+ }
+ }
+}
+
PlexServer* Plexservice::GetServer()
{
return pServer;
@@ -106,17 +138,18 @@ std::shared_ptr<MediaContainer> Plexservice::GetSection(std::string section, boo
if(putOnStack) {
m_vUriStack.push(uri);
}
-
- Poco::Net::HTTPClientSession session(pServer->GetIpAdress(), pServer->GetPort());
- session.sendRequest(*pRequest);
+
+ dsyslog("[plex] URI: %s%s", pServer->GetUri().c_str(), uri.c_str());
+ //Poco::Net::HTTPClientSession session(pServer->GetHost(), pServer->GetPort());
+ //session.sendRequest(*pRequest);
+ pServer->GetClientSession()->sendRequest(*pRequest);
Poco::Net::HTTPResponse response;
- std::istream &rs = session.receiveResponse(response);
+ std::istream &rs = pServer->GetClientSession()->receiveResponse(response);
- dsyslog("[plex] URI: http://%s:%d%s", pServer->GetIpAdress().c_str(), pServer->GetPort(), uri.c_str());
std::shared_ptr<MediaContainer> pAllsections(new MediaContainer(&rs, pServer));
- session.abort();
+ //session.abort();
return pAllsections;
} catch (Poco::Net::NetException &exc) {
@@ -153,8 +186,13 @@ std::unique_ptr<Poco::Net::HTTPRequest> Plexservice::CreateRequest(std::string p
if(Config::GetInstance().UsePlexAccount) {
// Add PlexToken to Header
std::string token = GetMyPlexToken();
- if(!token.empty())
+ if(pServer && !pServer->GetAuthToken().empty()) {
+ pRequest->add("X-Plex-Token", pServer->GetAuthToken());
+ dsyslog("[plex] Using server access token");
+ }
+ else if(!token.empty())
pRequest->add("X-Plex-Token", token);
+ dsyslog("[plex] Using global access token");
}
return pRequest;
@@ -162,22 +200,58 @@ std::unique_ptr<Poco::Net::HTTPRequest> Plexservice::CreateRequest(std::string p
std::shared_ptr<MediaContainer> Plexservice::GetMediaContainer(std::string fullUrl)
{
+ Poco::Net::HTTPClientSession* pSession = NULL;
try {
Poco::URI fileuri(fullUrl);
+
+ // Check for https
+ Poco::Net::Context::Ptr context = new Poco::Net::Context(
+ Poco::Net::Context::CLIENT_USE, "", "", "", Poco::Net::Context::VERIFY_NONE, // VERIFY_NONE...?!
+ 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
+
+ if(fileuri.getScheme().find("https") != std::string::npos) {
+ pSession = new Poco::Net::HTTPSClientSession(fileuri.getHost(), fileuri.getPort(), context);
+ }
+ else {
+ pSession = new Poco::Net::HTTPClientSession(fileuri.getHost(), fileuri.getPort());
+ }
+
+ // > HTTPS
+
Poco::Net::HTTPRequest request(Poco::Net::HTTPRequest::HTTP_GET, fileuri.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
PlexHelper::AddHttpHeader(request);
+
+ if(Config::GetInstance().UsePlexAccount) {
+ // Add PlexToken to Header
+ std::string token = GetMyPlexToken();
+ if(!token.empty())
+ request.add("X-Plex-Token", token);
+ }
- Poco::Net::HTTPClientSession session(fileuri.getHost(), fileuri.getPort());
- session.sendRequest(request);
+ pSession->sendRequest(request);
Poco::Net::HTTPResponse response;
- std::istream &rs = session.receiveResponse(response);
-
- std::shared_ptr<MediaContainer> pAllsections(new MediaContainer(&rs, plexgdm::GetInstance().GetServer(fileuri.getHost(), fileuri.getPort())));
+ std::istream &rs = pSession->receiveResponse(response);
+
+ //Poco::StreamCopier::copyStream(rs, std::cout);
+
+ std::shared_ptr<MediaContainer> pAllsections;
+
+ // omit creating a server when talking to plex.tv
+ if(fileuri.getHost().find("plex.tv") != std::string::npos) {
+ pAllsections = std::shared_ptr<MediaContainer>(new MediaContainer(&rs));
+ }
+ else {
+ pAllsections = std::shared_ptr<MediaContainer>(new MediaContainer(&rs, plexgdm::GetInstance().GetServer(fileuri.getHost(), fileuri.getPort())));
+ }
+
- session.abort();
+ pSession->abort();
+ delete pSession;
return pAllsections;
} catch (Poco::Net::NetException &exc) {
+ std::cout << exc.displayText() << std::endl;
+ delete pSession;
return 0;
}
}
diff --git a/Plexservice.h b/Plexservice.h
index 5f3567b..7897281 100644
--- a/Plexservice.h
+++ b/Plexservice.h
@@ -46,14 +46,14 @@ public:
std::shared_ptr<MediaContainer> GetSection(std::string section, bool putOnStack = true);
std::shared_ptr<MediaContainer> GetLastSection(bool current = false);
bool IsRoot();
- void GetAuthDetails();
- void Authenticate();
PlexServer* GetServer();
+ void Authenticate();
static std::string GetUniversalTranscodeUrl(Video* video, int offset = 0, PlexServer* server = 0);
static std::string GetMyPlexToken();
static std::shared_ptr<MediaContainer> GetMediaContainer(std::string fullUrl);
static std::string encode(std::string message);
+ static void UpdateResources();
std::string StartUri;
diff --git a/SubscriptionManager.cpp b/SubscriptionManager.cpp
index aa10077..67ab723 100644
--- a/SubscriptionManager.cpp
+++ b/SubscriptionManager.cpp
@@ -60,7 +60,7 @@ void SubscriptionManager::ReportProgress()
if (m_pStatus->PlayerStopped) state = "stopped";
else if(!play) state = "paused";
- Poco::Net::HTTPClientSession session(m_pStatus->pVideo->m_pServer->GetIpAdress(), m_pStatus->pVideo->m_pServer->GetPort());
+ Poco::Net::HTTPClientSession session(m_pStatus->pVideo->m_pServer->GetHost(), m_pStatus->pVideo->m_pServer->GetPort());
std::string uri = "/:/progress?key=" + std::string(itoa(m_pStatus->pVideo->m_iRatingKey)) + "&identifier=com.plexapp.plugins.library&time=" + std::string(itoa(current)) + "&state=" + state;
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, uri);
session.sendRequest(req);
@@ -91,10 +91,10 @@ void SubscriptionManager::NotifyServer()
std::string server;
int port;
if(pVid) {
- server = pVid->m_pServer->GetIpAdress();
+ server = pVid->m_pServer->GetHost();
port = pVid->m_pServer->GetPort();
} else if ( plexgdm::GetInstance().GetPlexservers().size() > 0) {
- server = plexgdm::GetInstance().GetPlexservers().at(0).GetIpAdress();
+ server = plexgdm::GetInstance().GetPlexservers().at(0).GetHost();
port = plexgdm::GetInstance().GetPlexservers().at(0).GetPort();
} else {
// no plexservers in network
@@ -198,7 +198,7 @@ std::string SubscriptionManager::GetTimelineXml()
msg << " controllable=\"true\"";
msg << " machineIdentifier=\"" << (pVid ? pVid->m_pServer->GetUuid() : "") << "\"";
msg << " protocol=\"http\"";
- msg << " address=\"" << (pVid ? pVid->m_pServer->GetIpAdress() : "") << "\"";
+ msg << " address=\"" << (pVid ? pVid->m_pServer->GetHost() : "") << "\"";
msg << " port=\"" << (pVid ? pVid->m_pServer->GetPort() : 0) << "\"";
msg << " guid=\"" << Config::GetInstance().GetUUID() << "\"";
msg << " containerKey=\"" << (pVid ? pVid->m_sKey : "/library/metadata/900000") << "\"";
diff --git a/browserGrid.cpp b/browserGrid.cpp
index f9bb026..8504ced 100644
--- a/browserGrid.cpp
+++ b/browserGrid.cpp
@@ -482,7 +482,7 @@ void cServerElement::AddTokens(std::shared_ptr<skindesignerapi::cOsdElement> gri
grid->AddIntToken("isserver", 1);
grid->AddStringToken("title", m_pServer->GetServerName());
grid->AddStringToken("serverstartpointname", m_sStartName);
- grid->AddStringToken("serverip", m_pServer->GetIpAdress());
+ grid->AddStringToken("serverip", m_pServer->GetHost());
grid->AddIntToken("serverport", m_pServer->GetPort());
grid->AddStringToken("serverversion", m_pServer->GetVersion());
grid->AddIntToken("viewmode", Config::GetInstance().DefaultViewMode);
diff --git a/device.cpp b/device.cpp
new file mode 100644
index 0000000..8acf688
--- /dev/null
+++ b/device.cpp
@@ -0,0 +1,62 @@
+#include "device.h"
+
+namespace plexclient
+{
+
+Connection::Connection(Poco::XML::Node* pNode, Device* parent)
+{
+ m_pParent = parent;
+
+ NodeIterator it(pNode, Poco::XML::NodeFilter::SHOW_ALL);
+ Poco::XML::Node* pChildNode = it.nextNode();
+
+ while(pChildNode) {
+ if(Poco::icompare(pChildNode->nodeName(), "Connection") == 0) {
+ Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pChildNode->attributes();
+
+ m_sProtocol = GetNodeValue(pAttribs->getNamedItem("protocol"));
+ m_sAddress = GetNodeValue(pAttribs->getNamedItem("address"));
+ m_iPort = GetNodeValueAsInt(pAttribs->getNamedItem("port"));
+ m_sUri = GetNodeValue(pAttribs->getNamedItem("uri"));
+ m_bLocal = GetNodeValueAsBool(pAttribs->getNamedItem("local"));
+
+ pAttribs->release();
+ }
+ pChildNode = it.nextNode();
+ }
+}
+
+Device::Device(Poco::XML::Node* pNode, MediaContainer* parent)
+{
+ m_pParent = parent;
+
+ NodeIterator it(pNode, Poco::XML::NodeFilter::SHOW_ALL);
+ Poco::XML::Node* pChildNode = it.nextNode();
+ std::cout << "Found Device ";
+
+ while(pChildNode) {
+ if(Poco::icompare(pChildNode->nodeName(), "Device") == 0) {
+ Poco::XML::AutoPtr<Poco::XML::NamedNodeMap> pAttribs = pChildNode->attributes();
+
+ m_sName = GetNodeValue(pAttribs->getNamedItem("name"));
+ m_sProduct = GetNodeValue(pAttribs->getNamedItem("product"));
+ m_sProvides = GetNodeValue(pAttribs->getNamedItem("provides"));
+ m_sClientIdentifier = GetNodeValue(pAttribs->getNamedItem("clientIdentifier"));
+ m_bOwned = GetNodeValueAsBool(pAttribs->getNamedItem("owned"));
+ m_sAccessToken = GetNodeValue(pAttribs->getNamedItem("accessToken"));
+ m_bHttpsRequired = GetNodeValueAsBool(pAttribs->getNamedItem("httpsRequired"));
+ m_bPublicAddressMatches = GetNodeValueAsBool(pAttribs->getNamedItem("publicAddressMatches"));
+ m_bPresence = GetNodeValueAsBool(pAttribs->getNamedItem("presence"));
+ m_sSourceTitle = GetNodeValue(pAttribs->getNamedItem("sourceTitle"));
+
+ pAttribs->release();
+ } else if(Poco::icompare(pChildNode->nodeName(), "Connection") == 0) {
+ m_vConnections.push_back(Connection(pChildNode, this));
+ }
+
+ pChildNode = it.nextNode();
+ }
+}
+
+
+}
diff --git a/device.h b/device.h
new file mode 100644
index 0000000..5b28047
--- /dev/null
+++ b/device.h
@@ -0,0 +1,59 @@
+#ifndef DEVICE_H
+#define DEVICE_H
+
+#include <Poco/DOM/DOMParser.h>
+#include <Poco/DOM/Document.h>
+#include <Poco/DOM/NamedNodeMap.h>
+#include <Poco/DOM/NodeIterator.h>
+#include <Poco/DOM/NodeFilter.h>
+#include <Poco/DOM/AutoPtr.h>
+#include <Poco/Exception.h>
+#include <Poco/Timestamp.h>
+#include <Poco/String.h>
+
+#include "XmlObject.h"
+#include "MediaContainer.h"
+
+namespace plexclient
+{
+class Device;
+
+class Connection: private XmlObject
+{
+public:
+ Connection(Poco::XML::Node* pNode, Device* parent);
+
+ std::string m_sProtocol;
+ std::string m_sAddress;
+ int m_iPort;
+ std::string m_sUri;
+ bool m_bLocal;
+
+ Device* m_pParent;
+
+};
+
+class Device: private XmlObject
+{
+public:
+ Device(Poco::XML::Node* pNode, MediaContainer* parent);
+
+ std::string m_sName;
+ std::string m_sProduct;
+ std::string m_sProvides;
+ std::string m_sClientIdentifier;
+ bool m_bOwned;
+ std::string m_sAccessToken;
+ bool m_bHttpsRequired;
+ bool m_bPublicAddressMatches;
+ bool m_bPresence;
+ std::string m_sSourceTitle;
+
+ std::vector<Connection> m_vConnections;
+
+ MediaContainer* m_pParent;
+};
+
+}
+
+#endif // DEVICE_H
diff --git a/hlsPlayer.cpp b/hlsPlayer.cpp
index 5b650e3..70ce3fa 100644
--- a/hlsPlayer.cpp
+++ b/hlsPlayer.cpp
@@ -581,7 +581,6 @@ bool cHlsPlayer::GetIndex(int& Current, int& Total, bool SnapToIFrame __attribut
Total = m_pSegmentLoader->GetStreamLenght() * FramesPerSecond();
}
Current = GetPlayedSeconds() * FramesPerSecond();
- std::cout << "FPS: " << FramesPerSecond() << "STC: " << this->DeviceGetSTC() << std::endl;
return true;
}
@@ -667,7 +666,7 @@ void cHlsPlayer::SetAudioTrack(eTrackType Type __attribute__((unused)), const tT
}
// Then do the request
if(streamId > 0) {
- Poco::Net::HTTPClientSession session(m_Video.m_pServer->GetIpAdress(), m_Video.m_pServer->GetPort());
+ Poco::Net::HTTPClientSession session(m_Video.m_pServer->GetHost(), m_Video.m_pServer->GetPort());
std::string uri = "/library/parts/" + std::string(itoa(m_Video.m_Media.m_iPartId)) + "?audioStreamID=" + std::string(itoa(streamId));
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_PUT, uri);
@@ -719,7 +718,7 @@ void cHlsPlayer::ReportProgress(bool stopped)
}
try {
- Poco::Net::HTTPClientSession session(m_Video.m_pServer->GetIpAdress(), m_Video.m_pServer->GetPort());
+ Poco::Net::HTTPClientSession session(m_Video.m_pServer->GetHost(), m_Video.m_pServer->GetPort());
std::string uri = "/:/progress?key=" + std::string(itoa(m_Video.m_iRatingKey)) + "&identifier=com.plexapp.plugins.library&time=" + std::string(itoa(GetPlayedSeconds()*1000)) + "&state=" + state;
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, uri);
session.sendRequest(req);
@@ -736,7 +735,7 @@ void cHlsPlayer::ReportProgress(bool stopped)
void cHlsPlayer::SetWatched(void)
{
- Poco::Net::HTTPClientSession session(m_Video.m_pServer->GetIpAdress(), m_Video.m_pServer->GetPort());
+ Poco::Net::HTTPClientSession session(m_Video.m_pServer->GetHost(), m_Video.m_pServer->GetPort());
std::string uri = "/:/scrobble?key=" + std::string(itoa(m_Video.m_iRatingKey)) + "&identifier=com.plexapp.plugins.library";
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, uri);
session.sendRequest(req);
diff --git a/mpvWrapper.cpp b/mpvWrapper.cpp
index 4986705..48aa025 100644
--- a/mpvWrapper.cpp
+++ b/mpvWrapper.cpp
@@ -4,7 +4,3 @@ cMpvWrapper::cMpvWrapper()
{
}
-cMpvWrapper::~cMpvWrapper()
-{
-}
-
diff --git a/mpvWrapper.h b/mpvWrapper.h
index 890a27f..207494c 100644
--- a/mpvWrapper.h
+++ b/mpvWrapper.h
@@ -5,8 +5,6 @@ class cMpvWrapper
{
public:
cMpvWrapper();
- ~cMpvWrapper();
-
};
#endif // CMPVWRAPPER_H
diff --git a/pictureCache.cpp b/pictureCache.cpp
index 299bd8e..556a75d 100644
--- a/pictureCache.cpp
+++ b/pictureCache.cpp
@@ -122,7 +122,7 @@ std::string cPictureCache::TranscodeUri(std::string uri, int width, int height)
std::string host = u.getHost();
auto plServer = plexclient::plexgdm::GetInstance().GetFirstServer();
if (plServer) {
- host = plServer->GetIpAdress();
+ host = plServer->GetHost();
port = plServer->GetPort();
}
diff --git a/plex.cpp b/plex.cpp
index 801f497..dc3c3df 100644
--- a/plex.cpp
+++ b/plex.cpp
@@ -7,6 +7,11 @@
#include "services.h"
#include <libskindesignerapi/skindesignerapi.h>
+#include <Poco/Net/SSLManager.h>
+#include <Poco/SharedPtr.h>
+#include <Poco/Net/Context.h>
+#include <Poco/Net/AcceptCertificateHandler.h>
+#include <Poco/Net/ConsoleCertificateHandler.h>
//////////////////////////////////////////////////////////////////////////////
// cPlugin
@@ -98,12 +103,31 @@ bool cMyPlugin::Start(void)
*/
bool cMyPlugin::Initialize(void)
{
+ // Initialize SSL
+ {
+ using namespace Poco;
+ using namespace Poco::Net;
+ using Poco::Net::SSLManager;
+ using Poco::Net::Context;
+ using Poco::Net::AcceptCertificateHandler;
+ using Poco::Net::PrivateKeyPassphraseHandler;
+ using Poco::Net::InvalidCertificateHandler;
+ using Poco::Net::ConsoleCertificateHandler;
+
+ //SharedPtr<PrivateKeyPassphraseHandler> pConsoleHandler = new PrivateKeyPassphraseHandler;
+ SharedPtr<InvalidCertificateHandler> pInvalidCertHandler = new AcceptCertificateHandler(false);
+ Context::Ptr pContext = new Poco::Net::Context(
+ Context::CLIENT_USE, "", "", "", Context::VERIFY_NONE, // VERIFY_NONE...?!
+ 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH");
+ SSLManager::instance().initializeClient(NULL, pInvalidCertHandler, pContext);
+ }
// First Startup? Save UUID
SetupStore("UUID", Config::GetInstance().GetUUID().c_str());
plexclient::plexgdm::GetInstance().clientDetails(Config::GetInstance().GetUUID(), Config::GetInstance().GetHostname(), "3200", DESCRIPTION, VERSION);
plexclient::plexgdm::GetInstance().Start();
plexclient::ControlServer::GetInstance().Start();
+ plexclient::Plexservice::UpdateResources();
cPictureCache::GetInstance().Start();
return true;
diff --git a/plexgdm.cpp b/plexgdm.cpp
index cdc1339..a3b3de2 100644
--- a/plexgdm.cpp
+++ b/plexgdm.cpp
@@ -164,7 +164,7 @@ void plexgdm::discover()
bool flag = true;
// Check for duplicates
for(std::vector<PlexServer>::iterator s_it = m_vServers.begin(); s_it != m_vServers.end(); ++s_it) {
- if(s_it->GetIpAdress() == host) {
+ if(s_it->GetHost() == host) {
flag = false;
s_it->ParseData(data, host);
dsyslog("[plex] Server Updated: %s", host.c_str());
@@ -194,7 +194,7 @@ void plexgdm::stopRegistration()
PlexServer* plexgdm::GetServer(std::string ip, int port)
{
for(std::vector<PlexServer>::iterator s_it = m_vServers.begin(); s_it != m_vServers.end(); ++s_it) {
- if(s_it->GetIpAdress() == ip && s_it->GetPort() == port) {
+ if(s_it->GetHost() == ip && s_it->GetPort() == port) {
return &(*s_it);
}
}
@@ -208,4 +208,26 @@ PlexServer* plexgdm::GetFirstServer()
else return NULL;
}
+PlexServer* plexgdm::GetServer(std::string uuid)
+{
+ for(std::vector<PlexServer>::iterator s_it = m_vServers.begin(); s_it != m_vServers.end(); ++s_it) {
+ if(s_it->GetUuid() == uuid ){
+ return &(*s_it);
+ }
+ }
+ return NULL;
+}
+
+void plexgdm::AddServer(PlexServer server)
+{
+ for(std::vector<PlexServer>::iterator s_it = m_vServers.begin(); s_it != m_vServers.end(); ++s_it) {
+ if(s_it->GetUuid() == server.GetUuid() ){
+ dsyslog("[plex] Server already in list: %s", server.GetUri().c_str());
+ return;
+ }
+ }
+ m_vServers.push_back(server);
+ isyslog("[plex] New Server Added: %s", server.GetUri().c_str());
+}
+
} // namespace
diff --git a/plexgdm.h b/plexgdm.h
index 87ce82e..41e7dd7 100644
--- a/plexgdm.h
+++ b/plexgdm.h
@@ -34,6 +34,8 @@ public:
std::string getClientDetails();
PlexServer* getServerList();
PlexServer* GetServer(std::string ip, int port);
+ PlexServer* GetServer(std::string uuid);
+ void AddServer(PlexServer server);
PlexServer* GetFirstServer();
void discover();
void checkClientRegistration();
diff --git a/po/de_DE.mo b/po/de_DE.mo
index 0a3f556..db25a05 100644
--- a/po/de_DE.mo
+++ b/po/de_DE.mo
Binary files differ
diff --git a/po/de_DE.po b/po/de_DE.po
index 4c68b43..265d9b6 100644
--- a/po/de_DE.po
+++ b/po/de_DE.po
@@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: vdr-plex 0.1.0\n"
"Report-Msgid-Bugs-To: <see README>\n"
-"POT-Creation-Date: 2015-11-07 16:19+0100\n"
+"POT-Creation-Date: 2015-12-15 20:56+0100\n"
"PO-Revision-Date: 2015-11-07 16:38+0200\n"
"Last-Translator: Chris <zerov83@gmail.com>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"