summaryrefslogtreecommitdiff
path: root/PlexServer.cpp
blob: 4eb124530092d78a86cddaa6a1161aee7c07b06c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include <vdr/tools.h>
#include "PlexServer.h"

namespace plexclient
{

PlexServer::PlexServer(std::string data, std::string ip)
{
	m_sIpAddress = ip;
	std::istringstream f(data);
	std::string s;
	while(std::getline(f, s)) {
		int pos = s.find(':');
		if(pos > 0) {
			std::string name = Poco::trim(s.substr(0, pos));
			std::string val = Poco::trim(s.substr(pos+1));
			if(name == "Content-Type") {
				m_sContentType = val;
			} else if (name == "Resource-Identifier") {
				m_sUuid = val;
			} else if (name == "Name") {
				m_sServerName = val;
			} else if (name == "Port") {
				m_nPort = atoi(val.c_str());
			} else if (name == "Updated-At") {
				m_nUpdated = atol(val.c_str());
			} else if (name == "Version") {
				m_sVersion = val;
			}
		}
	}
}

std::string PlexServer::GetUri() {
	return std::string("http://") + m_sIpAddress + ":" + std::string(itoa(m_nPort));
}

PlexServer::~PlexServer()
{
}

}