-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlexItemCommand.php
More file actions
executable file
·83 lines (63 loc) · 1.8 KB
/
Copy pathPlexItemCommand.php
File metadata and controls
executable file
·83 lines (63 loc) · 1.8 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
namespace XcVm\Module\Plex;
use XcVm\Cli\CommandInterface;
/**
* PlexItemCommand — plex item command
*
* @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 PlexItemCommand implements CommandInterface {
public function getName(): string {
return 'plex_item';
}
public function getDescription(): string {
return 'Process single Plex item (movie/series)';
}
public function execute(array $rArgs): int {
if (posix_getpwuid(posix_geteuid())['name'] != 'xc_vm') {
echo "Please run as XC_VM!\n";
return 1;
}
if (empty($rArgs[0])) {
return 0;
}
setlocale(LC_ALL, 'en_US.UTF-8');
putenv('LC_ALL=en_US.UTF-8');
register_shutdown_function(function () {
global $db;
if (is_object($db)) {
$db->close_mysql();
}
@unlink(WATCH_TMP_PATH . @getmypid() . '.ppid');
});
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(30711);
global $rStreamDatabase;
global $rThreadData;
$rCacheContent = @file_get_contents(WATCH_TMP_PATH . 'stream_database.pcache');
$rStreamDatabase = (is_string($rCacheContent) ? (json_decode($rCacheContent, true) ?: array()) : array());
$rDecodedPayload = base64_decode($rArgs[0], true);
if ($rDecodedPayload === false) {
return 0;
}
$rThreadData = json_decode($rDecodedPayload, true);
if (!is_array($rThreadData)) {
return 0;
}
file_put_contents(WATCH_TMP_PATH . getmypid() . '.ppid', time());
if ($rThreadData['type'] == 'movie') {
$rTimeout = 60;
} else {
$rTimeout = 600;
}
set_time_limit($rTimeout);
ini_set('max_execution_time', $rTimeout);
PlexItem::run();
return 0;
}
}