Pptv.class.php
1.14 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
<?php
class Util_Video_Api_Pptv extends Util_Video_Api
{
private $swfurl = 'http://player.pptv.com/v/{id}.swf';
private $htmlurl = 'http://v.pptv.com/show/{id}.html';
/**
* @param unknown_type $url
*/
public function getData($url)
{
$id = $this->getid($url);
$infourl = str_ireplace("{id}", $id, $this->htmlurl);
$infodat = Util_Video_ApiConnect::get($infourl);
if(preg_match_all('/<strong><a .*>(.*)<\/a><\/strong>/', $infodat, $out, 2))
{
$title = $out[0][1];
}
if(!empty($title))
{
$dataobj = new Util_Video_Data($this->id);
$dataobj->swf = str_ireplace("{id}", $id, $this->swfurl);
$dataobj->title = $title;
$dataobj->source = '来自于pptv.com';
return $dataobj;
}
else
{
throw new Util_Video_ApiException('没有数据');
}
}
private function getid($url)
{
$url = $this->getUrl($url);
$id = str_replace(strrchr($url, '.'), '', substr(strrchr($url, '/'), 1));
$this->id = $id;
return $id;
}
}
?>