Skip to content

Instantly share code, notes, and snippets.

@nathanpitman
Created December 8, 2015 14:12
Show Gist options
  • Save nathanpitman/5f59edd56715c5f4f68d to your computer and use it in GitHub Desktop.
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
/**
* 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;
}
@powellzer
Copy link

powellzer commented Jun 9, 2016

This works great momentarily, but hls playlist redirects must be reprocessed every-so-often because the tokens used seem to expire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment