码迷,mamicode.com
首页 > Web开发 > 详细

php获取音悦台视频

时间:2014-11-25 16:21:30      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:blog   http   os   on   div   log   bs   amp   as   

<?php
	$url=isset($_GET[‘url‘])?trim($_GET[‘url‘]):‘‘;
	$url = "http://v.yinyuetai.com/video/692888";
	//http://v.yinyuetai.com/video/2185713
	$time=$_SERVER[‘REQUEST_TIME‘];
	$content = file_get_contents($url);
	//获取标题
	preg_match(‘/property="og:title"[\s]+content="([^"]*)".*?>/i‘,$content,$title);
	//获取封面
	preg_match(‘/property="og:image" content="([^"]*)".*?>/‘,$content,$images);
	//获取MV的ID
	preg_match(‘/[\d]+/‘,$url,$song_id);
	$title=$title[1];
	$images=$images[1];
	$song_id=$song_id[0];
	//解析json
	$songurl = "http://www.yinyuetai.com/api/info/get-video-urls?callback=callback&videoId=".$song_id."&_=".$time;
	$data = file_get_contents($songurl);
	if (strpos($data, "callback") !== false){
	    $lpos = strpos($data, "(");
	    $rpos = strrpos($data, ")");
	    $data  = substr($data, $lpos + 1, $rpos - $lpos -1);
	}
	$json= json_decode($data,true);
	echo $title."<br/>";
	echo "流畅地址:".$json[‘hcVideoUrl‘]."<br/>";
	echo "高清地址:".$json[‘hdVideoUrl‘]."<br/>";
	echo "超清地址:".$json[‘heVideoUrl‘]."<br/>";
	echo "<img src=\"".$images."\"/>";
?>

  

php获取音悦台视频

标签:blog   http   os   on   div   log   bs   amp   as   

原文地址:http://www.cnblogs.com/rnckty/p/4121097.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!