Smgbb.class.php
3.68 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
<?php
class Util_Video_Api_Smgbb extends Util_Video_Api
{
private $wulinxmlurl = 'http://www.kankanews.com/dataservice/InitPlayer.php';
private $wulinswfurl = 'http://www.kankanews.com/object/kankanewsplayer3.0.swf?autoPlay=true&width=600&height=490&streamType=recorded&
cid={CategoryId}&vid={ContentId}&server=http://www.kankanews.com/dataservice/';
private $infoswfurl = 'http://www.smgbb.cn/playxml/nplayer.swf?pid={id}';
private $infoxmlurl = 'http://www1.smgbb.cn/playxml/statdir/{id_2}/playlist{id}.xml';
public function getData($url)
{
$id = $this->getid($url);
if(is_array($id))
{
$params = 'parameter=' . json_encode($id) . '&method=InitPlayer';
$infodat = Util_Video_ApiConnect::get($this->wulinxmlurl, array(CURLOPT_POSTFIELDS => $params));
$infodat = str_replace("<div id=\"main\">\"", '', $infodat);
$infodat = str_replace("\"</div>", '', $infodat);
$infodat = str_replace("\\/", '/', $infodat);
$infodat = '<?xml version="1.0" encoding="utf-8"?>' . $infodat;
$infodat = @simplexml_load_string($infodat);
if($infodat == null)
{
throw new Util_Video_ApiException('simplexml_load_file 不存在');
}
$dataobj = new Util_Video_Data($this->id);
$swfurl = str_ireplace("{CategoryId}", $id['CategoryId'], $this->wulinswfurl);
$dataobj->swf = str_ireplace("{ContentId}", $id['ContentId'], $swfurl);
$dataobj->thumb = (string) $infodat->currentvod->imgurl;
$dataobj->time = "";
$title = preg_replace("#\\\u([0-9a-f]{4})#ie", "iconv('UCS-2', 'UTF-8//IGNORE', pack('H4', '\\1'))", (string) $infodat->currentvod->name);
$dataobj->title = $title;
}
else
{
$infurl = str_ireplace("{id}", $id, $this->infoxmlurl);
$infurl = str_ireplace("{id_2}", intval(substr($id, strlen($id) - 2, 2)), $infurl);
$infodat = Util_Video_ApiConnect::get($infurl);
$infodat = @simplexml_load_string($infodat);
if($infodat == null)
{
throw new Util_Video_ApiException('数据解析失败');
}
$dataobj = new Util_Video_Data($this->id);
$dataobj->swf = str_ireplace("{id}", $id, $this->infoswfurl);
$dataobj->thumb = (string) $infodat->playing['image'];
$dataobj->time = "";
$dataobj->title = (string) $infodat->playing['title'];
}
$dataobj->source = '来自于smgbb.cn';
return $dataobj;
}
private function getid($url)
{
$url = $this->getUrl($url);
if(preg_match("@^http:\/\/.*.smgbb.cn@is", $url))
{
if(preg_match("@^http:\/\/info.smgbb.cn@is", $url))
{
$id = str_replace(strrchr($url, '.'), '', substr(strrchr($url, '/'), 1));
$this->id = $id;
return $id;
}
else
{
$htmldat = Util_Video_ApiConnect::get($url);
if(preg_match_all("/&cid=(.*)&/isU", $htmldat, $out, 2))
{
$CategoryId = $out[0][1];
}
if(preg_match_all("/&vid=(.*)&/isU", $htmldat, $out, 2))
{
$ContentId = $out[0][1];
}
$this->id = $CategoryId;
return array(
'CategoryId' => $CategoryId,
'ContentId' => $ContentId
);
}
}
else
{
throw new Util_Video_ApiException('数据解析失败');
}
}
}
?>