diff options
author | chriszero <zerov83@gmail.com> | 2015-02-22 16:41:24 +0100 |
---|---|---|
committer | chriszero <zerov83@gmail.com> | 2015-02-22 16:41:24 +0100 |
commit | e44cc781e25490f0d942aa09cb383efd30e5e50d (patch) | |
tree | 44e67db9ffe7f6d6b131c5110061d7e8fcc8df66 | |
parent | 1d6583bf592119c85bfcbf2cc6f22aef364396e4 (diff) | |
download | vdr-plugin-plex-e44cc781e25490f0d942aa09cb383efd30e5e50d.tar.gz vdr-plugin-plex-e44cc781e25490f0d942aa09cb383efd30e5e50d.tar.bz2 |
Added option to completly disable using plex account0.1.1
-rw-r--r-- | Config.cpp | 3 | ||||
-rw-r--r-- | Config.h | 2 | ||||
-rw-r--r-- | Plexservice.cpp | 18 | ||||
-rw-r--r-- | plex.cpp | 1 |
4 files changed, 17 insertions, 7 deletions
@@ -70,6 +70,7 @@ cMyMenuSetupPage::cMyMenuSetupPage(void) Add(new cMenuEditBoolItem(tr("Hide main menu entry"), (int*)&HideMainMenuEntry, trVDR("no"), trVDR("yes"))); Add(new cMenuEditBoolItem(tr("Use custom transcoding profile"), (int*)&UseCustomTranscodeProfile, trVDR("no"), trVDR("yes"))); + Add(new cMenuEditBoolItem(tr("Use Plex account"), (int*)&UsePlexAccount, trVDR("no"), trVDR("yes"))); Add(new cMenuEditStrItem(tr("Plex Username"), Username, STRING_SIZE)); Add(new cMenuEditStrItem(tr("Plex Password"), Password, STRING_SIZE)); cMenuEditStrItem* devUUID = new cMenuEditStrItem(tr("Current UUID"), Uuid, STRING_SIZE); @@ -86,9 +87,11 @@ void cMyMenuSetupPage::Store(void) Config::GetInstance().s_password = std::string(Password); Config::GetInstance().HideMainMenuEntry = HideMainMenuEntry; Config::GetInstance().UseCustomTranscodeProfile = UseCustomTranscodeProfile; + Config::GetInstance().UsePlexAccount = UsePlexAccount; SetupStore("UseCustomTranscodeProfile", Config::GetInstance().UseCustomTranscodeProfile); SetupStore("HideMainMenuEntry", Config::GetInstance().HideMainMenuEntry); + SetupStore("UsePlexAccount", Config::GetInstance().UsePlexAccount); SetupStore("Username", Config::GetInstance().s_username.c_str()); SetupStore("Password", Config::GetInstance().s_password.c_str()); SetupStore("UUID", Config::GetInstance().GetUUID().c_str()); @@ -29,6 +29,7 @@ public: bool HideMainMenuEntry; bool UseCustomTranscodeProfile; + bool UsePlexAccount; std::string GetUUID(); void SetUUID(const char* uuid); @@ -60,6 +61,7 @@ class cMyMenuSetupPage:public cMenuSetupPage char Uuid[STRING_SIZE]; int HideMainMenuEntry; int UseCustomTranscodeProfile; + int UsePlexAccount; virtual void Store(void); diff --git a/Plexservice.cpp b/Plexservice.cpp index 2c0bdb7..5bee008 100644 --- a/Plexservice.cpp +++ b/Plexservice.cpp @@ -39,7 +39,7 @@ std::string Plexservice::GetMyPlexToken() { static bool done; static std::string myToken; - + //todo: cache token in file or db if(!done) { std::stringstream ss; @@ -85,6 +85,7 @@ std::string Plexservice::GetMyPlexToken() void Plexservice::Authenticate() { + if(!Config::GetInstance().UsePlexAccount) return; try { if(GetHttpSession(true)) { std::string token = GetMyPlexToken(); @@ -122,7 +123,7 @@ std::shared_ptr<MediaContainer> Plexservice::GetSection(std::string section, boo } else { uri = Poco::format("%s/%s", m_vUriStack.top(), section); } - + pRequest = CreateRequest(uri); if(putOnStack) { m_vUriStack.push(uri); @@ -135,7 +136,7 @@ std::shared_ptr<MediaContainer> Plexservice::GetSection(std::string section, boo dsyslog("[plex] URI: http://%s:32400%s", m_pPlexSession->getHost().c_str(), pRequest->getURI().c_str()); std::shared_ptr<MediaContainer> pAllsections(new MediaContainer(&rs, *pServer)); - + delete pRequest; return pAllsections; @@ -164,10 +165,13 @@ Poco::Net::HTTPRequest* Plexservice::CreateRequest(std::string path) path, Poco::Net::HTTPMessage::HTTP_1_1); PlexHelper::AddHttpHeader(*pRequest); - // Add PlexToken to Header - std::string token = GetMyPlexToken(); - if(!token.empty()) - pRequest->add("X-Plex-Token", token); + + if(Config::GetInstance().UsePlexAccount) { + // Add PlexToken to Header + std::string token = GetMyPlexToken(); + if(!token.empty()) + pRequest->add("X-Plex-Token", token); + } return pRequest; } @@ -373,6 +373,7 @@ bool cMyPlugin::SetupParse(const char *name, const char *value) //dsyslog("[plex]%s: '%s' = '%s'\n", __FUNCTION__, name, value); if (strcasecmp(name, "HideMainMenuEntry") == 0) Config::GetInstance().HideMainMenuEntry = atoi(value) ? true : false; + else if (strcasecmp(name, "UsePlexAccount") == 0) Config::GetInstance().UsePlexAccount = atoi(value) ? true : false; else if (strcasecmp(name, "UseCustomTranscodeProfile") == 0) Config::GetInstance().UseCustomTranscodeProfile = atoi(value) ? true : false; else if (strcasecmp(name, "Username") == 0) Config::GetInstance().s_username = std::string(value); else if (strcasecmp(name, "Password") == 0) Config::GetInstance().s_password = std::string(value); |