-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
52 lines (47 loc) · 1.84 KB
/
index.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
<?php
if (!isset($_GET['request'])) {
header('HTTP/1.1 404 Not Found');
exit;
}
$config = [
'proxy-url' => $_ENV['DVBLINK_DVBPLEX_URL'],
'dvblink-ip' => $_ENV['DVBLINK_SERVER'],
'dvblink-port' => $_ENV['DVBLINK_PORT'],
];
header('Content-Type: application/json');
switch ($_GET['request']) {
case 'discover.json':
echo json_encode([
'FriendlyName' => 'DVBLink-Proxy',
'ModelNumber' => 'HDTC-2US',
'FirmwareName' => 'hmhomeruntc_atsc',
'TunerCount' => 2,
'FirmwareVersion' => '20150826',
'DeviceID' => '12345678',
'DeviceAuth' => 'auth',
'BaseURL' => $config['proxy-url'],
'LineupURL' => $config['proxy-url'].'/lineup.json',
]);
break;
case 'lineup_status.json':
echo json_encode([
'ScanInProgress' => 0,
'ScanPossible' => 1,
'Source' => 'Cable',
'SourceList' => ['Cable'],
]);
break;
case 'lineup.json':
$request = simplexml_load_string(file_get_contents('http://'.$config['dvblink-ip'].':'.$config['dvblink-port'].'/mobile/?command=get_channels'));
$xml = simplexml_load_string($request->xml_result);
$result = [];
foreach ($xml->channel as $channel) {
$result[] = [
'GuideNumber' => sprintf('%d%s', $channel->channel_number, $channel->channel_subnumber > 0 ? '.'.$channel->channel_subnumber : ''),
'GuideName' => (string)$channel->channel_name,
'URL' => 'http://'.$config['dvblink-ip'].':'.($config['dvblink-port'] + 1).'/dvblink/direct?client=AAABBBCCC&channel='.$channel->channel_dvblink_id,
];
}
echo json_encode($result);
break;
}