Iqiyi::parseFlv PHP Method

parseFlv() private static method

parseFlv 解析网站f4v格式的视频
private static parseFlv ( $tvid, $vid, $type, $proxy = '' )
    private static function parseFlv($tvid, $vid, $type, $proxy = '')
    {
        $key = static::mixKey($tvid);
        $api_url = "http://cache.video.qiyi.com/vms?key=fvip&src=1702633101b340d8917a69cf8a4b8c7c";
        $api_url .= "&tvId=" . $tvid . "&vid=" . $vid . "&vinfo=1&tm=" . $key['tm'] . "&enc=" . $key['enc'] . "&um=1";
        #echo $api_url;
        $video_datas = json_decode(static::_cget($api_url), true);
        if ($video_datas['code'] == 'A000001') {
            return false;
        }
        if (isset($video_datas['data']['vp']['tkl'][0]['vs'])) {
            $vs = $video_datas['data']['vp']['tkl'][0]['vs'];
            //.data.vp.tkl[0].vs
        } else {
            return 404;
        }
        $time_url = "http://data.video.qiyi.com/t";
        $time_datas = json_decode(static::_cget($time_url), true);
        $server_time = $time_datas['t'];
        //视频信息
        $data['title'] = $video_datas['data']['vi']['vn'];
        $data['seconds'] = $vs[0]['duration'];
        $vs[0]['type'] = $type;
        //划分视频尺寸 1080p 的视频地址暂时无法获得
        foreach ($vs as $val) {
            foreach ($val['fs'] as $v) {
                $type = $vs[0]['type'];
                $this_link = $v['l'];
                if ($val['bid'] == 4 || $val['bid'] == 5 || $val['bid'] == 10) {
                    $this_link = static::getVrsEncodeCode($this_link);
                }
                $sp = explode('/', $this_link);
                $files = explode('.', $sp[count($sp) - 1]);
                $fileId = $files[0];
                $this_key = static::calmd($server_time, $fileId);
                $final_url = "http://data.video.qiyi.com/" . $this_key . "/videos" . $this_link;
                if ($val['bid'] == 96 && ($type == 'all' || $type == 'fluent')) {
                    $urls_data['fluent'][] = $final_url;
                }
                if ($val['bid'] == 1 && ($type == 'all' || $type == 'normal')) {
                    $urls_data['normal'][] = $final_url;
                }
                if ($val['bid'] == 2 && ($type == 'all' || $type == 'high')) {
                    $urls_data['high'][] = $final_url;
                }
                if ($val['bid'] == 4 && ($type == 'all' || $type == 'super')) {
                    $urls_data['SUPER_HIGH'][] = $final_url;
                }
                if ($val['bid'] == 5 && ($type == 'all' || $type == 'hd')) {
                    $urls_data['FULL_HD'][] = $final_url;
                }
                if ($val['bid'] == 10 && $type == 'all') {
                    $urls_data['FOUR_K'][] = $final_url;
                }
            }
        }
        if (!empty($urls_data['fluent'])) {
            $data['极速'] = self::getVideoUrl($urls_data['fluent'], $proxy);
        }
        if (!empty($urls_data['normal'])) {
            $data['流畅'] = self::getVideoUrl($urls_data['normal'], $proxy);
        }
        if (!empty($urls_data['high'])) {
            $data['高清'] = self::getVideoUrl($urls_data['high'], $proxy);
        }
        if (!empty($urls_data['SUPER_HIGH'])) {
            $data['720P'] = self::getVideoUrl($urls_data['SUPER_HIGH'], $proxy);
        }
        if (!empty($urls_data['FULL_HD'])) {
            $data['1080P'] = self::getVideoUrl($urls_data['FULL_HD'], $proxy);
        }
        if (!empty($urls_data['FOUR_K'])) {
            $data['4K'] = self::getVideoUrl($urls_data['FOUR_K'], $proxy);
        }
        return $data;
    }