!136 fix优酷视频URL有多余参数导致解析错误的问题

Merge pull request !136 from 他乡启程/master
This commit is contained in:
他乡启程 2017-12-12 14:04:26 +08:00 committed by Discuz!
parent 14ec6ab0ed
commit 5785043780
2 changed files with 15 additions and 14 deletions

View File

@ -4,11 +4,11 @@ if(!defined('IN_DISCUZ')) {
exit('Access Denied'); exit('Access Denied');
} }
$checkurl = array('v.qq.com/x/page/'); $checkurl = array('v.qq.com/x/page/','v.qq.com/x/cover/');
function media_qq($url, $width, $height) { function media_qq($url, $width, $height) {
if(preg_match("/https?:\/\/v.qq.com\/x\/page\/([^\/]+)(.html|)/i", $url, $matches)) { if(preg_match("/https?:\/\/v.qq.com\/x\/(page|cover)\/([^\/]+)(.html|)/i", $url, $matches)) {
$vid = explode(".html", $matches[1]); $vid = explode(".html", $matches[2]);
$flv = 'https://imgcache.qq.com/tencentvideo_v1/playerv3/TPout.swf?vid='.$vid[0]; $flv = 'https://imgcache.qq.com/tencentvideo_v1/playerv3/TPout.swf?vid='.$vid[0];
$iframe = 'https://v.qq.com/iframe/player.html?vid='.$vid[0]; $iframe = 'https://v.qq.com/iframe/player.html?vid='.$vid[0];
} }

View File

@ -9,17 +9,18 @@ $checkurl = array('v.youku.com/v_show/');
function media_youku($url, $width, $height) { function media_youku($url, $width, $height) {
$ctx = stream_context_create(array('http' => array('timeout' => 10))); $ctx = stream_context_create(array('http' => array('timeout' => 10)));
if(preg_match("/^https?:\/\/v.youku.com\/v_show\/id_([^\/]+)(.html|)/i", $url, $matches)) { if(preg_match("/^https?:\/\/v.youku.com\/v_show\/id_([^\/]+)(.html|)/i", $url, $matches)) {
$flv = 'https://player.youku.com/player.php/sid/'.$matches[1].'/v.swf'; $params = explode('.', $matches[1]);
$iframe = 'https://player.youku.com/embed/'.$matches[1]; $flv = 'https://player.youku.com/player.php/sid/'.$params[0].'/v.swf';
if(!$width && !$height) { $iframe = 'https://player.youku.com/embed/'.$params[0];
$api = 'http://v.youku.com/player/getPlayList/VideoIDS/'.$matches[1]; if(!$width && !$height) {
$str = stripslashes(file_get_contents($api, false, $ctx)); $api = 'http://v.youku.com/player/getPlayList/VideoIDS/'.$params[0];
if(!empty($str) && preg_match("/\"logo\":\"(.+?)\"/i", $str, $image)) { $str = stripslashes(file_get_contents($api, false, $ctx));
$url = substr($image[1], 0, strrpos($image[1], '/')+1); if(!empty($str) && preg_match("/\"logo\":\"(.+?)\"/i", $str, $image)) {
$filename = substr($image[1], strrpos($image[1], '/')+2); $url = substr($image[1], 0, strrpos($image[1], '/')+1);
$imgurl = $url.'0'.$filename; $filename = substr($image[1], strrpos($image[1], '/')+2);
} $imgurl = $url.'0'.$filename;
} }
}
} }
return array($flv, $iframe, $url, $imgurl); return array($flv, $iframe, $url, $imgurl);
} }