我得到了以下 m3u8 作为 php 变量($returned_content)。现在我想用 video2.de.secondsite.net 替换所有m3u8 的proxy-63.somesite.com部分,然后为每个分辨率创建一个超链接并将所有超链接放在 textarea 中。(对于每个分辨率超链接,我想放置分辨率m3u8 在超链接标题后的括号中)。
谁能告诉我如何完成这项任务?提前致谢
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=836280,CODECS="mp4a.40.2,avc1.64001f",RESOLUTION=768x432
http://proxy-63.somesite.com/sec(42341234k32jlkjk234lkwerwlk32432)/video/600/500/12345678_mp4_h264_aac_hq_2.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=246440,CODECS="mp4a.40.2,avc1.42000d",RESOLUTION=320x180
http://proxy-63.somesite.com/sec(45432kjkhjkj4535lkj34543454lkj43)/video/600/500/12345678_mp4_h264_aac_ld_2.m3u8
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=460560,CODECS="mp4a.40.2,avc1.42001e",RESOLUTION=512x288
http://proxy-63.somesite.com/sec(dfgghdfdgd987435392429324343241k)/video/600/500/12345678_mp4_h264_aac_2.m3u8
PHP
$returned_content = get_data(''.$m3u8Url);
/* gets the data from a URL */
function get_data($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$link_text .="<a href=\"../Player.php?&vidID=".$m3u8Url."&title=".$title_name."\">".$title_name."."(".".$resolution.".")"</a><br/>\n";