diff --git a/app/Apps/.gitignore b/app/Apps/.gitignore
new file mode 100644
index 00000000..e69de29b
diff --git a/app/SupportedApps.php b/app/SupportedApps.php
new file mode 100644
index 00000000..d81bc07f
--- /dev/null
+++ b/app/SupportedApps.php
@@ -0,0 +1,30 @@
+_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 = '
-
- - Wanted'.$wantedMovies.'
- - Available'.$availableMovies.'
-
- ';
- 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;
- }
-}
diff --git a/app/SupportedApps/Deluge.php b/app/SupportedApps/Deluge.php
deleted file mode 100644
index 5af9de5a..00000000
--- a/app/SupportedApps/Deluge.php
+++ /dev/null
@@ -1,109 +0,0 @@
-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 = '
-
- - '.$this->formatBytes($download_rate).'
- - '.$this->formatBytes($upload_rate).'
-
-
- - Leech: '.$leech_count[1].'
- - Seed: '.$seed_count[1].'
-
- ';
- 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';
- }
-}
diff --git a/app/SupportedApps/Dokuwiki.php b/app/SupportedApps/Dokuwiki.php
deleted file mode 100644
index edf08281..00000000
--- a/app/SupportedApps/Dokuwiki.php
+++ /dev/null
@@ -1,12 +0,0 @@
-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, ' ', '');
- $current_speed = format_bytes($rate, false, ' ');
-
- $active = ($size > 0 || $rate > 0) ? 'active' : 'inactive';
- $html = '
-
- - Queue'.$queue_size.'
- - Speed'.$current_speed.'/s
-
- ';
- }
- 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;
-
- }
-
-}
\ No newline at end of file
diff --git a/app/SupportedApps/Nzbhydra.php b/app/SupportedApps/Nzbhydra.php
deleted file mode 100644
index 8bba0dc7..00000000
--- a/app/SupportedApps/Nzbhydra.php
+++ /dev/null
@@ -1,12 +0,0 @@
-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 = '
-
- - Domains
Blocked'.$data->domains_being_blocked.'
- - Blocked
Today'.$data->ads_blocked_today.'
-
- ';
- 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;
-
- }
-
-
-}
\ No newline at end of file
diff --git a/app/SupportedApps/Plex.php b/app/SupportedApps/Plex.php
deleted file mode 100644
index 669d36d5..00000000
--- a/app/SupportedApps/Plex.php
+++ /dev/null
@@ -1,12 +0,0 @@
-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 = '
-
- - Stream Count'.$stream_count.'
-
- ';
-
- 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;
-
- }
-
-}
diff --git a/app/SupportedApps/Plexrequests.php b/app/SupportedApps/Plexrequests.php
deleted file mode 100644
index 395d7751..00000000
--- a/app/SupportedApps/Plexrequests.php
+++ /dev/null
@@ -1,12 +0,0 @@
-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 = '
-
- - Domains
Blocked'.$data->domains_being_blocked.'
- - Blocked
Today'.$data->ads_blocked_today.'
-
- ';
- 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;
-
- }
-
-
-}
\ No newline at end of file
diff --git a/app/SupportedApps/Radarr.php b/app/SupportedApps/Radarr.php
deleted file mode 100644
index 8a1d0fdc..00000000
--- a/app/SupportedApps/Radarr.php
+++ /dev/null
@@ -1,12 +0,0 @@
-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 = '';
-
- if (strlen($artist) > 12) {
- $output = $output.'- '.$artist.'
';
- } else {
- $output = $output.'- '.$artist.'
';
- }
-
- $output = $output.'
';
-
- if (strlen($song_title) > 12) {
- $output = $output.'- '.$song_title.'
';
- } else {
- $output = $output.'- '.$song_title.'
';
- }
-
- $output = $output.'
';
-
- 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;
-
- }
-
-
-}
diff --git a/app/SupportedApps/Sabnzbd.php b/app/SupportedApps/Sabnzbd.php
deleted file mode 100644
index 4e78c735..00000000
--- a/app/SupportedApps/Sabnzbd.php
+++ /dev/null
@@ -1,89 +0,0 @@
-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, ' ', '');
- $current_speed = format_bytes($rate*1000, false, ' ');
-
- $active = ($size > 0 || $rate > 0) ? 'active' : 'inactive';
- $html = '
-
- - Queue'.$queue_size.'
- - Speed'.$current_speed.'/s
-
- ';
- }
- 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;
-
- }
-
-}
\ No newline at end of file
diff --git a/app/SupportedApps/Sickrage.php b/app/SupportedApps/Sickrage.php
deleted file mode 100644
index e4fc9c68..00000000
--- a/app/SupportedApps/Sickrage.php
+++ /dev/null
@@ -1,12 +0,0 @@
-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 = '
-
- - Stream Count'.$stream_count.'
-
- ';
-
- 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;
-
- }
-
-}
diff --git a/app/SupportedApps/Traefik.php b/app/SupportedApps/Traefik.php
deleted file mode 100644
index 14a58743..00000000
--- a/app/SupportedApps/Traefik.php
+++ /dev/null
@@ -1,78 +0,0 @@
-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 = '
-
- - Avg. Response Time '.$time_output.' ms
-
- ';
- }
- 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;
- }
-}
diff --git a/app/SupportedApps/Transmission.php b/app/SupportedApps/Transmission.php
deleted file mode 100644
index 8656db3c..00000000
--- a/app/SupportedApps/Transmission.php
+++ /dev/null
@@ -1,169 +0,0 @@
- ["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 = '
-
- - Done'.$completedTorrents.' / '.$torrentCount.'
- - Down'.format_bytes($rateDownload).'
- - Up'.format_bytes($rateUpload).'
-
- ';
- 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;
- }
-}
diff --git a/app/SupportedApps/Ttrss.php b/app/SupportedApps/Ttrss.php
deleted file mode 100644
index 4ec483fb..00000000
--- a/app/SupportedApps/Ttrss.php
+++ /dev/null
@@ -1,12 +0,0 @@
-