Chris
6 years ago
69 changed files with 30 additions and 1719 deletions
@ -0,0 +1,30 @@ |
|||||
|
<?php namespace App; |
||||
|
|
||||
|
use GuzzleHttp\Exception\GuzzleException; |
||||
|
use GuzzleHttp\Client; |
||||
|
|
||||
|
abstract class SupportedApps |
||||
|
{ |
||||
|
public $config; |
||||
|
|
||||
|
public function test($url, $requiresLoginFirst=false) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public function execute($url, $requiresLoginFirst=false) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public function login() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public function apiRequest($url) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
} |
@ -1,11 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
class AirSonic implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#08F'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/airsonic.png'; |
|
||||
} |
|
||||
} |
|
@ -1,14 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Bazarr implements Contracts\Applications { |
|
||||
|
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#222'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/bazarr.png'; |
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Bitwarden implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#3c8dbc'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/bitwarden.png'; |
|
||||
} |
|
||||
} |
|
@ -1,14 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class BookStack implements Contracts\Applications { |
|
||||
|
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#02679E'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/bookstack.png'; |
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Booksonic implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#58a'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/booksonic.png'; |
|
||||
} |
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
class Cardigann implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#753'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/cardigann.png'; |
|
||||
} |
|
||||
} |
|
@ -1,9 +0,0 @@ |
|||||
<?php namespace App\SupportedApps\Contracts; |
|
||||
|
|
||||
interface Applications { |
|
||||
|
|
||||
public function defaultColour(); |
|
||||
|
|
||||
public function icon(); |
|
||||
|
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
<?php namespace App\SupportedApps\Contracts; |
|
||||
|
|
||||
interface Livestats { |
|
||||
|
|
||||
public function configDetails(); |
|
||||
|
|
||||
public function testConfig(); |
|
||||
|
|
||||
public function executeConfig(); |
|
||||
|
|
||||
} |
|
@ -1,122 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
use GuzzleHttp\Exception\GuzzleException; |
|
||||
use GuzzleHttp\Client; |
|
||||
use Illuminate\Support\Facades\Log; |
|
||||
|
|
||||
class CouchPotato implements Contracts\Applications, Contracts\Livestats |
|
||||
{ |
|
||||
|
|
||||
private $_client; |
|
||||
|
|
||||
public function __construct() |
|
||||
{ |
|
||||
$this->_client = new Client( |
|
||||
['http_errors' => false, |
|
||||
'timeout' => 10] |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#363840'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/couchpotato.png'; |
|
||||
} |
|
||||
public function configDetails() |
|
||||
{ |
|
||||
return 'couchpotato'; |
|
||||
} |
|
||||
public function testConfig() |
|
||||
{ |
|
||||
$res = $this->sendRequest(); |
|
||||
if ($res == null) { |
|
||||
echo 'CouchPotato connection failed'; |
|
||||
return; |
|
||||
} |
|
||||
switch($res->getStatusCode()) { |
|
||||
case 200: |
|
||||
echo "Successfully connected to CouchPotato"; |
|
||||
break; |
|
||||
case 401: |
|
||||
echo 'Failed: Invalid credentials'; |
|
||||
break; |
|
||||
case 404: |
|
||||
echo 'Failed: Please make sure your URL is correct and includes the port'; |
|
||||
break; |
|
||||
case 409: |
|
||||
echo 'Failed: Incorrect session id'; |
|
||||
break; |
|
||||
default: |
|
||||
echo 'Something went wrong... Code: '.$res->getStatusCode(); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public function executeConfig() |
|
||||
{ |
|
||||
$html = ''; |
|
||||
$res = $this->sendRequest(); |
|
||||
if ($res == null) { |
|
||||
Log::debug('CouchPotato connection failed'); |
|
||||
return ''; |
|
||||
} |
|
||||
$data = json_decode($res->getBody()); |
|
||||
if (! isset($data->movies)) { |
|
||||
Log::debug('Failed to fetch data from CouchPotato'); |
|
||||
return ''; |
|
||||
} |
|
||||
$movies = $data->movies; |
|
||||
$wantedMovies = $availableMovies = 0; |
|
||||
foreach ($movies as $v) { |
|
||||
switch ($v->status) { |
|
||||
case 'active': |
|
||||
$wantedMovies++; |
|
||||
break; |
|
||||
case 'done': |
|
||||
$availableMovies++; |
|
||||
break; |
|
||||
default: |
|
||||
Log::warning('Unexpected CouchPotato status received: '.$v['status']); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
$html = ' |
|
||||
<ul class="livestats"> |
|
||||
<li><span class="title">Wanted</span><sub>'.$wantedMovies.'</sub></li> |
|
||||
<li><span class="title">Available</span><sub>'.$availableMovies.'</sub></li> |
|
||||
</ul> |
|
||||
'; |
|
||||
return json_encode(['status' => 'inactive', 'html' => $html]); |
|
||||
} |
|
||||
|
|
||||
private function sendRequest() |
|
||||
{ |
|
||||
$res = null; |
|
||||
try{ |
|
||||
$res = $this->_client->request( |
|
||||
'GET', |
|
||||
$this->getApiUrl() |
|
||||
); |
|
||||
}catch(\GuzzleHttp\Exception\BadResponseException $e){ |
|
||||
Log::error("Connection to {$e->getRequest()->getUrl()} failed"); |
|
||||
Log::debug($e->getMessage()); |
|
||||
$res = $e->getRequest(); |
|
||||
}catch(\GuzzleHttp\Exception\ConnectException $e) { |
|
||||
Log::error("CouchPotato connection refused"); |
|
||||
Log::debug($e->getMessage()); |
|
||||
} |
|
||||
return $res; |
|
||||
} |
|
||||
|
|
||||
private function getApiUrl() |
|
||||
{ |
|
||||
$url = $this->config->url; |
|
||||
$url = rtrim($url, '/'); |
|
||||
$apiUrl = $url.'/api/'.$this->config->apikey.'/movie.list'; |
|
||||
return $apiUrl; |
|
||||
} |
|
||||
} |
|
@ -1,109 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
use GuzzleHttp\Exception\GuzzleException; |
|
||||
use GuzzleHttp\Client; |
|
||||
class Deluge implements Contracts\Applications, Contracts\Livestats { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#357'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/deluge.png'; |
|
||||
} |
|
||||
|
|
||||
public function configDetails() |
|
||||
{ |
|
||||
return 'deluge'; |
|
||||
} |
|
||||
|
|
||||
public function testConfig() |
|
||||
{ |
|
||||
$res = $this->login()[0]; |
|
||||
switch($res->getStatusCode()) { |
|
||||
case 200: |
|
||||
$data = json_decode($res->getBody()); |
|
||||
if(!isset($data->result) || is_null($data->result) || $data->result == false) { |
|
||||
echo 'Failed: Invalid Credentials'; |
|
||||
} else { |
|
||||
echo 'Successfully connected to the API'; |
|
||||
} |
|
||||
break; |
|
||||
case 401: |
|
||||
echo 'Failed: Invalid credentials'; |
|
||||
break; |
|
||||
case 404: |
|
||||
echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; |
|
||||
break; |
|
||||
default: |
|
||||
echo 'Something went wrong... Code: '.$res->getStatusCode(); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
public function executeConfig() |
|
||||
{ |
|
||||
$html = ''; |
|
||||
$active = 'active'; |
|
||||
$jar = $this->login()[1]; |
|
||||
$res = $this->getDetails($jar); |
|
||||
$data = json_decode($res->getBody()); |
|
||||
$download_rate = $data->result->stats->download_rate; |
|
||||
$upload_rate = $data->result->stats->upload_rate; |
|
||||
$seed_count = $data->result->filters->state[2]; |
|
||||
$leech_count = $data->result->filters->state[1]; |
|
||||
$html = ' |
|
||||
<ul class="livestats"> |
|
||||
<li><span class="title"><i class="fas fa-arrow-down"></i> '.$this->formatBytes($download_rate).'</span></li> |
|
||||
<li><span class="title"><i class="fas fa-arrow-up"></i> '.$this->formatBytes($upload_rate).'</span></li> |
|
||||
</ul> |
|
||||
<ul class="livestats"> |
|
||||
<li><span class="title">Leech: '.$leech_count[1].'</span></li> |
|
||||
<li><span class="title">Seed: '.$seed_count[1].'</span></li> |
|
||||
</ul> |
|
||||
'; |
|
||||
return json_encode(['status' => $active, 'html' => $html]); |
|
||||
} |
|
||||
public function getDetails($jar) |
|
||||
{ |
|
||||
$config = $this->config; |
|
||||
$url = $config->url; |
|
||||
$url = rtrim($url, '/'); |
|
||||
$api_url = $url.'/json'; |
|
||||
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); |
|
||||
$res = $client->request('POST', $api_url, [ |
|
||||
'body' => '{"method": "web.update_ui", "params": [["none"], {}], "id": 1}', |
|
||||
'cookies' => $jar, |
|
||||
'headers' => ['content-type' => 'application/json', 'Accept' => 'application/json'] |
|
||||
]); |
|
||||
return $res; |
|
||||
} |
|
||||
public function login() |
|
||||
{ |
|
||||
$config = $this->config; |
|
||||
$url = $config->url; |
|
||||
$password = $config->password; |
|
||||
$url = rtrim($url, '/'); |
|
||||
$api_url = $url.'/json'; |
|
||||
$jar = new \GuzzleHttp\Cookie\CookieJar(); |
|
||||
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); |
|
||||
$res = $client->request('POST', $api_url, [ |
|
||||
'body' => '{"method": "auth.login", "params": ["'.$password.'"], "id": 1}', |
|
||||
'cookies' => $jar, |
|
||||
'headers' => ['content-type' => 'application/json', 'Accept' => 'application/json'] |
|
||||
]); |
|
||||
return array($res,$jar); |
|
||||
} |
|
||||
|
|
||||
function formatBytes($bytes, $precision = 2) { |
|
||||
$units = array('B', 'KB', 'MB', 'GB', 'TB'); |
|
||||
|
|
||||
$bytes = max($bytes, 0); |
|
||||
$pow = floor(($bytes ? log($bytes) : 0) / log(1024)); |
|
||||
$pow = min($pow, count($units) - 1); |
|
||||
|
|
||||
// Uncomment one of the following alternatives |
|
||||
$bytes /= pow(1024, $pow); |
|
||||
// $bytes /= (1 << (10 * $pow)); |
|
||||
|
|
||||
return round($bytes, $precision) . ' ' . $units[$pow] . 'ps'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Dokuwiki implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#9d7056'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/dokuwiki.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Duplicati implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#2c3744'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/duplicati.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Emby implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#222'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/emby.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Flood implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '##00D091'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/Flood.png'; |
|
||||
} |
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
class FreshRSS implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#003B73'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/freshrss.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Gitea implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#585e52'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/gitea.png'; |
|
||||
} |
|
||||
} |
|
@ -1,14 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Glances implements Contracts\Applications { |
|
||||
|
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#2c363f'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/glances.png'; |
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Grafana implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#a56e4d'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/grafana.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Graylog implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#158'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/graylog.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Headphones implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#185'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/headphones.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class HomeAssistant implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#073c52'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/homeassistant.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Jackett implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#484814'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/jackett.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Jdownloader implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#2b494f'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/jdownloader.png'; |
|
||||
} |
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
class Krusader implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#5A5'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/krusader.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Lidarr implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#183c18'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/lidarr.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Mailcow implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#161b1f'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/mailcow.svg'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Mcmyadmin implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#30404b'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/mcmyadmin.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Medusa implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#4b5e55'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/medusa.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Monica implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#fafbfc'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/monica.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class MusicBrainz implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#a0a'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/musicbrainz.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Mylar implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#aa0'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/mylar.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Netdata implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#543737'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/netdata.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Nextcloud implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#0e2c3e'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/nextcloud.png'; |
|
||||
} |
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
class NowShowing implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#690000'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/nowshowing.png'; |
|
||||
} |
|
||||
} |
|
@ -1,84 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
use GuzzleHttp\Exception\GuzzleException; |
|
||||
use GuzzleHttp\Client; |
|
||||
|
|
||||
class Nzbget implements Contracts\Applications, Contracts\Livestats { |
|
||||
|
|
||||
public $config; |
|
||||
|
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#253827'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/nzbget.png'; |
|
||||
} |
|
||||
public function configDetails() |
|
||||
{ |
|
||||
return 'nzbget'; |
|
||||
} |
|
||||
public function testConfig() |
|
||||
{ |
|
||||
$res = $this->buildRequest('status'); |
|
||||
switch($res->getStatusCode()) { |
|
||||
case 200: |
|
||||
echo 'Successfully connected to the API'; |
|
||||
break; |
|
||||
case 401: |
|
||||
echo 'Failed: Invalid credentials'; |
|
||||
break; |
|
||||
case 404: |
|
||||
echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; |
|
||||
break; |
|
||||
default: |
|
||||
echo 'Something went wrong... Code: '.$res->getStatusCode(); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
public function executeConfig() |
|
||||
{ |
|
||||
$html = ''; |
|
||||
$active = 'inactive'; |
|
||||
$res = $this->buildRequest('status'); |
|
||||
$data = json_decode($res->getBody()); |
|
||||
//$data->result->RemainingSizeMB = '10000000'; |
|
||||
//$data->result->DownloadRate = '100000000'; |
|
||||
if($data) { |
|
||||
$size = $data->result->RemainingSizeMB; |
|
||||
$rate = $data->result->DownloadRate; |
|
||||
$queue_size = format_bytes($size*1000*1000, false, ' <span>', '</span>'); |
|
||||
$current_speed = format_bytes($rate, false, ' <span>'); |
|
||||
|
|
||||
$active = ($size > 0 || $rate > 0) ? 'active' : 'inactive'; |
|
||||
$html = ' |
|
||||
<ul class="livestats"> |
|
||||
<li><span class="title">Queue</span><strong>'.$queue_size.'</strong></li> |
|
||||
<li><span class="title">Speed</span><strong>'.$current_speed.'/s</span></strong></li> |
|
||||
</ul> |
|
||||
'; |
|
||||
} |
|
||||
return json_encode(['status' => $active, 'html' => $html]); |
|
||||
} |
|
||||
public function buildRequest($endpoint) |
|
||||
{ |
|
||||
$config = $this->config; |
|
||||
$url = $config->url; |
|
||||
$username = $config->username; |
|
||||
$password = $config->password; |
|
||||
|
|
||||
$rebuild_url = str_replace('http://', 'http://'.$username.':'.$password.'@', $url); |
|
||||
$rebuild_url = str_replace('https://', 'https://'.$username.':'.$password.'@', $rebuild_url); |
|
||||
$rebuild_url = rtrim($rebuild_url, '/'); |
|
||||
|
|
||||
|
|
||||
$api_url = $rebuild_url.'/jsonrpc/'.$endpoint; |
|
||||
|
|
||||
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); |
|
||||
$res = $client->request('GET', $api_url); |
|
||||
return $res; |
|
||||
|
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Nzbhydra implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#53644d'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/nzbhydra.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Ombi implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#150f09'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/ombi.png'; |
|
||||
} |
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
class OpenMediaVault implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#5AF'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/openmediavault.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Openhab implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#2b2525'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/openhab.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Opnsense implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#211914'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/opnsense.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Pfsense implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#243699'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/pfsense.png'; |
|
||||
} |
|
||||
} |
|
@ -1,73 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
use GuzzleHttp\Exception\GuzzleException; |
|
||||
use GuzzleHttp\Client; |
|
||||
|
|
||||
class Pihole implements Contracts\Applications, Contracts\Livestats { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#352222'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/pihole.png'; |
|
||||
} |
|
||||
|
|
||||
public function configDetails() |
|
||||
{ |
|
||||
return 'pihole'; |
|
||||
} |
|
||||
|
|
||||
public function testConfig() |
|
||||
{ |
|
||||
$res = $this->buildRequest(); |
|
||||
switch($res->getStatusCode()) { |
|
||||
case 200: |
|
||||
echo 'Successfully connected to the API'; |
|
||||
break; |
|
||||
case 401: |
|
||||
echo 'Failed: Invalid credentials'; |
|
||||
break; |
|
||||
case 404: |
|
||||
echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; |
|
||||
break; |
|
||||
default: |
|
||||
echo 'Something went wrong... Code: '.$res->getStatusCode(); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public function executeConfig() |
|
||||
{ |
|
||||
$html = ''; |
|
||||
$active = 'active'; |
|
||||
$res = $this->buildRequest(); |
|
||||
$data = json_decode($res->getBody()); |
|
||||
|
|
||||
$html = ' |
|
||||
<ul class="livestats"> |
|
||||
<li><span class="title">Domains<br />Blocked</span><strong>'.$data->domains_being_blocked.'</strong></li> |
|
||||
<li><span class="title">Blocked<br />Today</span><strong>'.$data->ads_blocked_today.'</span></strong></li> |
|
||||
</ul> |
|
||||
'; |
|
||||
return json_encode(['status' => $active, 'html' => $html]); |
|
||||
} |
|
||||
|
|
||||
public function buildRequest() |
|
||||
{ |
|
||||
$config = $this->config; |
|
||||
$url = $config->url; |
|
||||
|
|
||||
$url = rtrim($url, '/'); |
|
||||
|
|
||||
$api_url = $url.'/api.php'; |
|
||||
//die( $api_url.' --- '); |
|
||||
|
|
||||
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); |
|
||||
$res = $client->request('GET', $api_url); |
|
||||
return $res; |
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Plex implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#222'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/plex.png'; |
|
||||
} |
|
||||
} |
|
@ -1,77 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
use GuzzleHttp\Exception\GuzzleException; |
|
||||
use GuzzleHttp\Client; |
|
||||
|
|
||||
class Plexpy implements Contracts\Applications, Contracts\Livestats { |
|
||||
|
|
||||
public $config; |
|
||||
|
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#2d2208'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/plexpy.png'; |
|
||||
} |
|
||||
public function configDetails() |
|
||||
{ |
|
||||
return 'plexpy'; |
|
||||
} |
|
||||
public function testConfig() |
|
||||
{ |
|
||||
$res = $this->buildRequest('arnold'); |
|
||||
switch($res->getStatusCode()) { |
|
||||
case 200: |
|
||||
$data = json_decode($res->getBody()); |
|
||||
if(isset($data->error) && !empty($data->error)) { |
|
||||
echo 'Failed: '.$data->error; |
|
||||
} else { |
|
||||
echo 'Successfully connected to the API'; |
|
||||
} |
|
||||
break; |
|
||||
case 401: |
|
||||
echo 'Failed: Invalid credentials'; |
|
||||
break; |
|
||||
case 404: |
|
||||
echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; |
|
||||
break; |
|
||||
default: |
|
||||
echo 'Something went wrong... Code: '.$res->getStatusCode(); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
public function executeConfig() |
|
||||
{ |
|
||||
$html = ''; |
|
||||
$active = 'active'; |
|
||||
$res = $this->buildRequest('get_activity'); |
|
||||
$data = json_decode($res->getBody()); |
|
||||
$stream_count = $data->response->data->stream_count; |
|
||||
|
|
||||
$html = ' |
|
||||
<ul class="livestats"> |
|
||||
<li><span class="title">Stream Count</span><strong>'.$stream_count.'</strong></li> |
|
||||
</ul> |
|
||||
'; |
|
||||
|
|
||||
return json_encode(['status' => $active, 'html' => $html]); |
|
||||
} |
|
||||
public function buildRequest($endpoint) |
|
||||
{ |
|
||||
$config = $this->config; |
|
||||
$url = $config->url; |
|
||||
$apikey = $config->apikey; |
|
||||
|
|
||||
$url = rtrim($url, '/'); |
|
||||
|
|
||||
$api_url = $url.'/api/v2?apikey='.$apikey.'&cmd='.$endpoint; |
|
||||
|
|
||||
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); |
|
||||
$res = $client->request('GET', $api_url); |
|
||||
return $res; |
|
||||
|
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Plexrequests implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#3c2d1c'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/plexrequests.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Portainer implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#283f44'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/portainer.png'; |
|
||||
} |
|
||||
} |
|
@ -1,80 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
use GuzzleHttp\Exception\GuzzleException; |
|
||||
use GuzzleHttp\Client; |
|
||||
|
|
||||
class Proxmox implements Contracts\Applications, Contracts\Livestats { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#542e0a'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/proxmox.png'; |
|
||||
} |
|
||||
|
|
||||
public function configDetails() |
|
||||
{ |
|
||||
//return 'proxmox'; |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
public function testConfig() |
|
||||
{ |
|
||||
/*$res = $this->buildRequest(); |
|
||||
switch($res->getStatusCode()) { |
|
||||
case 200: |
|
||||
echo 'Successfully connected to the API'; |
|
||||
break; |
|
||||
case 401: |
|
||||
echo 'Failed: Invalid credentials'; |
|
||||
break; |
|
||||
case 404: |
|
||||
echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; |
|
||||
break; |
|
||||
default: |
|
||||
echo 'Something went wrong... Code: '.$res->getStatusCode(); |
|
||||
break; |
|
||||
}*/ |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
public function executeConfig() |
|
||||
{ |
|
||||
/* |
|
||||
$output = ''; |
|
||||
$res = $this->buildRequest(); |
|
||||
$data = json_decode($res->getBody()); |
|
||||
|
|
||||
$output = ' |
|
||||
<ul class="livestats"> |
|
||||
<li><span class="title">Domains<br />Blocked</span><strong>'.$data->domains_being_blocked.'</strong></li> |
|
||||
<li><span class="title">Blocked<br />Today</span><strong>'.$data->ads_blocked_today.'</span></strong></li> |
|
||||
</ul> |
|
||||
'; |
|
||||
return $output; |
|
||||
*/ |
|
||||
return null; |
|
||||
} |
|
||||
|
|
||||
public function buildRequest($endpoint='') |
|
||||
{ |
|
||||
$config = $this->config; |
|
||||
|
|
||||
$username = $config->username; |
|
||||
$password = $config->password; |
|
||||
|
|
||||
$url = $config->url; |
|
||||
$url = rtrim($url, '/'); |
|
||||
|
|
||||
$api_url = $url.'/api2/json/'.$endpoint.'?username='.$username.'&password='.$password; |
|
||||
//die( $api_url.' --- '); |
|
||||
|
|
||||
$client = new Client(['http_errors' => false, 'verify' => false ]); |
|
||||
$res = $client->request('GET', $api_url); |
|
||||
return $res; |
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Radarr implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#3e3726'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/radarr.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Rancher implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#78c9cf'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/rancher.png'; |
|
||||
} |
|
||||
} |
|
@ -1,95 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
use GuzzleHttp\Exception\GuzzleException; |
|
||||
use GuzzleHttp\Client; |
|
||||
|
|
||||
class Runeaudio implements Contracts\Applications, Contracts\Livestats { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#05A'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/runeaudio.png'; |
|
||||
} |
|
||||
|
|
||||
public function configDetails() |
|
||||
{ |
|
||||
return 'runeaudio'; |
|
||||
} |
|
||||
|
|
||||
public function testConfig() |
|
||||
{ |
|
||||
$res = $this->buildRequest('status'); |
|
||||
switch($res->getStatusCode()) { |
|
||||
case 200: |
|
||||
echo 'Successfully connected to the API'; |
|
||||
break; |
|
||||
case 401: |
|
||||
echo 'Failed: Invalid credentials'; |
|
||||
break; |
|
||||
case 404: |
|
||||
echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; |
|
||||
break; |
|
||||
default: |
|
||||
echo 'Something went wrong... Code: '.$res->getStatusCode(); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public function executeConfig() |
|
||||
{ |
|
||||
$output = ''; |
|
||||
$active = 'active'; |
|
||||
$artist = ''; |
|
||||
$song_title = ''; |
|
||||
$res = $this->buildRequest('currentsong'); |
|
||||
$array = explode("\n", $res->getBody()); |
|
||||
foreach($array as $item) { |
|
||||
$item_array = explode(": ", $item); |
|
||||
if ($item_array[0] == 'Artist') { |
|
||||
$artist = $item_array[1]; |
|
||||
} elseif ($item_array[0] == 'Title') { |
|
||||
$song_title = $item_array[1]; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
$output = '<ul class="livestats">'; |
|
||||
|
|
||||
if (strlen($artist) > 12) { |
|
||||
$output = $output.'<li><span class="title-marquee"><span>'.$artist.'</span></span></li>'; |
|
||||
} else { |
|
||||
$output = $output.'<li><span class="title">'.$artist.'</span></li>'; |
|
||||
} |
|
||||
|
|
||||
$output = $output.'</ul><ul class="livestats">'; |
|
||||
|
|
||||
if (strlen($song_title) > 12) { |
|
||||
$output = $output.'<li><span class="title-marquee"><span>'.$song_title.'</span></span></li>'; |
|
||||
} else { |
|
||||
$output = $output.'<li><span class="title">'.$song_title.'</span></li>'; |
|
||||
} |
|
||||
|
|
||||
$output = $output.'</ul>'; |
|
||||
|
|
||||
return json_encode(['status' => $active, 'html' => $output]); |
|
||||
} |
|
||||
|
|
||||
public function buildRequest($endpoint) |
|
||||
{ |
|
||||
$config = $this->config; |
|
||||
$url = $config->url; |
|
||||
|
|
||||
$url = rtrim($url, '/'); |
|
||||
|
|
||||
$api_url = $url.'/command/?cmd='.$endpoint; |
|
||||
//die( $api_url.' --- '); |
|
||||
|
|
||||
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); |
|
||||
$res = $client->request('GET', $api_url); |
|
||||
return $res; |
|
||||
|
|
||||
} |
|
||||
|
|
||||
|
|
||||
} |
|
@ -1,89 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
use GuzzleHttp\Exception\GuzzleException; |
|
||||
use GuzzleHttp\Client; |
|
||||
|
|
||||
class Sabnzbd implements Contracts\Applications, Contracts\Livestats { |
|
||||
|
|
||||
public $config; |
|
||||
|
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#3e3924'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/sabnzbd.png'; |
|
||||
} |
|
||||
public function configDetails() |
|
||||
{ |
|
||||
return 'sabnzbd'; |
|
||||
} |
|
||||
public function testConfig() |
|
||||
{ |
|
||||
$res = $this->buildRequest('queue'); |
|
||||
switch($res->getStatusCode()) { |
|
||||
case 200: |
|
||||
$data = json_decode($res->getBody()); |
|
||||
if(isset($data->error) && !empty($data->error)) { |
|
||||
echo 'Failed: '.$data->error; |
|
||||
} else { |
|
||||
echo 'Successfully connected to the API'; |
|
||||
} |
|
||||
break; |
|
||||
case 401: |
|
||||
echo 'Failed: Invalid credentials'; |
|
||||
break; |
|
||||
case 404: |
|
||||
echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; |
|
||||
break; |
|
||||
default: |
|
||||
echo 'Something went wrong... Code: '.$res->getStatusCode(); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
public function executeConfig() |
|
||||
{ |
|
||||
$html = ''; |
|
||||
$active = 'inactive'; |
|
||||
$res = $this->buildRequest('queue'); |
|
||||
$data = json_decode($res->getBody()); |
|
||||
//$data->result->RemainingSizeMB = '10000000'; |
|
||||
//$data->result->DownloadRate = '100000000'; |
|
||||
if($data) { |
|
||||
$size = $data->queue->mbleft; |
|
||||
$rate = $data->queue->kbpersec; |
|
||||
$queue_size = format_bytes($size*1000*1000, false, ' <span>', '</span>'); |
|
||||
$current_speed = format_bytes($rate*1000, false, ' <span>'); |
|
||||
|
|
||||
$active = ($size > 0 || $rate > 0) ? 'active' : 'inactive'; |
|
||||
$html = ' |
|
||||
<ul class="livestats"> |
|
||||
<li><span class="title">Queue</span><strong>'.$queue_size.'</strong></li> |
|
||||
<li><span class="title">Speed</span><strong>'.$current_speed.'/s</span></strong></li> |
|
||||
</ul> |
|
||||
'; |
|
||||
} |
|
||||
return json_encode(['status' => $active, 'html' => $html]); |
|
||||
} |
|
||||
public function buildRequest($endpoint) |
|
||||
{ |
|
||||
$config = $this->config; |
|
||||
$url = $config->url; |
|
||||
$apikey = $config->apikey; |
|
||||
|
|
||||
//print_r($config); |
|
||||
//die(); |
|
||||
|
|
||||
$url = rtrim($url, '/'); |
|
||||
|
|
||||
$api_url = $url.'/api?output=json&apikey='.$apikey.'&mode='.$endpoint; |
|
||||
//die( $api_url.' --- '); |
|
||||
|
|
||||
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); |
|
||||
$res = $client->request('GET', $api_url); |
|
||||
return $res; |
|
||||
|
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Sickrage implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#6185a6'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/sickrage.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Sonarr implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#163740'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/sonarr.png'; |
|
||||
} |
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
class Syncthing implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#888'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/syncthing.png'; |
|
||||
} |
|
||||
} |
|
@ -1,14 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class TVheadend implements Contracts\Applications { |
|
||||
|
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#006080'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/tvheadend.png'; |
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,77 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
use GuzzleHttp\Exception\GuzzleException; |
|
||||
use GuzzleHttp\Client; |
|
||||
|
|
||||
class Tautulli implements Contracts\Applications, Contracts\Livestats { |
|
||||
|
|
||||
public $config; |
|
||||
|
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#2d2208'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/tautulli.png'; |
|
||||
} |
|
||||
public function configDetails() |
|
||||
{ |
|
||||
return 'tautulli'; |
|
||||
} |
|
||||
public function testConfig() |
|
||||
{ |
|
||||
$res = $this->buildRequest('arnold'); |
|
||||
switch($res->getStatusCode()) { |
|
||||
case 200: |
|
||||
$data = json_decode($res->getBody()); |
|
||||
if(isset($data->error) && !empty($data->error)) { |
|
||||
echo 'Failed: '.$data->error; |
|
||||
} else { |
|
||||
echo 'Successfully connected to the API'; |
|
||||
} |
|
||||
break; |
|
||||
case 401: |
|
||||
echo 'Failed: Invalid credentials'; |
|
||||
break; |
|
||||
case 404: |
|
||||
echo 'Failed: Please make sure your URL is correct and that there is a trailing slash'; |
|
||||
break; |
|
||||
default: |
|
||||
echo 'Something went wrong... Code: '.$res->getStatusCode(); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
public function executeConfig() |
|
||||
{ |
|
||||
$html = ''; |
|
||||
$active = 'active'; |
|
||||
$res = $this->buildRequest('get_activity'); |
|
||||
$data = json_decode($res->getBody()); |
|
||||
$stream_count = $data->response->data->stream_count; |
|
||||
|
|
||||
$html = ' |
|
||||
<ul class="livestats"> |
|
||||
<li><span class="title">Stream Count</span><strong>'.$stream_count.'</strong></li> |
|
||||
</ul> |
|
||||
'; |
|
||||
|
|
||||
return json_encode(['status' => $active, 'html' => $html]); |
|
||||
} |
|
||||
public function buildRequest($endpoint) |
|
||||
{ |
|
||||
$config = $this->config; |
|
||||
$url = $config->url; |
|
||||
$apikey = $config->apikey; |
|
||||
|
|
||||
$url = rtrim($url, '/'); |
|
||||
|
|
||||
$api_url = $url.'/api/v2?apikey='.$apikey.'&cmd='.$endpoint; |
|
||||
|
|
||||
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); |
|
||||
$res = $client->request('GET', $api_url); |
|
||||
return $res; |
|
||||
|
|
||||
} |
|
||||
|
|
||||
} |
|
@ -1,78 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
use GuzzleHttp\Client; |
|
||||
use GuzzleHttp\Exception\GuzzleException; |
|
||||
|
|
||||
class Traefik implements Contracts\Applications, Contracts\Livestats |
|
||||
{ |
|
||||
|
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#28434a'; |
|
||||
} |
|
||||
|
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/traefik.png'; |
|
||||
} |
|
||||
|
|
||||
public function configDetails() |
|
||||
{ |
|
||||
return 'traefik'; |
|
||||
} |
|
||||
|
|
||||
public function testConfig() |
|
||||
{ |
|
||||
$res = $this->sendRequest(); |
|
||||
if ($res == null) { |
|
||||
echo 'Traefik connection failed'; |
|
||||
return; |
|
||||
} |
|
||||
switch($res->getStatusCode()) { |
|
||||
case 200: |
|
||||
$data = json_decode($res->getBody()); |
|
||||
echo "Successfully connected with status: ".$data->result."\n"; |
|
||||
break; |
|
||||
case 404: |
|
||||
echo 'Failed: Please make sure your URL is correct and includes the port'; |
|
||||
break; |
|
||||
default: |
|
||||
echo 'Something went wrong... Code: '.$res->getStatusCode(); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public function executeConfig() |
|
||||
{ |
|
||||
$html = ''; |
|
||||
$active = 'inactive'; |
|
||||
$res = $this->sendRequest(); |
|
||||
$data = json_decode($res->getBody()); |
|
||||
if ($data) { |
|
||||
$avg_response_time = $data->average_response_time_sec; |
|
||||
$time = $avg_response_time*1000; |
|
||||
$time_output = number_format($time, 2); |
|
||||
$active = ($time > 0) ? 'active' : 'inactive'; |
|
||||
$html = ' |
|
||||
<ul class="livestats"> |
|
||||
<li><span class="title">Avg. Response Time</span><sub><i class="fas fa-heartbeat"></i> '.$time_output.' ms</sub></li> |
|
||||
</ul> |
|
||||
'; |
|
||||
} |
|
||||
return json_encode(['status' => $active, 'html' => $html]); |
|
||||
} |
|
||||
|
|
||||
public function sendRequest() |
|
||||
{ |
|
||||
$config = $this->config; |
|
||||
$url = $config->url; |
|
||||
|
|
||||
$url = rtrim($url, '/'); |
|
||||
$api_url = $url.'/health'; |
|
||||
|
|
||||
$client = new Client(['http_errors' => false, 'timeout' => 15, 'connect_timeout' => 15]); |
|
||||
$res = $client->request('GET', $api_url); |
|
||||
|
|
||||
return $res; |
|
||||
} |
|
||||
} |
|
@ -1,169 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
use GuzzleHttp\Exception\GuzzleException; |
|
||||
use GuzzleHttp\Client; |
|
||||
use Illuminate\Support\Facades\Log; |
|
||||
|
|
||||
class Transmission implements Contracts\Applications, Contracts\Livestats |
|
||||
{ |
|
||||
|
|
||||
private $_client; |
|
||||
private $_clientOptions = array(); |
|
||||
|
|
||||
public function __construct() |
|
||||
{ |
|
||||
$body = array(); |
|
||||
$body["method"] = "torrent-get"; |
|
||||
$body["arguments"] = array("fields" => ["percentDone","status","rateDownload","rateUpload"]); |
|
||||
$this->_client = new Client( |
|
||||
['http_errors' => false, |
|
||||
'timeout' => 10, |
|
||||
'body' => json_encode($body)] |
|
||||
); |
|
||||
} |
|
||||
|
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#950003'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/transmission.png'; |
|
||||
} |
|
||||
public function configDetails() |
|
||||
{ |
|
||||
return 'transmission'; |
|
||||
} |
|
||||
public function testConfig() |
|
||||
{ |
|
||||
$res = $this->sendRequest(); |
|
||||
if ($res == null) { |
|
||||
echo 'Transmission connection failed'; |
|
||||
return; |
|
||||
} |
|
||||
switch($res->getStatusCode()) { |
|
||||
case 200: |
|
||||
$data = json_decode($res->getBody()); |
|
||||
echo "Successfully connected with status: ".$data->result."\n"; |
|
||||
break; |
|
||||
case 401: |
|
||||
echo 'Failed: Invalid credentials'; |
|
||||
break; |
|
||||
case 404: |
|
||||
echo 'Failed: Please make sure your URL is correct and includes the port'; |
|
||||
break; |
|
||||
case 409: |
|
||||
echo 'Failed: Incorrect session id'; |
|
||||
break; |
|
||||
default: |
|
||||
echo 'Something went wrong... Code: '.$res->getStatusCode(); |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public function executeConfig() |
|
||||
{ |
|
||||
$html = ''; |
|
||||
$active = 'active'; |
|
||||
$res = $this->sendRequest(); |
|
||||
if ($res == null) { |
|
||||
Log::debug('Transmission connection failed'); |
|
||||
return ''; |
|
||||
} |
|
||||
$data = json_decode($res->getBody()); |
|
||||
if (! isset($data->arguments)) { |
|
||||
Log::debug('Failed to fetch data from Transmission'); |
|
||||
return ''; |
|
||||
} |
|
||||
$torrents = $data->arguments->torrents; |
|
||||
$torrentCount = count($torrents); |
|
||||
$rateDownload = $rateUpload = $completedTorrents = 0; |
|
||||
foreach ($torrents as $thisTorrent) { |
|
||||
$rateDownload += $thisTorrent->rateDownload; |
|
||||
$rateUpload += $thisTorrent->rateUpload; |
|
||||
if ($thisTorrent->percentDone == 1) { |
|
||||
$completedTorrents += 1; |
|
||||
} |
|
||||
} |
|
||||
if ($torrentCount - $completedTorrents == 0) { |
|
||||
// Don't poll as frequently if we don't have any active torrents |
|
||||
$active = 'inactive'; |
|
||||
} |
|
||||
|
|
||||
$html = ' |
|
||||
<ul class="livestats"> |
|
||||
<li><span class="title">Done</span><sub>'.$completedTorrents.' / '.$torrentCount.'</sub></li> |
|
||||
<li><span class="title">Down</span><sub>'.format_bytes($rateDownload).'</sub></li> |
|
||||
<li><span class="title">Up</span><sub>'.format_bytes($rateUpload).'</sub></li> |
|
||||
</ul> |
|
||||
'; |
|
||||
return json_encode(['status' => $active, 'html' => $html]);; |
|
||||
} |
|
||||
|
|
||||
private function sendRequest() |
|
||||
{ |
|
||||
$optionsSet = $this->setClientOptions(); |
|
||||
if (! $optionsSet) { |
|
||||
// Pass the failed response back up the chain |
|
||||
return null; |
|
||||
} |
|
||||
$res = $this->torrentGet(); |
|
||||
if ($res->getStatusCode() == 409) { |
|
||||
$this->setClientOptions(); |
|
||||
$res = $this->torrentGet(); |
|
||||
} |
|
||||
return $res; |
|
||||
} |
|
||||
|
|
||||
private function torrentGet() |
|
||||
{ |
|
||||
$res = null; |
|
||||
try{ |
|
||||
$res = $this->_client->request( |
|
||||
'POST', |
|
||||
$this->getApiUrl(), |
|
||||
$this->_clientOptions |
|
||||
); |
|
||||
}catch(\GuzzleHttp\Exception\BadResponseException $e){ |
|
||||
Log::error("Connection to {$e->getRequest()->getUrl()} failed"); |
|
||||
Log::debug($e->getMessage()); |
|
||||
$res = $e->getRequest(); |
|
||||
}catch(\GuzzleHttp\Exception\ConnectException $e) { |
|
||||
Log::error("Transmission connection refused"); |
|
||||
Log::debug($e->getMessage()); |
|
||||
} |
|
||||
return $res; |
|
||||
} |
|
||||
|
|
||||
private function setClientOptions() |
|
||||
{ |
|
||||
if ($this->config->username != '' || $this->config->password != '') { |
|
||||
$this->_clientOptions = ['auth'=> [$this->config->username, $this->config->password, 'Basic']]; |
|
||||
} |
|
||||
try{ |
|
||||
$res = $this->_client->request('HEAD', $this->getApiUrl(), $this->_clientOptions); |
|
||||
$xtId = $res->getHeaderLine('X-Transmission-Session-Id'); |
|
||||
if ($xtId != null) { |
|
||||
$this->_clientOptions['headers'] = ['X-Transmission-Session-Id' => $xtId]; |
|
||||
} else { |
|
||||
Log::error("Unable to get Transmission session information"); |
|
||||
Log::debug("Status Code: ".$res->getStatusCode()); |
|
||||
} |
|
||||
}catch(\GuzzleHttp\Exception\ConnectException $e){ |
|
||||
Log::error("Failed connection to Transmission"); |
|
||||
return false; |
|
||||
} |
|
||||
return true; |
|
||||
} |
|
||||
|
|
||||
private function getApiUrl() |
|
||||
{ |
|
||||
$config = $this->config; |
|
||||
$url = $config->url; |
|
||||
|
|
||||
$url = rtrim($url, '/'); |
|
||||
$api_url = $url.'/transmission/rpc'; |
|
||||
|
|
||||
return $api_url; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Ttrss implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#9d704c'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/tt-rss.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Unifi implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#363840'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/unifi.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Unraid implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#A12624'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/unraid.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Virtualmin implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#161b1f'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/virtualmin.svg'; |
|
||||
} |
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
class Watcher3 implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#500'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/watcher3.png'; |
|
||||
} |
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
class WebTools implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#555'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/webtools.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class Webmin implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#161b1f'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/webmin.svg'; |
|
||||
} |
|
||||
} |
|
@ -1,11 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
class pyLoad implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#881'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/pyload.png'; |
|
||||
} |
|
||||
} |
|
@ -1,12 +0,0 @@ |
|||||
<?php namespace App\SupportedApps; |
|
||||
|
|
||||
class ruTorrent implements Contracts\Applications { |
|
||||
public function defaultColour() |
|
||||
{ |
|
||||
return '#004'; |
|
||||
} |
|
||||
public function icon() |
|
||||
{ |
|
||||
return 'supportedapps/rutorrent.png'; |
|
||||
} |
|
||||
} |
|
Loading…
Reference in new issue