Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 26 additions & 28 deletions Plex/Plex.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,37 +26,35 @@ public function test()
public function livestats()
{
$status = "inactive";
$res = parent::execute(
$this->url("/library/recentlyAdded"),
$this->attrs()
);
$body = $res->getBody();
$xml = simplexml_load_string(
$body,
"SimpleXMLElement",
LIBXML_NOCDATA | LIBXML_NOBLANKS
);

$data = [];

if ($xml) {
$data["recently_added"] = $xml["size"];
$status = "active";
if ($this->config->section_1_key > 0) {
$res = parent::execute($this->url("/library/sections/{$this->config->section_1_key}/all"), $this->attrs());
$body = $res->getBody();
$xml = simplexml_load_string(
$body,
"SimpleXMLElement",
LIBXML_NOCDATA | LIBXML_NOBLANKS
);
if ($xml) {
$data["section_1_number"] = $xml["size"];
$data["section_1_title"] = $xml["librarySectionTitle"];
$status = "active";
}
}

$res = parent::execute($this->url("/library/onDeck"));

$res = parent::execute($this->url("/library/onDeck"), $this->attrs());

$body = $res->getBody();
$xml = simplexml_load_string(
$body,
"SimpleXMLElement",
LIBXML_NOCDATA | LIBXML_NOBLANKS
);
if ($xml) {
$data["on_deck"] = $xml["size"];
$status = "active";
if ($this->config->section_2_key > 0) {
$res = parent::execute($this->url("/library/sections/{$this->config->section_2_key}/all"), $this->attrs());
$body = $res->getBody();
$xml = simplexml_load_string(
$body,
"SimpleXMLElement",
LIBXML_NOCDATA | LIBXML_NOBLANKS
);
if ($xml) {
$data["section_2_number"] = $xml["size"];
$data["section_2_title"] = $xml["librarySectionTitle"];
$status = "active";
}
}

return parent::getLiveStats($status, $data);
Expand Down
8 changes: 8 additions & 0 deletions Plex/config.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,14 @@
<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 title="">Section 1 Key (<a href="https://support.plex.tv/articles/201638786-plex-media-server-url-commands/" target="_blank">help?</a>)</label>
{!! Form::text('config[section_1_key]', isset($item) ? $item->getconfig()->section_1_key : null, ['placeholder' => __('section_1_key'), 'data-config' => 'section_1_key', 'class' => 'form-control config-i
</div>
<div class="input">
<label title="">Section 2 Key (<a href="https://support.plex.tv/articles/201638786-plex-media-server-url-commands/" target="_blank">help?</a>)</label>
{!! Form::text('config[section_2_key]', isset($item) ? $item->getconfig()->section_2_key : null, ['placeholder' => __('section_2_key'), 'data-config' => 'section_2_key', 'class' => 'form-control config-i
</div>
<div class="input">
<label title="">Plex Token (<a href="https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/" target="_blank">help?</a>)</label>
{!! Form::text('config[token]', isset($item) ? $item->getconfig()->token : null, ['placeholder' => __('token'), 'data-config' => 'token', 'class' => 'form-control config-item']) !!}
Expand Down
8 changes: 4 additions & 4 deletions Plex/livestats.blade.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<ul class="livestats">
<li>
<span class="title">Recent</span>
<strong>{!! $recently_added ?? '' !!}</strong>
<span class="title">{!! $section_1_title ?? '' !!}</span>
<strong>{!! $section_1_number ?? '' !!}</strong>
</li>
<li>
<span class="title">On Deck</span>
<strong>{!! $on_deck ?? '' !!}</strong>
<span class="title">{!! $section_2_title ?? '' !!}</span>
<strong>{!! $section_2_number ?? '' !!}</strong>
</li>

</ul>