summaryrefslogtreecommitdiff
path: root/Plexservice.h
blob: aad20a98ef358eac5365f9b3f07f388254d60091 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#ifndef PLEXSERVICE_H
#define PLEXSERVICE_H

//#include "plexgdm.h"
#include "PlexServer.h"

#include <sstream>
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <stdlib.h>

#include <Poco/Base64Encoder.h>
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPSClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
#include <Poco/Net/MessageHeader.h>
#include <Poco/Net/Context.h>
#include <Poco/Exception.h>
#include <Poco/Format.h>
#include <Poco/URI.h>

#include <Poco/StreamCopier.h>

#include "Config.h"
#include "user.h"
#include "MediaContainer.h"

namespace plexclient
{

class Plexservice
{
public:
	Plexservice(PlexServer *server);
	~Plexservice();

	void DisplaySections();
	MediaContainer* GetAllSections();
	MediaContainer* GetSection(std::string section);
	void GetAuthDetails();
	std::string GetMyPlexToken();
	void Authenticate();
	//void DiscoverFirstServer();
	PlexServer* GetServer();
	
	static MediaContainer* GetMediaContainer(std::string fullUrl);

private:
	std::string USERAGENT;

	Poco::Net::HTTPClientSession *m_pPlexSession;
	PlexServer *pServer;
	std::string m_sToken;

	Poco::Net::HTTPClientSession* GetHttpSession(bool createNew = false);
	Poco::Net::HTTPRequest* CreateRequest(std::string path);

};

}

#endif // PLEXSERVICE_H