Browse Source

Formatting

pull/271/head
alxlaxv 7 years ago
committed by GitHub
parent
commit
2042c125a2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 26
      app/SupportedApps/Sonarr.php

26
app/SupportedApps/Sonarr.php

@ -2,43 +2,49 @@
use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client; use GuzzleHttp\Client;
class Sonarr implements Contracts\Applications, Contracts\Livestats { class Sonarr implements Contracts\Applications, Contracts\Livestats
{
public function defaultColour() public function defaultColour()
{ {
return '#163740'; return '#163740';
} }
public function icon() public function icon()
{ {
return 'supportedapps/sonarr.png'; return 'supportedapps/sonarr.png';
} }
public function configDetails() public function configDetails()
{ {
return 'sonarr'; return 'sonarr';
} }
public function testConfig() public function testConfig()
{ {
$res = $this->getStatus(); $res = $this->getStatus();
$status = json_decode($res->getBody()); $status = json_decode($res->getBody());
if(isset($status->version)) if (isset($status->version))
{ {
echo 'Successfully connected to Sonarr API version ' . $status->version; echo 'Successfully connected to Sonarr API version ' . $status->version;
} }
else if(isset($status->error)) else if (isset($status->error))
{ {
if($status->error == "Unauthorized") if ($status->error == "Unauthorized")
{ {
echo 'Incorrect API Key. You can find it in Settings > General'; echo 'Incorrect API Key. You can find it in Settings > General';
} }
else else
{ {
echo 'Error: '. $status->error; echo 'Error: ' . $status->error;
} }
} }
else else
{ {
echo 'Something went wrong'; echo 'Something went wrong';
} }
} }
public function executeConfig() public function executeConfig()
{ {
$html = ''; $html = '';
@ -51,6 +57,7 @@ class Sonarr implements Contracts\Applications, Contracts\Livestats {
'; ';
return json_encode(['status' => $active, 'html' => $html]); return json_encode(['status' => $active, 'html' => $html]);
} }
public function getStatus() public function getStatus()
{ {
$config = $this->config; $config = $this->config;
@ -61,6 +68,7 @@ class Sonarr implements Contracts\Applications, Contracts\Livestats {
$res = $client->request('GET', $api_url); $res = $client->request('GET', $api_url);
return $res; return $res;
} }
public function getWanted() public function getWanted()
{ {
$config = $this->config; $config = $this->config;
@ -70,11 +78,13 @@ class Sonarr implements Contracts\Applications, Contracts\Livestats {
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); $client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]);
$res = json_decode($client->request('GET', $api_url)); $res = json_decode($client->request('GET', $api_url));
$wanted = $res->totalRecords; $wanted = $res->totalRecords;
if (empty($wanted)) { if (empty($wanted))
$wanted=0; {
$wanted = 0;
} }
return $wanted; return $wanted;
} }
public function getQueue() public function getQueue()
{ {
$config = $this->config; $config = $this->config;

Loading…
Cancel
Save