56.class.php
1.57 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
<?php
/**
* 请求:http://6.cn/watch/13685903.html
*
*/
class Util_Video_Api_56 extends Util_Video_Api
{
private $jsonurl = 'http://vxml.56.com/json/{id}/?src=out';
private $htmlurl = 'http://www.56.com/u74/v_{id}.html';
private $swfurl = 'http://player.56.com/v_{id}.swf';
/**
* @param unknown_type $url
* @return VideoApi_Data
*/
public function getData($url)
{
$idandswf = $this->getid($url);
$jsonurl = str_ireplace("{id}", $this->id, $this->jsonurl);
$dat = Util_Video_ApiConnect::get($jsonurl);
$jsonobj = json_decode($dat);
if(!$jsonobj->status)
{
throw new Util_Video_ApiException('56.cn返回失败');
}
$dataobj = new Util_Video_Data($this->id);
$dataobj->swf = $idandswf['swf'];
$dataobj->thumb = $jsonobj->info->img;
$dataobj->time = $jsonobj->info->duration;
$dataobj->title = $jsonobj->info->Subject;
$dataobj->user = $jsonobj->info->user_id;
$dataobj->source = '来自于56.com';
return $dataobj;
}
private function getid($url)
{
$url = $this->getUrl($url);
if(preg_match("/^http:\/\/.*/si", $url))
{
$id = preg_replace("/\..*$/si", "", preg_replace("/^.*\/v_/si", "", $url));
}
if(empty($id))
{
exit();
}
$swf = str_ireplace("{id}", $id, $this->swfurl);
$this->id = $id;
return array(
"swf" => $swf,
"id" => $id
);
}
}
?>