From 6b8e9d39a0e07e4e5879749702a23c6173305998 Mon Sep 17 00:00:00 2001 From: alxlaxv <35723598+alxlaxv@users.noreply.github.com> Date: Fri, 19 Oct 2018 18:55:49 +0200 Subject: [PATCH] Update Sonarr.php --- app/SupportedApps/Sonarr.php | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/app/SupportedApps/Sonarr.php b/app/SupportedApps/Sonarr.php index 2035ffd5..c276aa33 100644 --- a/app/SupportedApps/Sonarr.php +++ b/app/SupportedApps/Sonarr.php @@ -36,16 +36,10 @@ class Sonarr implements Contracts\Applications, Contracts\Livestats { { $html = ''; $active = 'active'; - $wantedRes = $this->getWanted(); - $queueRes = $this->getQueue(); - $wanted = json_decode($wantedRes->getBody()); - $queue = json_decode($queueRes->getBody()); - $wantedCount = $wanted->totalRecords; - $queueCount = sizeof($queue); $html = ' '; return json_encode(['status' => $active, 'html' => $html]); @@ -67,8 +61,12 @@ class Sonarr implements Contracts\Applications, Contracts\Livestats { $url = rtrim($url, '/'); $api_url = $url.'/api/wanted/missing?apikey='.$config->apiKey.'&pageSize=1'; $client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); - $res = $client->request('GET', $api_url); - return $res; + $res = json_decode($client->request('GET', $api_url)); + $wanted = $res->totalRecords; + if (empty($wanted)) { + $wanted=0; + } + return $wanted; } public function getQueue() { @@ -77,7 +75,7 @@ class Sonarr implements Contracts\Applications, Contracts\Livestats { $url = rtrim($url, '/'); $api_url = $url.'/api/queue?apikey='.$config->apiKey.'&pageSize=1'; $client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); - $res = $client->request('GET', $api_url); - return $res; + $queue = sizeof($client->request('GET', $api_url)); + return $queue; } }