summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchriszero <zerov83@gmail.com>2015-02-22 16:41:24 +0100
committerchriszero <zerov83@gmail.com>2015-02-22 16:41:24 +0100
commite44cc781e25490f0d942aa09cb383efd30e5e50d (patch)
tree44e67db9ffe7f6d6b131c5110061d7e8fcc8df66
parent1d6583bf592119c85bfcbf2cc6f22aef364396e4 (diff)
downloadvdr-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.cpp3
-rw-r--r--Config.h2
-rw-r--r--Plexservice.cpp18
-rw-r--r--plex.cpp1
4 files changed, 17 insertions, 7 deletions
diff --git a/Config.cpp b/Config.cpp
index c3a5abf..0dc889c 100644
--- a/Config.cpp
+++ b/Config.cpp
@@ -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());
diff --git a/Config.h b/Config.h
index d6412e7..21b9b94 100644
--- a/Config.h
+++ b/Config.h
@@ -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;
}
diff --git a/plex.cpp b/plex.cpp
index cf5f945..a8ad435 100644
--- a/plex.cpp
+++ b/plex.cpp
@@ -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);