Pptv.class.php 1.14 KB
<?php
class Util_Video_Api_Pptv extends Util_Video_Api
{
    private $swfurl = 'http://player.pptv.com/v/{id}.swf';
    private $htmlurl = 'http://v.pptv.com/show/{id}.html';
    /**
     * @param unknown_type $url
     */
    public function getData($url)
    {
        $id = $this->getid($url);
        $infourl = str_ireplace("{id}", $id, $this->htmlurl);
        $infodat = Util_Video_ApiConnect::get($infourl);
        if(preg_match_all('/<strong><a .*>(.*)<\/a><\/strong>/', $infodat, $out, 2))
        {
            $title = $out[0][1];
        }
        if(!empty($title))
        {
            $dataobj = new Util_Video_Data($this->id);
            $dataobj->swf = str_ireplace("{id}", $id, $this->swfurl);
            $dataobj->title = $title;
            $dataobj->source = '来自于pptv.com';
            return $dataobj;
        }
        else
        {
            throw new Util_Video_ApiException('没有数据');
        }
    }
    
    private function getid($url)
    {
        $url = $this->getUrl($url);
        $id = str_replace(strrchr($url, '.'), '', substr(strrchr($url, '/'), 1));
        $this->id = $id;
        return $id;
    }

}

?>