Yinyuetai.class.php 1.25 KB
<?php
class Util_Video_Api_Yinyuetai extends Util_Video_Api
{
    private $htmlurl = "http://www.yinyuetai.com/video/{id}";
    private $swfurl = 'http://www.yinyuetai.com/video/player/{id}/v_0.swf';
    
    /**
     * @param unknown_type unknown_type $url
     */
    public function getData($url)
    {
        $id = $this->getid($url);
        $htmlurl = str_ireplace("{id}", $id, $this->htmlurl);
        $htmldat = Util_Video_ApiConnect::get($htmlurl);
        if(preg_match_all("@<h1 id=\"videoTitle\">(.*)<\/h1>@isU", $htmldat, $out, 2))
        {
            $title = $out[0][1];
        }
        if(empty($title))
        {
            throw new Util_Video_ApiException("没有标题");
        }
        $dataobj = new Util_Video_Data($this->id);
        $dataobj->swf = str_ireplace("{id}", $id, $this->swfurl);
        $dataobj->thumb = "";
        $dataobj->time = "";
        $dataobj->title = $title;
        $dataobj->source = '来自于yinyuetai.com';
        return $dataobj;
    }
    
    private function getid($url)
    {
        $url = $this->getUrl($url);
        if(!preg_match("/^http:\/\/.*/si", $url))
        {
            $id = $url;
        }
        $id = substr(strrchr($url, '/'), 1);
        $this->id = $id;
        return $id;
    }

}

?>