-
-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add Threadfin Enhanced app * Fix lint error * Add SVG icon for Threadfin
- Loading branch information
1 parent
6b1312b
commit 35b82de
Showing
5 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
namespace App\SupportedApps\Threadfin; | ||
|
||
class Threadfin 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 | ||
|
||
public function __construct() | ||
{ | ||
//$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set | ||
} | ||
|
||
private function getStatus() | ||
{ | ||
$attrs = [ | ||
"headers" => [ | ||
"Content-Type" => "application/json" | ||
], | ||
"body" => json_encode([ | ||
"cmd" => "status" | ||
]) | ||
]; | ||
|
||
$res = parent::execute($this->url("api/"), $attrs); | ||
|
||
switch ($res->getStatusCode()) { | ||
case 200: | ||
return json_decode($res->getBody()); | ||
case 400: | ||
throw new \Exception("Bad command"); | ||
default: | ||
throw new \Exception("Could not connect to Threadfin"); | ||
} | ||
} | ||
|
||
public function test() | ||
{ | ||
try { | ||
$res = $this->getStatus(); | ||
if ($res->status == true) { | ||
echo "Successfully communicated with the API"; | ||
} else { | ||
echo "Threadfin is not in a good health"; | ||
} | ||
} catch (Exception $err) { | ||
echo $err->getMessage(); | ||
} | ||
} | ||
|
||
public function livestats() | ||
{ | ||
$status = "inactive"; | ||
$data = []; | ||
|
||
$res = $this->getStatus(); | ||
|
||
$data["activeChannels"] = $res->{"streams.active"}; | ||
$data["totalChannels"] = $res->{"streams.all"}; | ||
|
||
return parent::getLiveStats($status, $data); | ||
} | ||
|
||
public function url($endpoint) | ||
{ | ||
$api_url = parent::normaliseurl($this->config->url) . $endpoint; | ||
return $api_url; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"appid": "98028de0432f62fda3283fc2e833f0d68c2a38d9", | ||
"name": "Threadfin", | ||
"website": "https://github.com/Threadfin/Threadfin", | ||
"license": "MIT license", | ||
"description": "An M3U proxy for Kernel/Plex/Jellyfin/Emby based on xTeVe", | ||
"enhanced": true, | ||
"tile_background": "dark", | ||
"icon": "threadfin.svg" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<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, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!} | ||
</div> | ||
<div class="input"> | ||
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<ul class="livestats"> | ||
<li> | ||
<span class="title">Channels</span> | ||
<strong>{!! $activeChannels !!}<span>/{!! $totalChannels !!}</span></strong> | ||
</li> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.