diff --git a/app/Item.php b/app/Item.php index 0067a9a8..6945abfd 100644 --- a/app/Item.php +++ b/app/Item.php @@ -26,6 +26,7 @@ class Item extends Model public static function supportedList() { return [ + 'CouchPotato' => \App\SupportedApps\CouchPotato::class, 'Deluge' => \App\SupportedApps\Deluge::class, 'Dokuwiki' => \App\SupportedApps\Dokuwiki::class, 'Duplicati' => \App\SupportedApps\Duplicati::class, diff --git a/app/SupportedApps/CouchPotato.php b/app/SupportedApps/CouchPotato.php new file mode 100644 index 00000000..3e659ef8 --- /dev/null +++ b/app/SupportedApps/CouchPotato.php @@ -0,0 +1,126 @@ +_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 = ' + + '; + $active = 'inactive'; + if (isset($this->config->aggressive_polling) && $this->config->aggressive_polling) { + $active = 'active'; + } + return json_encode(['status' => $active, '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/readme.md b/readme.md index 8b3a55d7..8bead9aa 100644 --- a/readme.md +++ b/readme.md @@ -28,6 +28,7 @@ If you want to see a quick video of it in use, go to https://youtu.be/GXnnMAxPzM You can use the app to link to any site or application, but Foundation apps will auto fill in the icon for the app and supply a default color for the tile. In addition Enhanced apps allow you provide details to an apps API, allowing you to view live stats directly on the dashboad. For example, the NZBGet and Sabnzbd Enhanced apps will display the queue size and download speed while something is downloading. **Enhanced** +- CouchPotato - NZBGet - Pihole - Sabnzbd diff --git a/resources/lang/de/app.php b/resources/lang/de/app.php index adaeb1e4..718e00f5 100644 --- a/resources/lang/de/app.php +++ b/resources/lang/de/app.php @@ -44,6 +44,7 @@ return array ( 'apps.username' => 'Benutzername', 'apps.password' => 'Passwort', 'apps.config' => 'Konfig', + 'apps.aggressive_polling' => 'Aggressives Polling', 'url' => 'Url', 'title' => 'Titel', 'delete' => 'Löschen', diff --git a/resources/lang/en/app.php b/resources/lang/en/app.php index 920b26ed..430d51ef 100644 --- a/resources/lang/en/app.php +++ b/resources/lang/en/app.php @@ -66,6 +66,7 @@ return [ 'apps.tag_name' => 'Tag name', 'apps.tags' => 'Tags', 'apps.override' => 'If different to main url', + 'apps.aggressive_polling' => 'Aggressive polling', 'url' => 'Url', 'title' => 'Title', diff --git a/resources/lang/es/app.php b/resources/lang/es/app.php index dd7c632a..7407f3bc 100644 --- a/resources/lang/es/app.php +++ b/resources/lang/es/app.php @@ -44,6 +44,7 @@ return array ( 'apps.username' => 'Nombre de usuario', 'apps.password' => 'Contraseña', 'apps.config' => 'Config', + 'apps.aggressive_polling' => 'Encuesta agresiva', 'url' => 'Url', 'title' => 'Título', 'delete' => 'Borrar', diff --git a/resources/lang/fi/app.php b/resources/lang/fi/app.php index 0e1178cf..373d0d5d 100644 --- a/resources/lang/fi/app.php +++ b/resources/lang/fi/app.php @@ -44,6 +44,7 @@ return array ( 'apps.username' => 'Käyttäjätunnus', 'apps.password' => 'Salasana', 'apps.config' => 'Konfiguraatio', + 'apps.aggressive_polling' => 'Agressieve polling', 'url' => 'Url', 'title' => 'Otsikko', 'delete' => 'Poistaa', diff --git a/resources/lang/fr/app.php b/resources/lang/fr/app.php index 639b24b3..5ba8bbbe 100644 --- a/resources/lang/fr/app.php +++ b/resources/lang/fr/app.php @@ -44,6 +44,7 @@ return array ( 'apps.username' => 'Nom d\'utilisateur', 'apps.password' => 'Mot de passe', 'apps.config' => 'Config', + 'apps.aggressive_polling' => 'Scrutation agressive', 'url' => 'Url', 'title' => 'Titre', 'delete' => 'Effacer', diff --git a/resources/lang/it/app.php b/resources/lang/it/app.php index 47388cb3..235fbf16 100644 --- a/resources/lang/it/app.php +++ b/resources/lang/it/app.php @@ -61,6 +61,7 @@ return [ 'apps.config' => 'Configurazione', 'apps.apikey' => 'Api Key', 'apps.enable' => 'Abilitato', + 'apps.aggressive_polling' => 'Sondaggio aggressivo', 'url' => 'Url', 'title' => 'Titolo', diff --git a/resources/lang/nl/app.php b/resources/lang/nl/app.php index 416b38bb..3b029366 100644 --- a/resources/lang/nl/app.php +++ b/resources/lang/nl/app.php @@ -65,6 +65,7 @@ return [ 'apps.add_tag' => 'Tag toevoegen', 'apps.tag_name' => 'Naam van tag', 'apps.tags' => 'Tags', + 'apps.aggressive_polling' => 'Agressieve polling', 'url' => 'URL', 'title' => 'Titel', diff --git a/resources/lang/no/app.php b/resources/lang/no/app.php index 09e497ab..20fc1976 100644 --- a/resources/lang/no/app.php +++ b/resources/lang/no/app.php @@ -61,6 +61,7 @@ return [ 'apps.config' => 'Konfigurasjon', 'apps.apikey' => 'Api nøkkel', 'apps.enable' => 'Aktiver', + 'apps.aggressive_polling' => 'Aggressiv avstemning', 'url' => 'Url', 'title' => 'Tittel', diff --git a/resources/lang/pl/app.php b/resources/lang/pl/app.php index e8d1a2ab..5e10afe3 100644 --- a/resources/lang/pl/app.php +++ b/resources/lang/pl/app.php @@ -61,6 +61,7 @@ return [ 'apps.config' => 'Ustawienia', 'apps.apikey' => 'Klucz API', 'apps.enable' => 'Włącz', + 'apps.aggressive_polling' => 'Agresywny głosowanie', 'url' => 'URL', 'title' => 'Tytuł', diff --git a/resources/lang/sv/app.php b/resources/lang/sv/app.php index a4ffbe50..6eb65344 100644 --- a/resources/lang/sv/app.php +++ b/resources/lang/sv/app.php @@ -44,6 +44,7 @@ return array ( 'apps.username' => 'Användarnamn', 'apps.password' => 'Lösenord', 'apps.config' => 'Konfiguration', + 'apps.aggressive_polling' => 'Aggressiv omröstning', 'url' => 'Url', 'title' => 'Titel', 'delete' => 'Radera', diff --git a/resources/lang/tr/app.php b/resources/lang/tr/app.php index 671cd6db..e62a5a87 100644 --- a/resources/lang/tr/app.php +++ b/resources/lang/tr/app.php @@ -59,6 +59,7 @@ return [ 'apps.username' => 'Kullanıcı adı', 'apps.password' => 'Şifre', 'apps.config' => 'Yapılandırma', + 'apps.aggressive_polling' => 'Agresif oy verme', 'url' => 'Adres', 'title' => 'Başlık', diff --git a/resources/views/supportedapps/couchpotato.blade.php b/resources/views/supportedapps/couchpotato.blade.php new file mode 100644 index 00000000..9490cb21 --- /dev/null +++ b/resources/views/supportedapps/couchpotato.blade.php @@ -0,0 +1,25 @@ +

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

+
+ + +
+ + {!! Form::hidden('config[aggressive_polling', '0') !!} + +
+
+ + {!! 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..50702517 Binary files /dev/null and b/storage/app/public/supportedapps/couchpotato.png differ