Created
December 8, 2015 14:12
-
-
Save nathanpitman/5f59edd56715c5f4f68d to your computer and use it in GitHub Desktop.
Used to parse Vimeo HLS URLs to negate issues with redirects and JW Player
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Parse Vimeo M3U8 URLs to negate relative redirect issues with JW Player (See issue #1510) | |
* | |
* @return string | |
*/ | |
public function parseHLSUrl($url) | |
{ | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); //set url | |
curl_setopt($ch, CURLOPT_HEADER, true); //get header | |
curl_setopt($ch, CURLOPT_NOBODY, true); //do not include response body | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //do not show in browser the response | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //follow any redirects | |
curl_exec($ch); | |
$new_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL); //extract the url from the header response | |
curl_close($ch); | |
return $new_url; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works great momentarily, but hls playlist redirects must be reprocessed every-so-often because the tokens used seem to expire.