Joy.class.php
1.81 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
<?php
class Util_Video_Api_Joy extends Util_Video_Api
{
private $xmlurl = 'http://msx.app.joy.cn/service.php?action=msxv6&showad=true&videoid={id}&playertype=joyplayer&nocache={rand}';
private $imgurl = 'http://file1.megajoy.com/{id}_001.jpg';
/**
* @param unknown_type $url
*/
public function getData($url)
{
$id = $this->getid($url);
$infourl = str_ireplace("{id}", $id, $this->xmlurl);
$infourl = str_ireplace("{rand}", rand(1000, 20000), $infourl);
$infodat = Util_Video_ApiConnect::get($infourl);
if(!function_exists("simplexml_load_file"))
{
throw new Util_Video_ApiException('simplexml_load_file 不存在');
}
$infodat = @simplexml_load_string($infodat);
if($infodat == null)
{
throw new Util_Video_ApiException('数据解析失败');
}
$dataobj = new Util_Video_Data($this->id);
$flvurl = (string) $infodat->entry->item->Url;
$flvdate = substr($flvurl, 2, 10);
$flvID = str_replace('.flv', '', substr(strrchr($flvurl, '/'), 1));
$imgID = $flvdate . '/0' . substr(strrev($flvID), 0, 1) . '/' . $flvID;
$dataobj->swf = $infodat->entry->item->HostPath[0] . (string) $infodat->entry->item->Url;
$dataobj->thumb = ''; //str_ireplace("{id}",$imgID,$this->imgurl);暂时
$dataobj->time = '';
$dataobj->title = (string) $infodat->entry->item->Title;
$dataobj->source = '来自于joy.cn';
return $dataobj;
}
private function getid($url)
{
$url = $this->getUrl($url);
if(!preg_match("/^http:\/\/.*/si", $url))
{
$id = $url;
}
$id = str_replace(strrchr($url, '.'), '', substr(strrchr($url, '/'), 1));
$this->id = $id;
return $id;
}
}
?>