-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplex-status.php
More file actions
54 lines (46 loc) · 1.24 KB
/
plex-status.php
File metadata and controls
54 lines (46 loc) · 1.24 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
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://".$argv[1].":".$argv[2]."/status/sessions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
if($err)
{
echo "offline";
exit;
}
$array=json_decode(json_encode(simplexml_load_string($response)),true);
if(!isset($array['Video'])){
echo "stop";
exit;
}
if(isset($array['Video']['@attributes'])){
if(!isset($array['Video']['Player'])){
echo "stop";
exit;
}
if($array['Video']['Player']['@attributes']['machineIdentifier'] == $argv[3]){
echo $array['Video']['Player']['@attributes']['state'];
exit;
}
}else{
foreach ($array['Video'] as $key => $video) {
if(!isset($video['Player'])){
continue;
}
if($video['Player']['@attributes']['machineIdentifier'] == $argv[3]){
echo $video['Player']['@attributes']['state'];
exit;
}
}
}
echo "stop";
exit;