使用php抓取m3u8直播流制作m3u8 进行播放
header("Content-type: application/text");
header("Content-Disposition: attachment; filename=index.m3u8");
$url = "http://111.40.205.87/PLTV/88888888/224/3221225710/index.m3u8";
$header = get_headers($url,1);
$location = $header["Location"];
$url = $location;
preg_match("#(.*)/.*m3u8#is",$url,$view);
$bath_url = trim($view[1]);
$c = file_get_contents($url);
preg_match_all("#,(.*.ts)#isU", $c, $vv);
$match_view = $vv[1];
$res = [];
foreach ($match_view as $key => $value) {
$old_value = $value;
$value = str_replace("
", "", $value);
$value = str_replace("", "", $value);
$value = str_replace("
", "", $value);
$ts = "
".$bath_url."/".$value;
$c = str_replace($old_value,$ts,$c);
//$match_view[$key] = $bath_url."/".$value;
}
echo $c;