Update: This is where I based the regex off of..
http://www.phpliveregex.com/p/iLL
I can not figure this out for the life of me. I would think it is simple but apparently not.
On an app I am trying to return a url, that has been parsed on a separate page to avoid crossdomain errors and return that url. The problem is it adds #.m3u8 at the end of the url returned IE.
http://ipaddress/stringHere/stringHere/link.m3u8#.m3u8
This is my code..
This page is where the parsing takes place.
<?php
header("Access-Control-Allow-Origin: *");
header("Connection: keep-alive");
header("Content-Type: video/vnd.apple.mpegurl");
header("Accept-Ranges: bytes");
?>
<?php
ob_start(); // ensures anything dumped out will be caught
$html = file_get_contents("https://www.example.com/s/");
preg_match_all(
'/((?:(?:f|ht){1}tp:\/\/)[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+.m3u8)/',
$html,
$posts, // will contain the article data
PREG_SET_ORDER // formats data into an array of posts
);
foreach ($posts as $post) {
$link = $post[1];
// clear out the output buffer
while (ob_get_status())
{
ob_end_clean();
}
// no redirect
header( "Location: $link" );
}
?>
This is the page that is called by the app and has the link returned.
<?php
header("Access-Control-Allow-Origin: *");
header("Connection: keep-alive");
header("Content-Type: video/vnd.apple.mpegurl");
header("Accept-Ranges: bytes");
header("Cache-Control: private, max-age=0, must-revalidate");
?>
<html>
<body>
<?php
include ("parse.php");
?>
</body>
</html>
The result is
http://ipAddress/hls/3691308f2a4c2f6983f2880d32e29c84-313391.m3u8#.m3u8
What I really need is for the result to have the ip replaced with a specific one and the removal of the #.m3u8
http://replacedAddress/hls/3691308f2a4c2f6983f2880d32e29c84-313391.m3u8
I hope someone can help. Im pulling my hair out.