|  | @ -44,25 +44,27 @@ class Sabnzbd implements Contracts\Applications, Contracts\Livestats { | 
			
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |     public function executeConfig() |  |  |     public function executeConfig() | 
			
		
	
		
		
			
				
					|  |  |     { |  |  |     { | 
			
		
	
		
		
			
				
					
					|  |  |         $output = ''; |  |  |         $html = ''; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |  |  |  |         $active = 'inactive'; | 
			
		
	
		
		
			
				
					|  |  |         $res = $this->buildRequest('queue'); |  |  |         $res = $this->buildRequest('queue'); | 
			
		
	
		
		
			
				
					|  |  |         $data = json_decode($res->getBody()); |  |  |         $data = json_decode($res->getBody()); | 
			
		
	
		
		
			
				
					|  |  |         //$data->result->RemainingSizeMB = '10000000'; |  |  |         //$data->result->RemainingSizeMB = '10000000'; | 
			
		
	
		
		
			
				
					|  |  |         //$data->result->DownloadRate = '100000000'; |  |  |         //$data->result->DownloadRate = '100000000'; | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         if($data) { | 
			
		
	
		
		
			
				
					|  |  |             $size = $data->queue->mbleft; |  |  |             $size = $data->queue->mbleft; | 
			
		
	
		
		
			
				
					|  |  |             $rate = $data->queue->kbpersec; |  |  |             $rate = $data->queue->kbpersec; | 
			
		
	
		
		
			
				
					|  |  |             $queue_size = format_bytes($size*1000*1000, false, ' <span>', '</span>'); |  |  |             $queue_size = format_bytes($size*1000*1000, false, ' <span>', '</span>'); | 
			
		
	
		
		
			
				
					|  |  |             $current_speed = format_bytes($rate*1000, false, ' <span>'); |  |  |             $current_speed = format_bytes($rate*1000, false, ' <span>'); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |         if($size > 0 || $rate > 0) { |  |  |             $active = ($size > 0 || $rate > 0) ? 'active' : 'inactive'; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |             $output = ' |  |  |             $html = ' | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					|  |  |                 <ul class="livestats"> |  |  |                 <ul class="livestats"> | 
			
		
	
		
		
			
				
					|  |  |                     <li><span class="title">Queue</span><strong>'.$queue_size.'</strong></li> |  |  |                     <li><span class="title">Queue</span><strong>'.$queue_size.'</strong></li> | 
			
		
	
		
		
			
				
					|  |  |                     <li><span class="title">Speed</span><strong>'.$current_speed.'/s</span></strong></li> |  |  |                     <li><span class="title">Speed</span><strong>'.$current_speed.'/s</span></strong></li> | 
			
		
	
		
		
			
				
					|  |  |                 </ul> |  |  |                 </ul> | 
			
		
	
		
		
			
				
					|  |  |             '; |  |  |             '; | 
			
		
	
		
		
			
				
					|  |  |         } |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |         return $output; |  |  |         return json_encode(['status' => $active, 'html' => $html]); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |     } |  |  |     } | 
			
		
	
		
		
			
				
					|  |  |     public function buildRequest($endpoint) |  |  |     public function buildRequest($endpoint) | 
			
		
	
		
		
			
				
					|  |  |     { |  |  |     { | 
			
		
	
	
		
		
			
				
					|  | @ -70,12 +72,15 @@ class Sabnzbd implements Contracts\Applications, Contracts\Livestats { | 
			
		
	
		
		
			
				
					|  |  |         $url = $config->url; |  |  |         $url = $config->url; | 
			
		
	
		
		
			
				
					|  |  |         $apikey = $config->apikey; |  |  |         $apikey = $config->apikey; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //print_r($config); | 
			
		
	
		
		
			
				
					|  |  |  |  |  |         //die(); | 
			
		
	
		
		
			
				
					|  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         $url = rtrim($url, '/'); |  |  |         $url = rtrim($url, '/'); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					|  |  |         $api_url = $url.'/api?output=json&apikey='.$apikey.'&mode='.$endpoint; |  |  |         $api_url = $url.'/api?output=json&apikey='.$apikey.'&mode='.$endpoint; | 
			
		
	
		
		
			
				
					|  |  |         //die( $api_url.' --- '); |  |  |         //die( $api_url.' --- '); | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |         $client = new Client(['http_errors' => false]); |  |  |         $client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					|  |  |         $res = $client->request('GET', $api_url); |  |  |         $res = $client->request('GET', $api_url); | 
			
		
	
		
		
			
				
					|  |  |         return $res; |  |  |         return $res; | 
			
		
	
		
		
			
				
					|  |  | 
 |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  | 
 |