Skip to content

Commit 2969441

Browse files
authored
Update Plex.php
Querying media section data
1 parent a8660e0 commit 2969441

1 file changed

Lines changed: 26 additions & 28 deletions

File tree

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);

0 commit comments

Comments
 (0)