Xiyou.class.php
1.31 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
<?php
/**
* 请求:
* http://xiyou.cntv.cn/v-3e971408-b35f-11e0-b140-a4badb469111.html
*/
class Util_Video_Api_Xiyou extends Util_Video_Api
{
private $jsonurl = 'http://xiyou.cntv.cn/interface/index?videoId={id}';
public function getData($url)
{
$id = str_replace('v-', '', $this->getid($url));
$infourl = str_ireplace("{id}", $id, $this->jsonurl);
$infodat = Util_Video_ApiConnect::get($infourl);
$infodat = json_decode($infodat);
if($infodat->status != 'success')
{
throw new Util_Video_ApiException('数据解析失败');
}
$dataobj = new Util_Video_Data($this->id);
$flv = $infodat->data[0]->videoList[0]->videoFilePath;
$dataobj->swf = str_replace(strrchr($flv, '#'), '.flv', $flv);
$dataobj->thumb = $infodat->data[0]->imagePath;
$dataobj->time = $infodat->data[0]->uploadTime;
$dataobj->title = (string) $infodat->data[0]->title;
$dataobj->source = '来自于cntv.cn';
return $dataobj;
}
private function getid($url)
{
$url = $this->getUrl($url);
if(!preg_match("/^http:\/\/.*/si", $url))
{
$id = $url;
}
$id = str_replace('.html', '', substr(strrchr($url, '/'), 1));
$this->id = $id;
return $id;
}
}
?>