资源分享

咪咕解析源码

咪咕解析源码

#',$content1,$_a);
}
if (isset($_a[1])) {
$ids['sessionID'] = $_a[1];
}
//print_r($_a);exit;
$json = json_decode($content,true);
$data = $json[0];

$ids['vid'] = $data['playId'];
$ids['title'] = $data['name'];
$ids['poster'] = $data['imgH'];
$ids['url'] = $url;
file_put_contents(NAME_PATH.$name, json_encode($ids));
}

return $ids;
}

public static function get_vip_video_url($ids){
$api = "http://www.miguvideo.com/playurl/v1/play/playurlh5?contId={$ids['vid']}&rateType=1,2,3&clientId={$ids['sessionID']}";
$data = self::curl($api,'',$ids['url']);
//print_r($data);exit;
$d = json_decode($data,true);

if ($d['code'] == '200') {
$data = $d['body'];
$urls = $data['urlInfos'];
$types = $data['mediaFiles'];

$count=0;
foreach ($urls as $key => $value) {
switch ($types[$key]['rateType']) {
case '1':$def = "标清";$vurl = $value['url'];break;
case '2':$def = "高清";$vurl = $value['url'];break;
case '3':$def = "超清";$vurl = $value['url'];break;
}
if ($value['url'] == '') {
continue;
}

if (GlobalBase::is_ipad()) {
if ($types[$key]['rateType']=='1') {
$videoinfo['code'] = 200;
$videoinfo["data"]["url"] = $vurl;
$videoinfo['data']['poster'] = $ids['poster'];
}
} else {
$video_m3u8[0] = str_replace('gslbmgspvod.miguvideo.com','vod.hcs.cmvideo.cn:8088',$vurl);
$video_m3u8[1] = "video/m3u8";
$video_m3u8[2] = $def;
$video_m3u8[3] = $key=="1" ? 10 : 0;
$videoinfo['code'] = 200;
$videoinfo['data']["video"][$count] = $video_m3u8;
$videoinfo['data']['poster'] = $ids['poster'];
$count++;
}
}
return $videoinfo;
}

}

public static function format_video($url,$key){

$ip = GlobalBase::get_ip();

$name = 'MIGUVIDEO-'.md5($key.$ip);

$url_1 = explode('media',$url);
$url_2 = str_replace('gslbmgspvod.miguvideo.com','vod.hcs.cmvideo.cn:8088',$url_1[0]);
$domain = $url_2.'media/';

$_data = file_get_contents($url);

$_data = preg_split('/[\r\n]+/s', $_data);
$d_u = array();
$urls = array();
$bool = true;
$targetduration = "";
foreach ($_data as $value) {
if(strstr($value,"#EXT-X-TARGETDURATION:")){//多码率
$targetduration = $value;
}else if(strstr($value,'#EXTINF:')){//单码率
$d_u[count($d_u)] = $value;
}else if($value&&substr($value,0,1)!="#"){
$urls[count($urls)] = $domain.$value;
}
}
$m3u8 = "#EXTM3U\n#EXT-X-VERSION:3\n";
$m3u8 .= empty($targetduration)?"#EXT-X-TARGETDURATION:7200\n" : $targetduration."\n";
foreach ($d_u as $key => $value) {
$m3u8 .= $value."\n"."../../video/ts.php?url=".base64_encode($urls[$key])."&site=migu\n";
}
$m3u8 .="#EXT-X-ENDLIST";
file_put_contents(M3U8_PATH.$name.".m3u8", $m3u8);
$vurl = "./data/m3u8/".$name.".m3u8";
return $vurl;

}

public static function format_video1($url,$key){

$ip = GlobalBase::get_ip();

$name = 'MIGUVIDEO-'.md5($key.$ip);

$url_1 = explode('media',$url);
$url_2 = str_replace('gslbmgspvod.miguvideo.com','vod.hcs.cmvideo.cn:8088',$url_1[0]);
$domain = $url_2.'media/';

$_data = file_get_contents($url);

$_data = preg_split('/[\r\n]+/s', $_data);
$d_u = array();
$urls = array();
$bool = true;
$targetduration = "";
foreach ($_data as $value) {
if(strstr($value,"#EXT-X-TARGETDURATION:")){//多码率
$targetduration = $value;
}else if(strstr($value,'#EXTINF:')){//单码率
$d_u[count($d_u)] = $value;
}else if($value&&substr($value,0,1)!="#"){
$urls[count($urls)] = $domain.$value;
}
}
$m3u8 = "#EXTM3U\n#EXT-X-VERSION:3\n";
$m3u8 .= empty($targetduration)?"#EXT-X-TARGETDURATION:7200\n" : $targetduration."\n";
foreach ($d_u as $key => $value) {
$m3u8 .= $value."\n".$urls[$key]."\n";
}
$m3u8 .="#EXT-X-ENDLIST";
print_r($m3u8);exit;
file_put_contents(M3U8_PATH.$name.".m3u8", $m3u8);
$vurl = "./data/m3u8/".$name.".m3u8";
return $vurl;

}

public static function curl($url,$cookie="",$ref,$cid='')
{
$params["ua"] = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36";
if ($cid != '') {
$params["fields"] = "cid=".$cid;
}
$params["ref"] = $ref;
return GlobalBase::curl($url,$params);
}
}
?>

(0)

本文由 柴郡猫-cheshirex,搬瓦工VPS,bandwagonhost 作者:cheshirex 发表,转载请注明来源!

关键词:

热评文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注