Letv.class.php
1.78 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
<?php
class Util_Video_Api_Letv extends Util_Video_Api
{
private $htmlurl = 'http://www.letv.com/ptv/{link}.html';
private $jsonurl = 'http://app.letv.com/ajax/getFocusVideo.php?pid={pid}&p=2&top=0&max=1';
private $swfurl = 'http://img1.c0.letv.com/ptv/player/swfPlayer.swf?id={vid}&host=app.letv.com&vstatus=4&AP=1&logoMask=0&isShowP2p=0&autoplay=true';
public function getData($url)
{
$id = $this->getid($url);
$infourl = str_ireplace("{pid}", $id['pid'], $this->jsonurl);
$infodat = Util_Video_ApiConnect::get($infourl);
$infodat = str_replace("([", '', $infodat);
$infodat = str_replace("])", '', $infodat);
$infodat = json_decode($infodat);
if($infodat == null)
{
throw new Util_Video_ApiException('数据解析失败');
}
$dataobj = new Util_Video_Data($id['pid']);
$dataobj->swf = str_ireplace("{vid}", $id['vid'], $this->swfurl);
;
$dataobj->thumb = $infodat->pic;
$dataobj->time = "";
$dataobj->title = $infodat->title;
$dataobj->source = '来自于letv.com';
return $dataobj;
}
private function getid($url)
{
$url = $this->getUrl($url);
$link = str_replace("http://www.letv.com/ptv/", "", $url);
$link = str_replace(strrchr($url, '.'), '', $link);
$htmlurl = str_ireplace("{link}", $link, $this->htmlurl);
$htmldat = Util_Video_ApiConnect::get($htmlurl);
if(preg_match_all("/vid:(.*),/siU", $htmldat, $out, 2))
{
$vid = $out[0][1];
}
if(preg_match_all("/pid:(.*),/siU", $htmldat, $out, 2))
{
$pid = $out[0][1];
}
return array(
'vid' => $vid,
'pid' => $pid
);
}
}
?>