&$stream) { $stream["url"] = "$GLOBALS[frairable_host]/frontiersmart/radio/custom=$id/play=$index"; } return $data; } function get_radio_play($id, $index) { $data = get_radio_data($id); // clone loves to complain about the stream not being an object... // deep clone using json is ugly, but eh. $stream = json_decode(json_encode($data["streams"][$index]), true); $stream["id"] = ["frontiersmart", "redirect", "custom=$id/play=$index"]; $stream["content"] = $data; unset($stream["reliability"]); return $stream; } if ($_SERVER["REQUEST_URI"] === "/frontiersmart/radios") { airable_proxy(function(&$data) { array_push($data["content"]["entries"], [ "id" => [ "frontiersmart", "directory", "custom" ], "title" => "Frairable (Custom)", "url" => "$GLOBALS[frairable_host]/frontiersmart/radios/custom" ]); }); } elseif ($_SERVER["REQUEST_URI"] === "/frontiersmart/radios/custom") { $entries = []; foreach (new DirectoryIterator($GLOBALS["frairable_dir_radios"]) as $sub) { if ($sub->isDot() || $sub->isDir()) { continue; } $id = basename($sub->getFilename(), ".json"); $entries[] = get_radio_entry($id); } $data = [ "id" => [ "frontiersmart", "directory", "custom" ], "title" => "Frairable (Custom)", "url" => "$GLOBALS[frairable_host]$_SERVER[REQUEST_URI]", "content" => [ "entries" => $entries ] ]; respond_with_json($data); } elseif (str_starts_with($_SERVER["REQUEST_URI"], "/frontiersmart/radio/custom=")) { $id = substr($_SERVER["REQUEST_URI"], strlen("/frontiersmart/radio/custom=")); $split = strpos($id, "/play="); if ($split) { $index = intval(substr($id, $split + strlen("/play="))); $id = substr($id, 0, $split); respond_with_json(get_radio_play($id, $index)); } else { respond_with_json(get_radio_meta($id)); } } else { airable_proxy(); } ?>