summaryrefslogtreecommitdiff
path: root/Plexservice.h
blob: 97bf8a2d2dd861dbdd0e4c817b48cd4e0469faa3 (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
74
75
76
77
78
#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(PlexServer *server, std::string startUri);

        std::shared_ptr<MediaContainer> GetSection(std::string section, bool putOnStack = true);

        std::shared_ptr<MediaContainer> GetLastSection(bool current = false);

        bool IsRoot();

        PlexServer *GetServer();

        void Authenticate();

        static std::string GetUniversalTranscodeUrl(cVideo *video, int offset = 0, PlexServer *server = 0,
                                                    bool http = false);

        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;

    private:
        Poco::Mutex m_mutex;
        PlexServer *pServer;

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

        std::unique_ptr<Poco::Net::HTTPRequest> CreateRequest(std::string path);

    };

}

#endif // PLEXSERVICE_H