Ku6.class.php
3.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
class Util_Video_Api_Ku6 extends Util_Video_Api
{
private $jsonurl = "http://vo.ku6.com/fetchVideo4Player/1/{id}.html";
private $jsonurl_2 = "http://vo.ku6.com/fetchVideo4Player/{id}.html";
private $htmlurl = "http://v.ku6.com/show/{id}.html";
//酷六网
const KU6_VIDEO_PID = 'D13aSslTjemFkeajqwSXqB5IAvOWh5uZ9fIrCjZ7zQ9AVm3-YPi7mLxrcgbOk21mkhSQlw..';
private static $ku6_video_api = 'http://v.ku6.com/openapi/repaste.htm?t=fetchVideoInfo&pid=%s&id=%s'; //酷六网视频接口
public function getData($url)
{
$idandswf = $this->getid_2($url);
$api_url = sprintf ( self::$ku6_video_api, self::KU6_VIDEO_PID, $this->id );
$result = Util_Video_ApiConnect::get($api_url);
$vinfo = ( array ) simplexml_load_string ( $result, 'SimpleXMLElement', LIBXML_NOCDATA );
if(!empty($vinfo))
{
$data = new Util_Video_Data($this->id);
$data->swf = (string) $vinfo['result']->playswf;
$data->title = (string) $vinfo['result']->title;
$data->thumb = (string) $vinfo['result']->picPath;
}
else
{
$data = $this->getViolentData($url);
}
return $data;
}
/**
* 暴力破解
*/
private function getViolentData($url)
{
if(preg_match("/^http:\/\/v\.ku6\.com\/show\/.*\.html$/siU", $url))
{
$idandswf = $this->getid($url);
$jsonurl = str_ireplace("{id}", $this->id, $this->jsonurl);
}
else if(preg_match("/http:\/\/v\.ku6\.com\/special\/show_.*\/.*\.html$/siU", $url))
{
$idandswf = $this->getid_2($url);
$jsonurl = str_ireplace("{id}", $this->id, $this->jsonurl_2);
}
else
{
return new Util_Video_ApiException('simplexml_load_file 不存在');
}
$dat = Util_Video_ApiConnect::get($jsonurl);
$jsonobj = json_decode($dat);
if(!$jsonobj->status)
{
throw new Util_Video_ApiException('数据解析失败');
}
$dataobj = new Util_Video_Data($this->id);
$dataobj->swf = $idandswf['swf'];
$dataobj->thumb = $jsonobj->data->bigpicpath;
$dataobj->time = $jsonobj->data->vtime;
$dataobj->title = $jsonobj->data->t;
$dataobj->source = '来自于ku6.com';
unset($dat);
return $dataobj;
}
private function getid($url)
{
$url = $this->getUrl($url);
if(!preg_match("/^http:\/\/.*/i", $url))
{
$url = str_ireplace("{id}", $url, $this->htmlurl);
}
$content = Util_Video_ApiConnect::get($url);
if(preg_match_all("/outSideSwfCode.*value=\"(.*)\"/siU", $content, $flashurl, 2))
{
$swf = $flashurl[0][1];
$urlid = preg_replace("/\/.*$/si", "", preg_replace("/^.*refer\//si", "", $swf));
}
else
{
throw new Util_Video_ApiException("数据解析失败");
}
$this->id = $urlid;
return array(
"swf" => $swf,
"id" => $urlid
);
}
private function getid_2($url)
{
$url = $this->getUrl($url);
$id = trim(str_replace(strrchr($url, '.'), '', substr(strrchr($url, '/'), 1)));
$swfurl = "http://player.ku6.com/refer/$id/v.swf";
$this->id = $id;
return array(
"swf" => $swfurl,
"id" => $id
);
}
}
?>