private static function getVideoData($vid) { //pptv 接口 http://play.api.pptv.com/boxplay.api?cb=json&auth=mpptv&ver=2&id=16904252&ft=5&type=mpptv&platform=ikan&_=1382552026550 $file_array = $data = array(); $get_url = "http://play.api.pptv.com/boxplay.api?cb=json&auth=mpptv&ver=2&id=" . $vid . "&ft=5&type=mpptv&platform=ikan&_=" . time() . mt_rand(100, 999); $video_json = rtrim(ltrim(Base::_cget($get_url), 'json ('), ');'); $video_data = json_decode($video_json, true); foreach ($video_data['childNodes'] as $nodeVals) { //获得影片名称和视频文件参数 if ($nodeVals['tagName'] == 'channel') { $data['title'] = $nodeVals['nm']; $data['seconds'] = $nodeVals['dur']; foreach ($nodeVals['childNodes'] as $nodeVal) { if ($nodeVal['tagName'] == 'file') { foreach ($nodeVal['childNodes'] as $node) { if ($node['tagName'] == 'item') { //获取视频文件参数地址 $file_array[$node['ft']]['file'] = $node['rid']; $file_array[$node['ft']]['height'] = $node['height']; $file_array[$node['ft']]['width'] = $node['width']; } } } } } //获得视频地址参数 if ($nodeVals['tagName'] == 'dt') { foreach ($nodeVals['childNodes'] as $nodeVal) { //获取视频ip地址 if ($nodeVal['tagName'] == 'sh') { $file_array[$nodeVals['ft']]['host'] = $nodeVal['childNodes'][0]; } //获取视频key值 if ($nodeVal['tagName'] == 'key') { $file_array[$nodeVals['ft']]['key'] = $nodeVal['childNodes'][0]; } } } } if (!empty($file_array)) { foreach ($file_array as $key => $val) { //构建视频地址 视频地址不能带 key值 if ($key == 0) { $data['normal'][] = 'http://' . $val['host'] . '/0/' . $val['file'] . '?k=' . $val['key'] . '&type=web.fpp'; } if ($key == 1) { $data['high'][] = 'http://' . $val['host'] . '/0/' . $val['file'] . '?k=' . $val['key'] . '&type=web.fpp'; } if ($key == 2) { $data['super'][] = 'http://' . $val['host'] . '/0/' . $val['file'] . '?k=' . $val['key'] . '&type=web.fpp'; } if ($key == 5) { $data['fluent'][] = 'http://' . $val['host'] . '/0/' . $val['file'] . '?k=' . $val['key'] . '&type=web.fpp'; } } return $data; } else { return false; } }
/** * [_getYouku description] * @param [type] $vid [视频id] * @return [type] [description] */ public static function _getYouku($vid) { //$link = "http://v.youku.com/player/getPlayList/VideoIDS/{$vid}/Pf/4"; //获取视频信息json 有些视频获取不全(土豆网的 火影忍者) $link = "http://v.youku.com/player/getPlayList/VideoIDS/{$vid}/timezone/+08/version/5/source/out/Sc/2?ev=1&ran=" . mt_rand(1999, 8999) . "&n=3&ctype=60&password="******"0" . $no; //no 为每段视频序号 } $_k = !empty($v['k']) ? $v['k'] : $rs['data'][0]['key2'] . $rs['data'][0]['key1']; //构建视频地址K值 $fileId = self::getFileid($streamfileids[$key], $seed); //判断后缀类型 、获得后缀 $typeArray = array("flv" => "flv", "mp4" => "mp4", "hd2" => "flv", "3gphd" => "mp4", "3gp" => "flv", "hd3" => "flv"); //判断视频清晰度 $sharpness = array("flv" => "normal", "flvhd" => "normal", "mp4" => "high", "hd2" => "super", "3gphd" => "high", "3gp" => "normal", "hd3" => "original"); //清晰度 数组 $fileType = $typeArray[$key]; $startId = substr($fileId, 0, 8); //截取 拼凑 fileid $endId = substr($fileId, 10, strlen($fileId)); $data[$sharpness[$key]][$k] = "http://f.youku.com/player/getFlvPath/sid/" . self::getSid() . "_{$no}/st/{$fileType}/fileid/" . $startId . $no . $endId . "?K=" . $_k; } } } //返回 图片 标题 链接 时长 视频地址 $data['img'] = $rs['data'][0]['logo']; $data['title'] = $rs['data'][0]['title']; $data['seconds'] = $rs['data'][0]['seconds']; return $data; } else { return false; } }
/** * [parseXml 解析相关xml] * @param [type] $url [description] * @return [type] [description] */ public static function parseXml($url) { $xml_str = Base::_cget($url); $xml_obj = @simplexml_load_string($xml_str); $playurl = $xml_obj->playurl; if (!empty($playurl)) { $play_str = strval($playurl); $play_json = json_decode($play_str, true); if (is_array($play_json)) { return $play_json; } else { return false; } } else { return false; } }
private static function parseXml($url) { $video = $seconds = $title = ''; $video_url = array(); $xml_str = Base::_cget($url); if (!empty($xml_str)) { $video = @simplexml_load_string($xml_str); $seconds = intval($video->timelength) / 1000; //获得时长 $title = strval($video->vname); //解析视频地址 $durl = $video->durl; for ($i = 0; $i < $durl->count(); $i++) { $video_url[] = strval($durl[$i]->url); } return array("title" => $title, "seconds" => $seconds, 'url' => $video_url); } else { return false; } }
public static function parse($url) { $key = ""; $data = $keys = array(); //pps 的站点数组 $pps_sites = array("dp.ugc.pps.tv", "dp.ppstream.com", "dp.ppstv.com"); if (strpos($url, "/play_") != false) { $keys = explode('.', substr($url, strpos($url, "play_") + 5)); $key = $keys[0] ? trim($keys[0]) : ''; if ($key) { foreach ($pps_sites as $val) { //pps 的api 接口 http://dp.ppstv.com/get_play_url_cdn.php?sid=312WAZ&flash_type=1&type=0 type = 0/1/2 貌似表示清晰度? $get_url = "http://" . $val . "/get_play_url_cdn.php?sid=" . $key . "&flash_type=1"; //$headers = @get_headers($get_url); 根据返回的状态来判断 is_array($headers) && (strrpos($headers[0], "200") != false) $video_str = @Base::_cget($get_url); if (!empty($video_str) && strpos($video_str, ".pfv") != false) { $video_array = explode("&", $video_str); $data['normal'][] = substr($video_str, 0, strpos($video_str, "?")); $data['title'] = $video_array[2] ? ltrim($video_array[2], 'title=') : ''; $data['seconds'] = $video_array[5] ? ltrim($video_array[5], 'ct=') : ''; break; } } if (!empty($data)) { $html = Base::_cget($url); $video_ids = array(); preg_match('#video_id:\\s*"([^"]+)"#', $html, $video_ids); $video_id = $video_ids[1] ? trim($video_ids[1]) : ''; //pps 的html5 接口 $h5_url = "http://active.v.pps.tv/ugc/ajax/aj_html5_url.php?url_key={$key}&video_id={$video_id}"; $h5_data = json_decode(substr(ltrim(Base::_cget($h5_url), "html5url("), 0, -1), true); $data['fulent'][] = $h5_data[0]['path']; } return $data; } else { return false; } } else { return false; } }
public static function parse($url) { $data = $vid_array = $video_data = array(); $vid = ''; if (strpos($url, "vid-")) { $vid_array = explode(".", substr($url, strrpos($url, "vid-") + 4)); $vid = $vid_array[0]; } else { if (strpos($url, "v_")) { $vid_array = explode(".", substr($url, strrpos($url, "v_") + 2)); $vid = $vid_array[0]; } } if (!empty($vid)) { //获取56视频的地址 $video_url = "http://vxml.56.com/json/{$vid}/?src=site"; $video_json = Base::_cget($video_url); $video_data = json_decode($video_json, true); if (is_array($video_data) && !empty($video_data['info']['rfiles'])) { $data['title'] = $video_data['info']['Subject']; $data['seconds'] = ceil(intval($video_data['info']['duration']) / 1000); foreach ($video_data['info']['rfiles'] as $key => $val) { if ($val['type'] == "normal") { $data['normal'][] = $val['url']; } if ($val['type'] == "clear") { $data['high'][] = $val['url']; } if ($val['type'] == "super") { $data['super'][] = $val['url']; } } return $data; } else { return false; } } else { return false; } }
private static function getVideoData($pid) { $data = array(); //http://pgmsvr.tv189.cn/program/getVideoPlayInfo?pid={$pid} 此api已经过期 $getUrl = "http://pgmsvr.tv189.cn/program/getVideoPlayInfo2?pid={$pid}"; //获得视频地址的新api地址 2014年2月改版的 $videoXml = Base::_cget($getUrl); if (empty($videoXml)) { return false; } $strXml = @simplexml_load_string($videoXml); $videoObj = $strXml->dt->ct; $data['title'] = strval($videoObj->tt); $urls = $videoObj->url; if ($urls->count() > 0 && is_object($urls)) { for ($i = 0; $i < $urls->count(); $i++) { foreach ($urls[$i]->attributes() as $key => $val) { //视频地址需要去掉最后的end=300 里的300 否者只能播放300秒 即5分钟 if ($key == 'cr' && $val == "450P") { $data['normal'][] = rtrim(strval($urls[$i]), '300'); } if ($key == 'cr' && $val == "720P") { $data['high'][] = rtrim(strval($urls[$i]), '300'); } if ($key == 'cr' && $val == "1080P") { $data['super'][] = rtrim(strval($urls[$i]), '300'); } if ($key == 'tm' && empty($data['seconds'])) { $data['seconds'] = strval($val); } } } return $data; } else { return false; } }
public static function parse($url) { $html = Base::_cget($url); $videos = $infos = $data = $video_data = array(); preg_match("#VIDEOINFO\\s*=\\s*(\\{[\\s\\S]+?\\})#ms", $html, $videos); //修复json 里面的 键值不能像 http:// 等 存在冒号的 否则会 修复失败 $infos = json_decode(preg_replace('@([\\w_0-9]+):@', '"\\1":', str_replace('\'', '"', $videos[1])), true); if (empty($infos)) { return false; exit(0); } else { $limitrate = intval($infos['limit_rate'] * 1.2); //通过拼接参数 来获得视频地址 $fhv_url = "http://pcvcr.cdn.imgo.tv/ncrs/vod.do?fid=" . $infos['code'] . "&limitrate=" . $limitrate . "&file=" . $infos['file'] . "&fmt=2&pno=1"; $m3u8_url = "http://pcvcr.cdn.imgo.tv/ncrs/vod.do?fid=" . $infos['code'] . "&limitrate=" . $limitrate . "&file=" . $infos['file'] . "&fmt=6&pno=3&m3u8=1"; $video_data = json_decode(Base::_cget($fhv_url), true); if ($video_data) { $data['normal'][] = $video_data['info']; return $data; } else { return false; } } }
/** * [getVideoRate 获得视频的码率数组] * @param [type] $url [description] * @return [type] [description] */ private static function getVideoRate($url) { $sharpness = array(); $video_info = json_decode(Base::_cget($url), true); $video_rate = explode(";", $video_info["RateInfo"]); if (is_array($video_rate) && !empty($video_rate)) { foreach ($video_rate as $key => $val) { $tmp_array = explode("@", $val); if ($tmp_array[1] == "流 畅") { $sharpness["fluent"] = $tmp_array[0]; } if ($tmp_array[1] == "标 清") { $sharpness["normal"] = $tmp_array[0]; } if ($tmp_array[1] == "高 清") { $sharpness["high"] = $tmp_array[0]; } if ($tmp_array[1] == "超 清") { $sharpness["super"] = $tmp_array[0]; } } } return $sharpness; }
/** * [getKey 根据参数获得视频地址参数] * @param [type] $vid [description] * @param [type] $filename [description] * @param [type] $vt [description] * @param [type] $format [description] * @return [type] [description] */ private static function getKey($vid, $filename, $vt, $format) { $url = "http://vv.video.qq.com/getkey"; $data = array("otype" => "json", "charge" => "0", "ran" => floatval('0.' . mt_rand(10000000, 90000000)), "filename" => $filename, "platform" => "11", "format" => $format, "vid" => $vid, "vt" => $vt, "defaultfmt" => "hd"); $jsonStr = Base::_cget($url, Base::USER_AGENT, $data, self::REFERER); $jsonArr = json_decode(substr($jsonStr, strpos($jsonStr, '{'), -1), true); return $jsonArr; }
/** * [parseFlv2 解析网站flv格式的视频,第二种方法] * @param [type] $tvid [description] * @param [type] $vid [description] * @return [type] [description] */ private static function parseFlv2($tvid, $vid) { $api_url = "http://cache.video.qiyi.com/vms?key=fvip&src=1702633101b340d8917a69cf8a4b8c7c"; $api_url = $api_url . "&tvId=" . $tvid . "&vid=" . $vid . "&vinfo=1&tm=" . self::$deadpara . "&enc=" . static::calenc($tvid); $video_datas = json_decode(Base::_cget($api_url), true); $vs = $video_datas['data']['vp']['tkl'][0]['vs']; //.data.vp.tkl[0].vs $time_url = "http://data.video.qiyi.com/t?tn=" . static::randomFloat(); $time_datas = json_decode(Base::_cget($time_url), true); $server_time = $time_datas['t']; $urls_data = $data = array(); if (is_array($vs) && count($vs) > 0) { foreach ($vs as $val) { //720p 和1080p 的视频地址暂时无法获得。 $data['seconds'] = $val['duration']; foreach ($val['fs'] as $v) { $this_link = $v['l']; if ($val['bid'] == 4 || $val['bid'] == 5 || $val['bid'] == 10) { $this_link = static::getVrsEncodeCode($this_link); } $sp = explode('/', $this_link); $sp_length = count($sp); $fileId = explode('.', $sp[$sp_length - 1])[0]; $this_key = static::calmd($server_time, $fileId); $this_link = $this_link . '?ran=' . self::$deadpara . '&qyid=08ca8cb480c0384cb5d3db068161f44f&qypid=' . $tvid . '_11&retry=1'; $final_url = "http://data.video.qiyi.com/" . $this_key . "/videos" . $this_link; if ($val['bid'] == 96) { $urls_data['fluent'][] = $final_url; } if ($val['bid'] == 1) { $urls_data['normal'][] = $final_url; } if ($val['bid'] == 2) { $urls_data['high'][] = $final_url; } if ($val['bid'] == 3) { $urls_data['super'][] = $final_url; } if ($val['bid'] == 4) { $urls_data['SUPER_HIGH'][] = $final_url; } if ($val['bid'] == 5) { $urls_data['FULL_HD'][] = $final_url; } if ($val['bid'] == 10) { $urls_data['FOUR_K'][] = $final_url; } } } if (!empty($urls_data['fluent'])) { $data['极速'] = self::getVideoUrl($urls_data['fluent']); } if (!empty($urls_data['normal'])) { $data['流畅'] = self::getVideoUrl($urls_data['normal']); } if (!empty($urls_data['high'])) { $data['高清'] = self::getVideoUrl($urls_data['high']); } if (!empty($urls_data['super'])) { $data['超清'] = self::getVideoUrl($urls_data['super']); } if (!empty($urls_data['SUPER_HIGH'])) { $data['720P'] = self::getVideoUrl($urls_data['SUPER_HIGH']); } if (!empty($urls_data['FULL_HD'])) { $data['1080P'] = self::getVideoUrl($urls_data['FULL_HD']); } if (!empty($urls_data['FOUR_K'])) { $data['4K'] = self::getVideoUrl($urls_data['FOUR_K']); } return $data; } else { return false; } }
private static function parseVideoUrl2($vid, $sub_ip) { $data = $urls = $data_urls = array(); $api_url = "http://" . $sub_ip[0] . "/vrs_flash.action?vid={$vid}&out=0&g=8&r=2&t=0." . mt_rand(100, 999); $video_data = json_decode(Base::_cget($api_url), true); if (is_array($video_data) && !empty($video_data)) { foreach ($video_data['data']['clipsURL'] as $key => $val) { $su_key = $video_data['data']['su'][$key]; $url = "http://data.vod.itc.cn/preview?file=" . $su_key; $urls[] = $url; /*curl 获取header $headers = Base::getHeader($url); preg_match("#Location:\s*(.+)#",$headers,$locations); $param_array = $locations[1]; */ /* //一次获得一个视频地址的,速度慢 $param_array = get_headers($url,1); //视频截图地址 http://data.vod.itc.cn/preview?file=/233/52/28FAAL9Tq9UX9kOatm6bj7.mp4&start=28 //相对视频地址 中间多了个thumb http://219.238.10.45/sohu/thumb/1/233/52/28FAAL9Tq9UX9kOatm6bj7.mp4?start=28&key=uGacwCdCKICxxJnliepKI_od5tZlsh3ONPL_ow..&n=13&a=4019&cip=101.39.251.131 $video_url = str_replace('/thumb/', '/',$param_array['Location']); //获得地址转向 $data[] = $video_url; */ } $data_urls = self::rolling_curl_url2($urls); ksort($data_urls); //获得数组根据key值排序 $data = array_values($data_urls); return $data; } else { return false; } }
public static function getVideoList($movie_id, $subids, $video_names) { $data = array(); if (is_array($subids) && count($subids) > 0) { foreach ($subids as $k => $v) { $data[$k]['name'] = iconv("gbk", "utf-8", $video_names[$k]); //获得视频的名字 $url = "http://api.movie.kankan.com/vodjs/subdata/" . floor($movie_id / 1000) . "/" . $movie_id . "/" . $v . ".js"; $movie_str = Base::_cget($url); preg_match("#surls:\\s*\\[([^]]+)\\]#", $movie_str, $surls); eval('$surls_array = array(' . $surls[1] . ');'); //转化为数组 $surls_array = array_filter($surls_array); // 过滤数组 preg_match("#msurls:\\s*\\[([^]]+)\\]#", $movie_str, $msurls); eval('$msurls_array = array(' . $msurls[1] . ');'); $msurls_array = array_filter($msurls_array); if (is_array($surls_array) && count($surls_array) > 0) { foreach ($surls_array as $key => $val) { $tmp_array = explode('/', $val); $gcid = $tmp_array[4]; $data[$k]['flv'][self::$sharpness_array[$key]][] = self::getVideoUrl($gcid); } } if (is_array($msurls_array) && count($msurls_array) > 0) { foreach ($msurls_array as $key => $val) { $tmp_array = explode('/', $val); $gcid = $tmp_array[4]; $data[$k]['mp4'][self::$sharpness_array[$key]][] = self::getVideoUrl($gcid, "mp4"); } } } } return $data; }
/** * [getFlvcdUrl 通过flvcd来解析视频地址] * @param [type] $url [description] * @return [type] [description] */ public static function getFlvcdUrl($url) { $url = "http://www.flvcd.com/parse.php?kw=" . urlencode($url); $result = array(); for ($i = 0; $i < 4; $i++) { if ($i == 0) { $url = $url . '&flag=one&format=super'; } if ($i == 1) { $url = $url . '&flag=one&format=high'; } if ($i == 2) { $url = $url . '&flag=one&format=normal'; } if ($i == 3) { $url = $url . '&flag=one&format=fluent'; } $_str = Base::_cget($url); $match = $matchs = array(); preg_match('/name="inf"\\s*value="([^"]+)"/i', $_str, $matchs); //匹配多视频地址 $download = iconv('utf-8', 'gbk', '下载地址:'); preg_match('/' . $download . '([^<]*)<a href="([^"]+)"/i', $_str, $match); preg_match('/title = "([^"]+)"/i', $_str, $names); //匹配视频标题 $name 数组的第二个是标题 if ($match && trim($match[2])) { $urls = trim($match[2]); } else { if (is_array($matchs) && !empty($matchs[1])) { $urls = substr($matchs[1], -1) == '|' ? substr($matchs[1], 0, -1) : $matchs[1]; } else { break; } } if ($urls) { switch ($i) { case 0: $sharpness = 'super'; break; case 1: $sharpness = 'high'; break; case 2: $sharpness = 'normal'; break; case 3: $sharpness = 'fluent'; break; } if ($sharpness == 'normal') { $result['title'] = iconv('gbk', 'utf-8', $names[1]); } $result[$sharpness] = array_filter(explode('|', $urls)); } } return $result; }
/** * [getPlayUrl 根据前面拿到的url 获得视频地址] * @param [type] $url [description] * @return [type] [description] */ private static function getPlayUrl($url) { $tn = mt_rand(10000, 99999) * 865; $url = $url . "&termid=1&format=1&hwtype=un&ostype=Windows8.1&tag=letv&sign=letv&expect=3&tn=0." . $tn . "&pay=0&rateid=1000"; $playJson = Base::_cget($url); $urls = json_decode($playJson, true); if ($urls['location']) { return $urls['location']; } else { return false; } }
/** * [_getYouku description] * @param [type] $vid [视频id] * @return [type] [description] */ public static function _getYouku($vid) { //$link = "http://v.youku.com/player/getPlayList/VideoIDS/{$vid}/Pf/4"; //获取视频信息json 有些视频获取不全(土豆网的 火影忍者) $base = "http://v.youku.com/player/getPlaylist/VideoIDS/"; $blink = $base . $vid; $link = $blink . "/Pf/4/ctype/12/ev/1"; $retval = Base::_cget($link); $bretval = Base::_cget($blink); if ($retval) { $rs = json_decode($retval, true); $brs = json_decode($bretval, true); if (!empty($rs['data'][0]['error'])) { return false; //有错误返回false } $data = array(); $streamtypes = $rs['data'][0]['streamtypes']; //可以输出的视频清晰度 $streamfileids = $rs['data'][0]['streamfileids']; $seed = $rs['data'][0]['seed']; $segs = $rs['data'][0]['segs']; $ip = $rs['data'][0]['ip']; $bsegs = $brs['data'][0]['segs']; list($sid, $token) = explode('_', static::yk_e('becaf9be', static::yk_na($rs['data'][0]['ep']))); foreach ($segs as $key => $val) { if (in_array($key, $streamtypes)) { foreach ($val as $k => $v) { $no = strtoupper(dechex($v['no'])); //转换为16进制 大写 if (strlen($no) == 1) { $no = "0" . $no; //no 为每段视频序号 } //构建视频地址K值 $_k = $v['k']; if (!$_k || $_k == '' || $_k == '-1') { $_k = $bsegs[$key][$k]['k']; } $fileId = static::getFileid($streamfileids[$key], $seed); $fileId = substr($fileId, 0, 8) . $no . substr($fileId, 10); $ep = urlencode(iconv('gbk', 'UTF-8', static::yk_d(static::yk_e('bf7e5f01', $sid . '_' . $fileId . '_' . $token)))); //判断后缀类型 、获得后缀 $typeArray = array("flv" => "flv", "mp4" => "mp4", "hd2" => "flv", "3gphd" => "mp4", "3gp" => "flv", "hd3" => "flv"); //判断视频清晰度 $sharpness = array("flv" => "normal", "flvhd" => "normal", "mp4" => "high", "hd2" => "super", "3gphd" => "high", "3gp" => "normal", "hd3" => "original"); //清晰度 数组 $fileType = $typeArray[$key]; $data[$sharpness[$key]][$k] = "http://k.youku.com/player/getFlvPath/sid/" . $sid . "_00/st/{$fileType}/fileid/" . $fileId . "?K=" . $_k . "&hd=1&myp=0&ts=" . ($v['seconds'] . '&ypp=0&ctype=12&ev=1&token=' . $token . '&oip=' . $ip . '&ep=') . $ep; } } } //返回 图片 标题 链接 时长 视频地址 $data['img'] = $rs['data'][0]['logo']; $data['title'] = $rs['data'][0]['title']; $data['seconds'] = $rs['data'][0]['seconds']; return $data; } else { return false; } }
/** * [parseFlv2 解析网站flv格式的视频,第二种方法] * @param [type] $tvid [description] * @param [type] $vid [description] * @return [type] [description] */ public static function parseFlv2($tvid, $vid) { $api_url = "http://cache.m.iqiyi.com/jp/tmts"; $api_url = $api_url . '/' . $tvid . '/' . $vid . '/?uid=&cupid=qc_100001_100102&platForm=h5&qyid=80f752d14113d33b394d1390e615e9ba&type=mp4'; $mobile_user_agent = "Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3"; $mobile_referer = "http://m.iqiyi.com/"; $result = Base::_cget($api_url, $mobile_user_agent, '', $mobile_referer); $result = str_replace("var tvInfoJs=", "", $result); $video_datas = json_decode($result, true); $result_data = array(); $result_data['mp4'] = $video_datas["data"]["m3u"]; $result_data['title'] = $video_datas["data"]["playInfo"]["an"]; $result_data['coverImg'] = $video_datas["data"]["playInfo"]["apic"]; return $result_data; // $vs = array(); // if(isset($video_datas['data'])) $vs = $video_datas['data']['vp']['tkl'][0]['vs']; //.data.vp.tkl[0].vs // $time_url = "http://data.video.qiyi.com/t?tn=".Iqiyi::randomFloat(); // $time_datas = json_decode(Base::_cget($time_url),true); // $server_time = $time_datas['t']; // $urls_data = $data = array(); // if(is_array($vs) && count($vs)>0){ // foreach($vs as $val){ // //720p 和1080p 的视频地址暂时无法获得。 // $data['seconds'] = $val['duration']; // foreach ($val['fs'] as $v){ // $this_link = $v['l']; // if($val['bid'] == 4 || $val['bid'] == 5 || $val['bid'] == 10){ // $this_link = Iqiyi::getVrsEncodeCode($this_link); // } // $sp = explode('/',$this_link); // $sp_length = count($sp); // $arr = explode('.',$sp[$sp_length-1]); // $fileId = $arr[0]; // $this_key = Iqiyi::calmd($server_time,$fileId); // $this_link = $this_link.'?ran='.self::$deadpara.'&qyid=08ca8cb480c0384cb5d3db068161f44f&qypid='.$tvid.'_11&retry=1'; // $final_url = "http://data.video.qiyi.com/".$this_key."/videos".$this_link; // if($val['bid'] == 96)$urls_data['fluent'][] = $final_url; // if($val['bid'] == 1)$urls_data['normal'][] = $final_url; // if($val['bid'] == 2)$urls_data['high'][] = $final_url; // if($val['bid'] == 3)$urls_data['super'][] = $final_url; // if($val['bid'] == 4)$urls_data['SUPER_HIGH'][] = $final_url; // if($val['bid'] == 5)$urls_data['FULL_HD'][] = $final_url; // if($val['bid'] == 10)$urls_data['FOUR_K'][] = $final_url; // } // } // if(!empty($urls_data['fluent'])) $data['极速'] = self::getVideoUrl($urls_data['fluent']); // if(!empty($urls_data['normal'])) $data['流畅'] = self::getVideoUrl($urls_data['normal']); // if(!empty($urls_data['high'])) $data['高清'] = self::getVideoUrl($urls_data['high']); // if(!empty($urls_data['super'])) $data['超清'] = self::getVideoUrl($urls_data['super']); // if(!empty($urls_data['SUPER_HIGH'])) $data['720P'] = self::getVideoUrl($urls_data['SUPER_HIGH']); // if(!empty($urls_data['FULL_HD'])) $data['1080P'] = self::getVideoUrl($urls_data['FULL_HD']); // if(!empty($urls_data['FOUR_K'])) $data['4K'] = self::getVideoUrl($urls_data['FOUR_K']); // return $data; // }else{ // return false; // } }
/** * [get_proxy 获取国内的代理ip和端口] * @return [type] [description] */ private static function get_proxy() { //http://cn-proxy.com/ 国内代理 $url = "http://cn-proxy.com/feed"; $html = Base::_cget($url, '', false); preg_match_all('#<td>([^<]+)</td>[\\r\\n]+<td>80</td>[\\r\\n]+<td>高度匿名</td>#ms', $html, $proxys); $rand = mt_rand(0, count($proxys[1]) - 1); //随机返回一个ip return $proxys[1][$rand] . ":80"; }
/** * [parseFlv2 解析网站flv格式的视频,第二种方法] * @param [type] $tvid [description] * @param [type] $vid [description] * @return [type] [description] */ private static function parseFlv2($tvid, $vid) { //爱奇艺 flv api http://cache.video.qiyi.com/vp/视频tvid/视频vid/ 可以获得视频的信息 // http://cache.video.qiyi.com/vi/视频tvid/视频vid/ // http://cache.video.qiyi.com/vd/视频tvid/视频vid/ //获得视频的key值和ip 方法:将视频格式flv 替换为mp4 参照 html5版获取视频地址 $api_url = "http://cache.video.qiyi.com/vp/{$tvid}/{$vid}/"; $video_datas = json_decode(Base::_cget($api_url), true); $vs = $video_datas['tkl'][0]['vs']; $timestamp = time(); $k = $timestamp ^ 1718192030; // k的值要进行位运算 $urls_data = $data = array(); if (is_array($vs) && count($vs) > 0) { foreach ($vs as $val) { //720p 和1080p 的视频地址暂时无法获得。 foreach ($val['fs'] as $v) { if ($val['bid'] == 96) { $urls_data['fluent'][] = "http://data.video.qiyi.com/videos" . str_replace('.f4v', '.mp4', $v['l']) . "?v=" . $k; } if ($val['bid'] == 1) { $urls_data['normal'][] = "http://data.video.qiyi.com/videos" . str_replace('.f4v', '.mp4', $v['l']) . "?v=" . $k; } if ($val['bid'] == 2) { $urls_data['high'][] = "http://data.video.qiyi.com/videos" . str_replace('.f4v', '.mp4', $v['l']) . "?v=" . $k; } if ($val['bid'] == 3) { $urls_data['super'][] = "http://data.video.qiyi.com/videos" . str_replace('.f4v', '.mp4', $v['l']) . "?v=" . $k; } } } if (!empty($urls_data['fluent'])) { $data['fluent'] = self::getVideoUrl($urls_data['fluent']); } if (!empty($urls_data['normal'])) { $data['normal'] = self::getVideoUrl($urls_data['normal']); } if (!empty($urls_data['high'])) { $data['high'] = self::getVideoUrl($urls_data['high']); } if (!empty($urls_data['super'])) { $data['super'] = self::getVideoUrl($urls_data['super']); } return $data; } else { return false; } }
public static function parse($url) { $html = Base::_cget($url); preg_match("#vcode:\\s*'([=\\w]+)'\\s*#ix", $html, $vcode); if (!empty($vcode) && !empty($vcode[1])) { //判断视频是不是来自 优酷 return Youku::_getYouku(trim($vcode[1])); } /* 土豆改版 此方法失效 2013.10.17 $api_url = "http://v2.tudou.com/v.action?ui=0&hd=100&sid={$areaCode}&vn=02&refurl=".urlencode($url)."&it=".$iid."&si=11000&pw=&st=1%2C2%2C3%2C5%2C99"; */ //现在根据土豆视频页面上的 segs 里的参数可以拼接地址 id为 segs里的k 获得相应清晰度的视频地址 http://v2.tudou.com/f?id=176466865&sid=10000&hd=3&sj=1 $data = array(); $time = $areaCode = $title = ''; preg_match('#areaCode="(\\d+)"#', $html, $areaCodes); //获得地区id $areaCode = $areaCodes[1] ? substr($areaCodes[1], 0, -1) : 10000; preg_match("#segs:\\s*'([^']+)'#ms", $html, $segs); preg_match('#kw:\\s*"([^"]+)"#ms', $html, $kws); //获得标题 preg_match('#time:\\s*"([^"]+)"#ms', $html, $times); if (!empty($times[1]) && is_array($times)) { $times_array = explode(":", $times[1]); if (count($times_array) == 2) { $time = intval($times_array[0]) * 60 + intval($times_array[1]); } else { if (count($times_array) == 3) { $time = intval($times_array[0]) * 60 * 60 + intval($times_array[1]) * 60 + intval($times_array[2]); } else { $time = intval($times[1]); } } } $title = !empty($kws[1]) ? $kws[1] : ''; if (!empty($segs[1])) { $segs_json = json_decode($segs[1], true); foreach ($segs_json as $key => $val) { foreach ($val as $k => $v) { $api_url = "http://v2.tudou.com/f?id=" . $v['k'] . "&sid={$areaCode}&hd={$k}&sj=1"; $v_xml = Base::_cget($api_url); if (empty($v_xml)) { return false; } $s_xml = @simplexml_load_string($v_xml); if ($key == 2) { $data['normal'][] = strval($s_xml); } if ($key == 3) { $data['high'][] = strval($s_xml); } if ($key == 5) { $data['super'][] = strval($s_xml); } if ($key == 99) { $data['original'][] = strval($s_xml); } } } $data['title'] = $title; //土豆网已经变为utf-8编码了无需转码 $data['seconds'] = $time; return $data; } else { return false; } }