summaryrefslogtreecommitdiff
path: root/Plexservice.h
blob: 4f81cafa9f09181bff1fa6f8cae10fb8ceb5e9c9 (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
66
67
68
69
70
71
72
73
#ifndef PLEXSERVICE_H
#define PLEXSERVICE_H

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

#include <sstream>
#include <iostream>
#include <string>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <memory>
#include <time.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/ScopedLock.h>
#include <Poco/Mutex.h>
#include <Poco/Format.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();
	std::shared_ptr<MediaContainer> GetSection(std::string section, bool putOnStack = true);
	std::shared_ptr<MediaContainer> GetLastSection(bool current = false);
	void GetAuthDetails();
	void Authenticate();
	PlexServer* GetServer();
	
	static std::string GetUniversalTranscodeUrl(Video* video, int offset = 0, PlexServer* server = 0);
	static std::string GetMyPlexToken();
	static MediaContainer GetMediaContainer(std::string fullUrl);
	static std::string encode(std::string message);

	std::string StartUri;

private:
	Poco::Mutex m_mutex;
	Poco::Net::HTTPClientSession *m_pPlexSession;
	PlexServer *pServer;

	std::stack<std::string> m_vUriStack;

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

}

#endif // PLEXSERVICE_H