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\Client;
class Sonarr implements Contracts\Applications, Contracts\Livestats {
class Sonarr implements Contracts\Applications, Contracts\Livestats
{
public function defaultColour()
{
return '#163740';
}
public function icon()
{
return 'supportedapps/sonarr.png';
}
public function configDetails()
{
return 'sonarr';
}
public function testConfig()
{
$res = $this->getStatus();
$status = json_decode($res->getBody());
if(isset($status->version))
if (isset($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';
}
else
{
echo 'Error: '. $status->error;
echo 'Error: ' . $status->error;
}
}
else
{
echo 'Something went wrong';
echo 'Something went wrong';
}
}
public function executeConfig()
{
$html = '';
@ -51,6 +57,7 @@ class Sonarr implements Contracts\Applications, Contracts\Livestats {
';
return json_encode(['status' => $active, 'html' => $html]);
}
public function getStatus()
{
$config = $this->config;
@ -61,6 +68,7 @@ class Sonarr implements Contracts\Applications, Contracts\Livestats {
$res = $client->request('GET', $api_url);
return $res;
}
public function getWanted()
{
$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]);
$res = json_decode($client->request('GET', $api_url));
$wanted = $res->totalRecords;
if (empty($wanted)) {
$wanted=0;
if (empty($wanted))
{
$wanted = 0;
}
return $wanted;
}
public function getQueue()
{
$config = $this->config;

Loading…
Cancel
Save