分享

优酷m3u8解析php,带清晰度调节

 黄三岁大爱人生 2018-06-04
优酷m3u8解析php,带清晰度调节,内有使用说明,拿去用吧!
  1. <?php
  2. /*
  3. 优酷M3U8解析 支持清晰度选择
  4. &hd= 的值为清晰度 0-3 分别对应 流畅,标清,高清,超清
  5. youku.php?vid=XMjgwNTg1MzAwOA==&hd=3
  6. youku.php?url=http://v.youku.com/v_show/id_XMjc0NDc5NzAyMA==.html&hd=3
  7. */

  8. error_reporting(0);
  9. header("Content-type:text/xml;charset=utf-8");
  10. if($_GET['vid']){
  11.         $dourl = "http://ups.youku.com/ups/get.json?vid={$_GET['vid']}&ccode=0501&client_ip=".$_SERVER["REMOTE_ADDR"]."&client_ts=".time()."&utid=EQ3LEfDheTECAd4sVIztAdnL";
  12. }elseif($_GET['url']){
  13.         preg_match('/id_(.*).html/imsU',$_GET['url'],$url);
  14.         $dourl = "http://ups.youku.com/ups/get.json?vid={$url[1]}&ccode=0501&client_ip=".$_SERVER["REMOTE_ADDR"]."&client_ts=".time()."&utid=EQ3LEfDheTECAd4sVIztAdnL";
  15. }
  16. $hd=$_GET['hd']?$_GET['hd']:0;
  17. $jsurl = CURL($dourl);
  18. $json = json_decode($jsurl);
  19. $stream = $json->data->stream;
  20. $m3u8_url = $stream[$hd]->m3u8_url;
  21. //print_r($m3u8_url);
  22. header("Location:$m3u8_url");
  23. function CURL($url) {
  24.   $ch = curl_init();
  25.   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
  26.   curl_setopt($ch, CURLOPT_HEADER, false);
  27.   curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
  28.   curl_setopt($ch, CURLOPT_URL, $url);
  29.   curl_setopt($ch, CURLOPT_REFERER, $url);
  30.   curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  31.   $result = curl_exec($ch);
  32.   curl_close($ch);
  33.   return $result;
  34. }
  35. ?>

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多