Explorar o código

fix plex connection test button

CauseFX %!s(int64=5) %!d(string=hai) anos
pai
achega
7259afb4f0
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      api/homepage/plex.php

+ 5 - 2
api/homepage/plex.php

@@ -209,7 +209,7 @@ trait PlexHomepageItem
 	public function testConnectionPlex()
 	{
 		if (!empty($this->config['plexURL']) && !empty($this->config['plexToken'])) {
-			$url = $this->qualifyURL($this->config['plexURL']) . "/?X-Plex-Token=" . $this->config['plexToken'];
+			$url = $this->qualifyURL($this->config['plexURL']) . "/servers?X-Plex-Token=" . $this->config['plexToken'];
 			try {
 				$options = ($this->localURL($url)) ? array('verify' => false) : array();
 				$response = Requests::get($url, array(), $options);
@@ -217,11 +217,14 @@ trait PlexHomepageItem
 				if ($response->success) {
 					$this->setAPIResponse('success', 'API Connection succeeded', 200);
 					return true;
+				} else {
+					$this->setAPIResponse('error', 'URL and/or Token not setup correctly', 422);
+					return false;
 				}
 			} catch (Requests_Exception $e) {
 				$this->setAPIResponse('error', $e->getMessage(), 500);
 				return false;
-			};
+			}
 		} else {
 			$this->setAPIResponse('error', 'URL and/or Token not setup', 422);
 			return 'URL and/or Token not setup';