-
Notifications
You must be signed in to change notification settings - Fork 1
/
plex.php
95 lines (77 loc) · 2.24 KB
/
plex.php
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
84
85
86
87
88
89
90
91
92
93
94
95
<?php
class plexApi {
public $plexServer = "localhost";
public $plexToken = "";
public function __construct ($plexServer, $plexToken) {
if(trim($plexServer)==""){
throw new Exception("Plex Server Not Specified");
}
if(trim($plexToken)==""){
throw new Exception("Plex Token Not Specified");
}
$this->plexServer = $plexServer;
$this->plexToken = $plexToken;
}
public function getData($link, $get){
$Data = file_get_contents('http://'.$this->plexServer.':32400'.$link.'?X-Plex-Token='.$this->plexToken.'');
return $Data;
}
/* Agents available (and some of their configuration) */
public function getPlayers(){
$link="/system/agents";
$get="";
return $this->getData($link, $get);
}
/* This will retrieve the "Now Playing" Information of the PMS. */
public function getSessions(){
$link="/status/sessions";
$get="";
return $this->getData($link, $get);
}
/* Contains all of the sections on the PMS. This acts as a directory and you are able to "walk" through it. */
public function getMedia(){
$link="/library/sections";
$get="";
return $this->getData($link, $get);
}
/* Get Plex.TV account information */
public function getAccount(){
$link="/myplex/account";
$get="";
return $this->getData($link, $get);
}
/* get the local List of servers */
public function getServers(){
$link="/servers";
$get="";
return $this->getData($link, $get);
}
/* Retrieves a listing of all history views */
public function getHistory(){
$link="/status/sessions/history/all";
$get="";
return $this->getData($link, $get);
}
/* General plex system information */
public function getSystem(){
$link="/system";
$get="";
return $this->getData($link, $get);
}
/* Show ondeck list */
public function getOnDeck(){
$link="/library/onDeck";
$get="";
return $this->getData($link, $get);
}
/* Gets the server preferences */
public function getPrefs(){
$link="/:/prefs";
$get="";
return $this->getData($link, $get);
}
/* create image url from thumb */
public function getImage($name){
return "http://".$this->plexServer.":32400".$name."?X-Plex-Token=".$this->plexToken;
}
}