Skip to content

Commit

Permalink
Merge pull request #43 from robearlam/master
Browse files Browse the repository at this point in the history
Updated Lidarr to be an enhanced app
  • Loading branch information
KodeStar authored Feb 25, 2019
2 parents d23e66c + 05a09e7 commit dc0637d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 3 deletions.
38 changes: 36 additions & 2 deletions Lidarr/Lidarr.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,39 @@
<?php namespace App\SupportedApps\Lidarr;

class Lidarr extends \App\SupportedApps {
class Lidarr extends \App\SupportedApps implements \App\EnhancedApps {

}
public $config;

//protected $login_first = true; // Uncomment if api requests need to be authed first
//protected $method = 'POST'; // Uncomment if requests to the API should be set by POST

function __construct() {
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set
}

public function test()
{
$test = parent::appTest($this->url('system/status'));
echo $test->status;
}

public function livestats()
{
$status = 'inactive';
$missing = json_decode(parent::execute($this->url('wanted/missing'))->getBody());
$queue = json_decode(parent::execute($this->url('queue'))->getBody());

if($missing || $queue) {
$data['missing'] = $missing->totalRecords ?? 0;
$data['queue'] = $queue->totalRecords ?? 0;
}

return parent::getLiveStats($status, $data);
}

public function url($endpoint)
{
$api_url = parent::normaliseurl($this->config->url).'api/v1/'.$endpoint.'?apikey='.$this->config->apikey;
return $api_url;
}
}
2 changes: 1 addition & 1 deletion Lidarr/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"website": "https://lidarr.audio/",
"license": "GNU General Public License v3.0 only",
"description": "Lidarr is a music collection manager for Usenet and BitTorrent users. It can monitor multiple RSS feeds for new tracks from your favorite artists and will grab, sort and rename them.",
"enhanced": false,
"enhanced": true,
"tile_background": "dark",
"icon": "lidarr.png"
}
15 changes: 15 additions & 0 deletions Lidarr/config.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<h2>{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')</h2>
<div class="items">
<div class="input">
<label>{{ strtoupper(__('app.url')) }}</label>
{!! Form::text('config[override_url]', (isset($item) ? $item->getconfig()->override_url : null), array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
</div>
<div class="input">
<label>{{ __('app.apps.apikey') }}</label>
{!! Form::text('config[apikey]', (isset($item) ? $item->getconfig()->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>

10 changes: 10 additions & 0 deletions Lidarr/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<ul class="livestats">
<li>
<span class="title">Missing</span>
<strong>{!! $missing !!}</strong>
</li>
<li>
<span class="title">Queue</span>
<strong>{!! $queue !!}</strong>
</li>
</ul>

0 comments on commit dc0637d

Please sign in to comment.