Xunlei.class.php
2.24 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
<?php
class Util_Video_Api_Xunlei extends Util_Video_Api
{
private $swfurl = 'http://video.xunlei.com/dt/swf/v.swf?fullscreenbtn=1&id={id}&channel=newauto&url={flvurl}&width=440&height=357';
private $imgurl = 'http://images.video.xunlei.com/section/{imgID}.jpg';
public function getData($url)
{
$id = $this->getid($url);
$infodat = Util_Video_ApiConnect::get($url);
if(preg_match_all("/var G_PLAY_URL='(.*)';/isU", $infodat, $out, 2))
{
$flvurl = $out[0][1];
}
if(empty($flvurl))
{
throw new Util_Video_ApiException("没有flvurl");
}
if(preg_match_all("/var G_TITLE='(.*)';/isU", $infodat, $out, 2))
{
$title = $out[0][1];
}
if(empty($title))
{
throw new Util_Video_ApiException("没有标题");
}
$imgID = str_replace('_1.flv', '', substr(strrchr($flvurl, '/'), 1));
$imgIDPath = substr($imgID, 0, 2) . '/' . substr($imgID, strlen($imgID) - 2, 2) . '/' . $imgID;
$imgpath = str_ireplace('{imgID}', $imgIDPath . '_0', $this->imgurl);
$dataobj = new Util_Video_Data($this->id);
$imgdat = Util_Video_ApiConnect::get($imgpath);
if(strlen($imgdat) > 500)
{
$dataobj->thumb = $imgpath;
}
else
{
$imgpath = str_ireplace('{imgID}', $imgIDPath . '_30', $this->imgurl);
$imgdat = Util_Video_ApiConnect::get($imgpath);
if(strlen($imgdat) > 500)
{
$dataobj->thumb = $imgpath;
}
else
{
$dataobj->thumb = '';
}
}
$dataobj->time = '';
$dataobj->title = $title;
$swfpath = str_ireplace("{id}", $this->id, $this->swfurl);
$dataobj->swf = str_ireplace("{flvurl}", $flvurl, $swfpath);
$dataobj->source = '来自于xunlei.com';
return $dataobj;
}
private function getid($url)
{
$url = $this->getUrl($url);
if(!preg_match("/^http:\/\/.*/si", $url))
{
$id = $url;
}
$this->id = $id = str_replace(strrchr($url, '.'), '', substr(strrchr($url, '/'), 1));
return $id;
}
}
?>