-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_run.php
executable file
·35 lines (32 loc) · 1.43 KB
/
test_run.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
<?php
echo "This script reads the current schedule.json file and confirms the elementals respond to having the livestream enabled.\n";
// required client file
$classfile = __DIR__ . "/class_pbs_elemental_client.php";
require($classfile);
// schedule file
$schedule_filename = __DIR__ . "/schedule.json";
$schedule_file = fopen($schedule_filename, 'r');
$schedule = fread($schedule_file, filesize($schedule_filename));
$channels = json_decode($schedule, TRUE);
if (empty($channels)) {
die("no json_decodable schedule found at $schedule_filename");
}
$channels = json_decode($schedule, TRUE);
if (!empty($channels)) {
echo "Successfully read schedule.json file\n";
}
foreach($channels as $channel_name => $channel) {
if (!empty($channel['blackouts']) && !empty($channel['user']) && !empty($channel['key']) && !empty($channel['host']) ) {
$client = new WNET_PBS_Elemental_Client($channel['user'], $channel['key'], $channel['host']);
$response = $client->enable_elemental_blackout($channel['user'], 'false');
if (!json_decode($response)) {
echo $response . "\n";
echo "bad JSON returned from " . $channel['user'] . "\n";
continue;
}
$status_ary = json_decode($response, true);
$status = !empty($status_ary['status']) ? "true" : "false";
echo "Configured livestream found on " . $channel['host'] ." for $channel_name with status content-restriction $status\n";
}
}
/* EOF */