diff --git a/app/Item.php b/app/Item.php index 9ad380c4..ae7a8869 100644 --- a/app/Item.php +++ b/app/Item.php @@ -27,6 +27,7 @@ class Item extends Model { return [ 'AirSonic' => \App\SupportedApps\AirSonic::class, + 'CouchPotato' => \App\SupportedApps\CouchPotato::class, 'Deluge' => \App\SupportedApps\Deluge::class, 'Dokuwiki' => \App\SupportedApps\Dokuwiki::class, 'Duplicati' => \App\SupportedApps\Duplicati::class, @@ -48,6 +49,7 @@ class Item extends Model 'OPNSense' => \App\SupportedApps\Opnsense::class, 'Ombi' => \App\SupportedApps\Ombi::class, 'Openhab' => \App\SupportedApps\Openhab::class, + 'OpenMediaVault' => \App\SupportedApps\OpenMediaVault::class, 'Pihole' => \App\SupportedApps\Pihole::class, 'Plex' => \App\SupportedApps\Plex::class, 'Plexpy' => \App\SupportedApps\Plexpy::class, @@ -62,10 +64,11 @@ class Item extends Model 'Tautulli' => \App\SupportedApps\Tautulli::class, 'Transmission' => \App\SupportedApps\Transmission::class, 'Traefik' => \App\SupportedApps\Traefik::class, - 'Ttrss' => \App\SupportedApps\Ttrss::class, + 'tt-rss' => \App\SupportedApps\Ttrss::class, 'UniFi' => \App\SupportedApps\Unifi::class, - 'pFsense' => \App\SupportedApps\Pfsense::class, + 'pfSense' => \App\SupportedApps\Pfsense::class, 'ruTorrent' => \App\SupportedApps\ruTorrent::class, + 'WebTools' => \App\SupportedApps\WebTools::class, ]; } public static function supportedOptions() diff --git a/app/SupportedApps/CouchPotato.php b/app/SupportedApps/CouchPotato.php new file mode 100644 index 00000000..82d93343 --- /dev/null +++ b/app/SupportedApps/CouchPotato.php @@ -0,0 +1,122 @@ +_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 = ' + + '; + 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/OpenMediaVault.php b/app/SupportedApps/OpenMediaVault.php new file mode 100644 index 00000000..e531b26f --- /dev/null +++ b/app/SupportedApps/OpenMediaVault.php @@ -0,0 +1,12 @@ + += 7.0.0, OpenSSL PHP Extension, PDO PHP Extension, Mbstring PHP Extension, Tokenizer PHP Extension and XML PHP Extension, the only other thing Heimdall needs is sqlite support. diff --git a/resources/views/supportedapps/couchpotato.blade.php b/resources/views/supportedapps/couchpotato.blade.php new file mode 100644 index 00000000..beffe7f0 --- /dev/null +++ b/resources/views/supportedapps/couchpotato.blade.php @@ -0,0 +1,13 @@ +

{{ __('app.apps.config') }} ({{ __('app.optional') }})

+
+ + + +
+ + {!! Form::text('config[apikey]', null, array('placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item')) !!} +
+
+ +
+
diff --git a/storage/app/public/supportedapps/couchpotato.png b/storage/app/public/supportedapps/couchpotato.png new file mode 100644 index 00000000..10f94270 Binary files /dev/null and b/storage/app/public/supportedapps/couchpotato.png differ diff --git a/storage/app/public/supportedapps/openmediavault.png b/storage/app/public/supportedapps/openmediavault.png new file mode 100644 index 00000000..90424f7d Binary files /dev/null and b/storage/app/public/supportedapps/openmediavault.png differ diff --git a/storage/app/public/supportedapps/transmission.png b/storage/app/public/supportedapps/transmission.png index 8b55fd4a..784440f5 100644 Binary files a/storage/app/public/supportedapps/transmission.png and b/storage/app/public/supportedapps/transmission.png differ diff --git a/storage/app/public/supportedapps/webtools.png b/storage/app/public/supportedapps/webtools.png new file mode 100644 index 00000000..7f619e4a Binary files /dev/null and b/storage/app/public/supportedapps/webtools.png differ