<?php
$url = "http://xxxx.site/get.php?username=xxx&password=xxx&type=m3u_plus&output=ts";
$options = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"User-Agent: Mozilla/5.0 \r\n"
)
);
$context = stream_context_create($options);
#$data = file_get_contents($url);
if(!file_exists("/tmp/testplaylist")) {
$data = file_get_contents($url, false, $context);
file_put_contents("/tmp/testplaylist", $data);
unset($data);
}
$pls = fopen("/tmp/testplaylist", "rb");
if (FALSE === $pls) {
exit("Failed to open stream to URL");
}
$contents = '';
$i = 0;
$down = array();
while (!feof($pls)) {
$line = trim(fgets($pls));
if($line[0] != "#") {
if($handle = @fopen($line, "r")) {
$contents = fread($handle, 1000);
fclose($handle);
file_put_contents("/tmp/c", $contents);
# echo mime_content_type("/tmp/c").PHP_EOL;
@unlink("/tmp/c");
}
else {
echo PHP_EOL . $line ." Down".PHP_EOL;
$down[] = $line;
}
echo $i++ ." ";
}
}
fclose($pls);
print_r($down);