Add Couchpotato as an enhanced app
This commit is contained in:
parent
1a8e2b92de
commit
39153c6936
16 changed files with 164 additions and 0 deletions
|
@ -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,
|
||||
|
|
126
app/SupportedApps/CouchPotato.php
Normal file
126
app/SupportedApps/CouchPotato.php
Normal file
|
@ -0,0 +1,126 @@
|
|||
<?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>
|
||||
';
|
||||
$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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -61,6 +61,7 @@ return [
|
|||
'apps.config' => 'Configurazione',
|
||||
'apps.apikey' => 'Api Key',
|
||||
'apps.enable' => 'Abilitato',
|
||||
'apps.aggressive_polling' => 'Sondaggio aggressivo',
|
||||
|
||||
'url' => 'Url',
|
||||
'title' => 'Titolo',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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ł',
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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',
|
||||
|
|
25
resources/views/supportedapps/couchpotato.blade.php
Normal file
25
resources/views/supportedapps/couchpotato.blade.php
Normal file
|
@ -0,0 +1,25 @@
|
|||
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }})</h2>
|
||||
<div class="items">
|
||||
<input type="hidden" name="config[enabled]" value="1" />
|
||||
<input type="hidden" data-config="type" class="config-item" name="config[type]" value="\App\SupportedApps\CouchPotato" />
|
||||
<div class="input">
|
||||
<label>{{ __('app.apps.aggressive_polling') }}</label>
|
||||
{!! Form::hidden('config[aggressive_polling', '0') !!}
|
||||
<label class="switch">
|
||||
<?php
|
||||
$checked = false;
|
||||
if(isset($item->config->aggressive_polling) && (bool)$item->config->aggressive_polling === true) $checked = true;
|
||||
$set_checked = ($checked) ? ' checked="checked"' : '';
|
||||
?>
|
||||
<input type="checkbox" name="config[aggressive_polling]" value="1"<?php echo $set_checked;?> />
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="input">
|
||||
<label>{{ __('app.apps.apikey') }}</label>
|
||||
{!! Form::text('config[apikey]', null, array('placeholder' => __('app.apps.apikey'), 'data-config' => 'apikey', 'class' => 'form-control config-item')) !!}
|
||||
</div>
|
||||
<div class="input">
|
||||
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button>
|
||||
</div>
|
||||
</div>
|
BIN
storage/app/public/supportedapps/couchpotato.png
Normal file
BIN
storage/app/public/supportedapps/couchpotato.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 26 KiB |
Loading…
Reference in a new issue