-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlexRepository.php
More file actions
executable file
·53 lines (44 loc) · 1.47 KB
/
Copy pathPlexRepository.php
File metadata and controls
executable file
·53 lines (44 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
namespace XcVm\Module\Plex;
/**
* PlexRepository — plex repository
*
* @package XC_VM_Module_Plex
* @author Divarion_D <https://github.com/Divarion-D>
* @copyright 2025-2026 Vateron Media
* @link https://github.com/Vateron-Media/XC_VM
* @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
*/
class PlexRepository {
use \XcVm\Infrastructure\Database\DatabaseAware;
public static function getPlexServers() {
$rReturn = array();
self::db()->query("SELECT * FROM `watch_folders` WHERE `type` = 'plex' ORDER BY `id` ASC;");
if (0 < self::db()->num_rows()) {
foreach (self::db()->get_rows() as $rRow) {
$rReturn[] = $rRow;
}
}
return $rReturn;
}
public static function enableAll(): void {
self::db()->query("UPDATE `watch_folders` SET `active` = 1 WHERE `type` = 'plex';");
}
public static function disableAll(): void {
self::db()->query("UPDATE `watch_folders` SET `active` = 0 WHERE `type` = 'plex';");
}
public static function getPlexSections($rIP, $rPort, $rToken) {
if (!$rToken) {
return array();
}
$URL = 'http://' . $rIP . ':' . $rPort . '/library/sections?X-Plex-Token=' . $rToken;
$rSections = json_decode(json_encode(simplexml_load_string(file_get_contents($URL))), true);
if (!isset($rSections['Directory'])) {
return array();
}
if (isset($rSections['Directory']['@attributes'])) {
$rSections['Directory'] = array($rSections['Directory']);
}
return $rSections['Directory'];
}
}