優(yōu)酷m3u8解析php,,帶清晰度調(diào)節(jié),內(nèi)有使用說(shuō)明,,拿去用吧,!
- <?php
- /*
- 優(yōu)酷M3U8解析 支持清晰度選擇
- &hd= 的值為清晰度 0-3 分別對(duì)應(yīng) 流暢,標(biāo)清,,高清,,超清
- youku.php?vid=XMjgwNTg1MzAwOA==&hd=3
- youku.php?url=http://v.youku.com/v_show/id_XMjc0NDc5NzAyMA==.html&hd=3
- */
- error_reporting(0);
- header("Content-type:text/xml;charset=utf-8");
- if($_GET['vid']){
- $dourl = "http://ups.youku.com/ups/get.json?vid={$_GET['vid']}&ccode=0501&client_ip=".$_SERVER["REMOTE_ADDR"]."&client_ts=".time()."&utid=EQ3LEfDheTECAd4sVIztAdnL";
- }elseif($_GET['url']){
- preg_match('/id_(.*).html/imsU',$_GET['url'],$url);
- $dourl = "http://ups.youku.com/ups/get.json?vid={$url[1]}&ccode=0501&client_ip=".$_SERVER["REMOTE_ADDR"]."&client_ts=".time()."&utid=EQ3LEfDheTECAd4sVIztAdnL";
- }
- $hd=$_GET['hd']?$_GET['hd']:0;
- $jsurl = CURL($dourl);
- $json = json_decode($jsurl);
- $stream = $json->data->stream;
- $m3u8_url = $stream[$hd]->m3u8_url;
- //print_r($m3u8_url);
- header("Location:$m3u8_url");
- function CURL($url) {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_REFERER, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
- }
- ?>
|