forked from MattsShack/Plex-Movie-Poster-Display
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconfig.php
More file actions
executable file
·75 lines (72 loc) · 2.48 KB
/
Copy pathconfig.php
File metadata and controls
executable file
·75 lines (72 loc) · 2.48 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
<?php
session_start();
include('./psConfig.php');
$get_plex_token = array();
$plexServer_url = array();
$getConfig = array();
$clientsxml = array();
$clientdata = array();
//Pseudo Channel Config File
$pseudoConfig = $pseudochannel . "pseudo_config.py";
$getConfig = file_get_contents($pseudoConfig);
$getConfig = explode("\n",$getConfig);
//Get Plex data from plex_token file in Pseudo Channel
$plex_token = $pseudochannel . "plex_token.py";
$get_token = file_get_contents($plex_token);
$get_plex_token = explode("\n", $get_token);
$baseurl = $get_plex_token['1'];
$baseurl = str_replace("'","",$baseurl);
$baseurl = str_replace("baseurl = ","",$baseurl);
$plexServer_url = parse_url($baseurl);
$plexServer = $plexServer_url['host'];
$plexport = $plexServer_url['port'];
$token = $get_plex_token['0'];
$token = str_replace("'","",$token);
$plexToken = str_replace("token = ","",$token);
//Get Client Name from Pseudo Channel Config
$configClientName = $getConfig[40];
$configClientName = trim($configClientName, 'plexClients = ["');
$configClientName = str_replace('"]','',$configClientName);
$configClientName = trim($configClientName);
$pseudochannelMaster = $pseudochannel;
$pseudochannelMaster = trim($pseudochannelMaster);
$pseudochannelTrim = rtrim($pseudochannel,'/');
$plexClientName = $configClientName;
$user = "pi";
$user = $pseudochannel;
$user = strstr($user, "/home/"); //gets all text from needle on
$user = strstr($user, "/channels", true); //gets all text before needle
$userpatharr = explode('/home/', $user);
if(count($userpatharr) > 1){
$user = $userpatharr[1];
}else {
$user = 'pi';
}
if (isset($_SESSION['tv'])) {
$plexClientName = $_SESSION['tv'];
$urlstring = "tv=" . $_SESSION['tv'] . "&";
if ($_SESSION['tv'] != $configClientName) {
$pseudochannel = $pseudochannelTrim . "_" . $_SESSION['tv'] . "/";
$pseudochannel = trim($pseudochannel);
}
} else {
$urlstring = "";
}
if (isset($_SESSION['size'])) {
$DisplayType=$_SESSION['size'];
} else {
$_SESSION['size'] = $DisplayType;
}
//Get Other Plex Client Data from Plex API
$clientsurl = "http://" . $plexServer . ":" . $plexport . "/clients?X-Plex-Token=" . $plexToken;
$getclientsxml = file_get_contents($clientsurl);
$clientsxml = simplexml_load_string($getclientsxml);
foreach($clientsxml->Server as $key => $clientdata) {
$clientname = $clientdata['name'];
if($clientname == $plexClientName) {
$plexClientIP = $clientdata['address'];
$plexClient = trim($plexClientIP);
$plexClientUID = $clientdata['machineIdentifier'];
}
}
?>