Skip to content

Commit 663c81f

Browse files
authored
Plex section status (#828)
* Update livestats.blade.php Print the media section information * Update config.blade.php Setting media section keys * Update Plex.php Querying media section data * Update Plex.php PHPCS fix 30 | ERROR | [x] Expected 1 space after IF keyword; 0 found 45 | ERROR | [x] Expected 1 space after IF keyword; 0 found
1 parent 48e2ab3 commit 663c81f

File tree

3 files changed

+38
-32
lines changed

3 files changed

+38
-32
lines changed

Plex/Plex.php

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -26,37 +26,35 @@ public function test()
2626
public function livestats()
2727
{
2828
$status = "inactive";
29-
$res = parent::execute(
30-
$this->url("/library/recentlyAdded"),
31-
$this->attrs()
32-
);
33-
$body = $res->getBody();
34-
$xml = simplexml_load_string(
35-
$body,
36-
"SimpleXMLElement",
37-
LIBXML_NOCDATA | LIBXML_NOBLANKS
38-
);
39-
4029
$data = [];
41-
42-
if ($xml) {
43-
$data["recently_added"] = $xml["size"];
44-
$status = "active";
30+
if ($this->config->section_1_key > 0) {
31+
$res = parent::execute($this->url("/library/sections/{$this->config->section_1_key}/all"), $this->attrs());
32+
$body = $res->getBody();
33+
$xml = simplexml_load_string(
34+
$body,
35+
"SimpleXMLElement",
36+
LIBXML_NOCDATA | LIBXML_NOBLANKS
37+
);
38+
if ($xml) {
39+
$data["section_1_number"] = $xml["size"];
40+
$data["section_1_title"] = $xml["librarySectionTitle"];
41+
$status = "active";
42+
}
4543
}
4644

47-
$res = parent::execute($this->url("/library/onDeck"));
48-
49-
$res = parent::execute($this->url("/library/onDeck"), $this->attrs());
50-
51-
$body = $res->getBody();
52-
$xml = simplexml_load_string(
53-
$body,
54-
"SimpleXMLElement",
55-
LIBXML_NOCDATA | LIBXML_NOBLANKS
56-
);
57-
if ($xml) {
58-
$data["on_deck"] = $xml["size"];
59-
$status = "active";
45+
if ($this->config->section_2_key > 0) {
46+
$res = parent::execute($this->url("/library/sections/{$this->config->section_2_key}/all"), $this->attrs());
47+
$body = $res->getBody();
48+
$xml = simplexml_load_string(
49+
$body,
50+
"SimpleXMLElement",
51+
LIBXML_NOCDATA | LIBXML_NOBLANKS
52+
);
53+
if ($xml) {
54+
$data["section_2_number"] = $xml["size"];
55+
$data["section_2_title"] = $xml["librarySectionTitle"];
56+
$status = "active";
57+
}
6058
}
6159

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

Plex/config.blade.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
<label>{{ strtoupper(__('app.url')) }}</label>
66
{!! Form::text('config[override_url]', isset($item) ? $item->getconfig()->override_url : null, ['placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control']) !!}
77
</div>
8+
<div class="input">
9+
<label title="">Section 1 Key (<a href="https://support.plex.tv/articles/201638786-plex-media-server-url-commands/" target="_blank">help?</a>)</label>
10+
{!! 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
11+
</div>
12+
<div class="input">
13+
<label title="">Section 2 Key (<a href="https://support.plex.tv/articles/201638786-plex-media-server-url-commands/" target="_blank">help?</a>)</label>
14+
{!! 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
15+
</div>
816
<div class="input">
917
<label title="">Plex Token (<a href="https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/" target="_blank">help?</a>)</label>
1018
{!! Form::text('config[token]', isset($item) ? $item->getconfig()->token : null, ['placeholder' => __('token'), 'data-config' => 'token', 'class' => 'form-control config-item']) !!}

Plex/livestats.blade.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<ul class="livestats">
22
<li>
3-
<span class="title">Recent</span>
4-
<strong>{!! $recently_added ?? '' !!}</strong>
3+
<span class="title">{!! $section_1_title ?? '' !!}</span>
4+
<strong>{!! $section_1_number ?? '' !!}</strong>
55
</li>
66
<li>
7-
<span class="title">On Deck</span>
8-
<strong>{!! $on_deck ?? '' !!}</strong>
7+
<span class="title">{!! $section_2_title ?? '' !!}</span>
8+
<strong>{!! $section_2_number ?? '' !!}</strong>
99
</li>
1010

1111
</ul>

0 commit comments

Comments
 (0)