Boosj.class.php 1.34 KB
<?php
/*
 * 靖求: http://www.boosj.com/1715323.html
 * */
class Util_Video_Api_Boosj extends Util_Video_Api
{
    private $xmlurl = 'http://xml.boosj.com/{id}.xml';
    /**
     * @param unknown_type $url
     */
    public function getData($url)
    {
        $id = $this->getid($url);
        $infourl = str_ireplace("{id}", $id, $this->xmlurl);
        $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);
        $dataobj->swf = (string) $infodat->video->fileUrl->file;
        $dataobj->thumb = (string) $infodat->video->pic;
        $dataobj->time = "";
        $dataobj->title = (string) $infodat->video->title;
        $dataobj->source = '来自于boosj.com';
        return $dataobj;
    }
    private function getid($url)
    {
        $url = $this->getUrl($url);
        if(!preg_match("/^http:\/\/.*/si", $url))
        {
            $id = $url;
        }
        $id = str_replace('.html', '', substr(strrchr($url, '/'), 1));
        $this->id = $id;
        return $id;
    }

}


?>