-
-
Notifications
You must be signed in to change notification settings - Fork 321
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* First Version - Icon is not the right size - "Something went wrong" * Rename icon * Overhaul... * Remove all debug stuff * changes for PHPCS * PHPCS
- Loading branch information
Showing
5 changed files
with
122 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,86 @@ | ||
<?php | ||
|
||
namespace App\SupportedApps\Jellystat; | ||
|
||
class Jellystat 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 | ||
} | ||
|
||
public function test() | ||
{ | ||
$attrs = $this->getRequestAttrs(); | ||
$test = parent::appTest($this->url('stats/getLibraryCardStats'), $attrs); | ||
echo $test->status; | ||
} | ||
|
||
public function livestats() | ||
{ | ||
$status = 'inactive'; | ||
$attrs = $this->getRequestAttrs(); | ||
|
||
$res = parent::execute($this->url('stats/getAllUserActivity'), $attrs); | ||
|
||
$results = json_decode($res->getBody()); | ||
|
||
$details = ["visiblestats" => []]; | ||
|
||
$newstat = new \stdClass(); | ||
$newstat->TotalPlays = new \stdClass(); | ||
$newstat->TotalPlays->title = 'Total Plays'; | ||
|
||
$newstat->TotalWatchTime = new \stdClass(); | ||
$newstat->TotalWatchTime->title = 'Total Watchtime'; | ||
|
||
if (isset($results[0])) { | ||
$result = $results[0]; | ||
$newstat->TotalPlays->value = $result->TotalPlays; | ||
$newstat->TotalWatchTime->value = $this->secondsToHoursMinutes($result->TotalWatchTime); | ||
} | ||
|
||
$details["visiblestats"][] = $newstat; | ||
|
||
return parent::getLiveStats($status, $details); | ||
} | ||
|
||
public function url($endpoint) | ||
{ | ||
$api_url = parent::normaliseurl($this->config->url) . $endpoint; | ||
return $api_url; | ||
} | ||
|
||
private function getRequestAttrs() | ||
{ | ||
$attrs = [ | ||
"headers" => [ | ||
|
||
"accept" => "application/json", | ||
"x-api-token" => $this->config->x_api_token, | ||
], | ||
]; | ||
|
||
return $attrs; | ||
} | ||
|
||
private function secondsToHoursMinutes($seconds) | ||
{ | ||
|
||
// Calculate the hours | ||
$hours = floor($seconds / 3600); | ||
|
||
// Calculate the remaining seconds | ||
// into minutes | ||
$minutes = floor(($seconds % 3600) / 60); | ||
|
||
// Return the result as an | ||
// associative array | ||
return $hours . 'h ' . $minutes . 'min'; | ||
} | ||
} |
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": "b134790d9a8269a36013773814955539268e224a", | ||
"name": "Jellystat", | ||
"website": "https://github.com/CyferShepard/Jellystat", | ||
"license": "MIT License", | ||
"description": "Jellystat is a free and open source Statistics App for Jellyfin!", | ||
"enhanced": true, | ||
"tile_background": "dark", | ||
"icon": "jellystat.png" | ||
} |
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,14 @@ | ||
<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"> | ||
<label>API token</label> | ||
{!! Form::input('text', 'config[x_api_token]', isset($item) ? $item->getconfig()->x_api_token : null, ['placeholder' => __('Api Token'), 'data-config' => 'x_api_token', 'class' => 'form-control config-item']) !!} | ||
</div> | ||
<div class="input"> | ||
<button style="margin-top: 32px;" class="btn test" id="test_config">Test</button> | ||
</div> | ||
</div> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,12 @@ | ||
<ul class="livestats"> | ||
@foreach ($visiblestats as $stat) | ||
<li> | ||
<span class="title">{!! $stat->TotalPlays->title !!}</span> | ||
<strong>{!! $stat->TotalPlays->value !!}</strong> | ||
</li> | ||
<li> | ||
<span class="title">{!! $stat->TotalWatchTime->title !!}</span> | ||
<strong>{!! $stat->TotalWatchTime->value !!}</strong> | ||
</li> | ||
@endforeach | ||
</ul> |