d+)#i’, array($this, ‘smartideo_embed_handler_xiami’) ); } # video public function smartideo_embed_handler_youku( $matches, $attr, $url, $rawattr ) { $embed = $this->get_iframe(“//player.youku.com/embed/{$matches[‘video_id’]}?client_id={$this->youku_client_id}”, $url); return apply_filters( ’embed_youku’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_qq( $matches, $attr, $url, $rawattr ) { $matches[‘video_id’] = $matches[‘video_id1’] == ” ? $matches[‘video_id2’] : $matches[‘video_id1’]; $embed = $this->get_iframe(“//v.qq.com/iframe/player.html?vid={$matches[‘video_id’]}&auto=0”, $url); return apply_filters( ’embed_qq’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_sohu( $matches, $attr, $url, $rawattr ) { $embed = $this->get_iframe(“//tv.sohu.com/upload/static/share/share_play.html#{$matches[‘video_id’]}_0_0_9001_0”, $url); return apply_filters( ’embed_sohu’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_wasu( $matches, $attr, $url, $rawattr ) { $embed = $this->get_iframe(“http://www.wasu.cn/Play/iframe/id/{$matches[‘video_id’]}”, $url); return apply_filters( ’embed_wasu’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_youtube( $matches, $attr, $url, $rawattr ) { $embed = $this->get_iframe(“//www.youtube.com/embed/{$matches[‘video_id’]}”, $url); return apply_filters( ’embed_youtube’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_bilibili( $matches, $attr, $url, $rawattr ) { $matches[‘video_id’] = ($matches[‘video_id1’] == ”) ? $matches[‘video_id’] : $matches[‘video_id1’]; $page = ($matches[‘video_id2’] > 1) ? $matches[‘video_id2’] : 1; $cid = ”; /* try{ $request = new WP_Http(); $url = “https://api.bilibili.com/view?type=jsonp&appkey=8e9fc618fbd41e28&id=” . $matches[‘video_id’]; $data = (array)$request->request($url, array(‘timeout’ => 3)); $json = json_decode($data[‘body’], true); $cid = $json[‘cid’]; }catch(Exception $e){} */ if(wp_is_mobile() || $this->bilibili_pc_player == 1){ $embed = $this->get_iframe(“//player.bilibili.com/player.html?aid={$matches[‘video_id’]}&cid={$cid}&page={$page}”, $url); }else{ $embed = $this->get_link($url); } return apply_filters( ’embed_bilibili’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_meipai( $matches, $attr, $url, $rawattr ) { $embed = $this->get_link($url); return apply_filters( ’embed_meipai’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_miaopai( $matches, $attr, $url, $rawattr ) { if(wp_is_mobile()){ $embed = $this->get_iframe(“//gslb.miaopai.com/stream/{$matches[‘video_id’]}.mp4”, $url); }else{ $embed = $this->get_embed(“//wscdn.miaopai.com/splayer2.2.0.swf?scid={$matches[‘video_id’]}&token=&autopause=true”, $url); } return apply_filters( ’embed_miaopai’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_iqiyi( $matches, $attr, $url, $rawattr ) { $embed = ”; try{ $request = new WP_Http(); $data = (array)$request->request($url, array(‘timeout’ => 3)); if(!isset($data[‘body’])){ $data[‘data’] = ”; } preg_match(‘/”vid”:”(w+)”/i’, (string)$data[‘body’], $match); $vid = $match[1]; preg_match(‘/”tvId”:(d+)/i’, (string)$data[‘body’], $match); $tvid = $match[1]; if ($tvid > 0 && !empty($vid)) { $embed = $this->get_iframe(“//open.iqiyi.com/developer/player_js/coopPlayerIndex.html?vid={$vid}&tvId={$tvid}&height=100%&width=100%&autoplay=0″, $url); } }catch(Exception $e){} if(empty($embed)){ $embed = ‘解析失败,请刷新页面重试’; } return apply_filters( ’embed_iqiyi’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_56( $matches, $attr, $url, $rawattr ) { $matches[‘video_id’] = $matches[‘video_id1’] == ” ? $matches[‘video_id2’] : $matches[‘video_id1’]; $embed = $this->get_iframe(“http://www.56.com/iframe/{$matches[‘video_id’]}”, $url); return apply_filters( ’embed_56′, $embed, $matches, $attr, $url, $rawattr ); } # video widthout h5 public function smartideo_embed_handler_weibo( $matches, $attr, $url, $rawattr ) { $embed = $this->get_embed(“http://video.weibo.com/player/1034:{$matches[‘video_id’]}/v.swf”, $url); if(wp_is_mobile()){ $embed = $this->get_link($url); } return apply_filters( ’embed_weibo’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_yinyuetai( $matches, $attr, $url, $rawattr ){ $embed = $this->get_embed(“http://player.yinyuetai.com/video/player/{$matches[‘video_id’]}/v_0.swf”, $url); if(wp_is_mobile()){ $embed = $this->get_link($url); } return apply_filters( ’embed_yinyuetai’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_ku6( $matches, $attr, $url, $rawattr ){ $embed = $this->get_embed(“http://player.ku6.com/refer/{$matches[‘video_id’]}/v.swf”, $url); if(wp_is_mobile()){ $embed = $this->get_link($url); } return apply_filters( ’embed_ku6′, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_letv($matches, $attr, $url, $rawattr){ $embed = $this->get_embed(“http://img1.c0.letv.com/ptv/player/swfPlayer.swf?id={$matches[‘video_id’]}&autoplay=0”, $url); if(wp_is_mobile()){ $embed = $this->get_link($url); } return apply_filters( ’embed_letv’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_hunantv( $matches, $attr, $url, $rawattr ) { $embed = $this->get_embed(“//i1.hunantv.com/ui/swf/share/player.swf?video_id={$matches[‘video_id’]}&autoplay=0”, $url); if(wp_is_mobile()){ $embed = $this->get_link($url); } return apply_filters( ’embed_hunantv’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_acfun( $matches, $attr, $url, $rawattr ) { $embed = $this->get_embed(“http://cdn.aixifan.com/player/ACFlashPlayer.out.swf?type=page&url=http://www.acfun.cn/v/ac{$matches[‘video_id’]}”, $url); if(wp_is_mobile()){ $embed = $this->get_link($url); } return apply_filters( ’embed_acfun’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_tudou( $matches, $attr, $url, $rawattr ) { $embed = $this->get_link($url); return apply_filters( ’embed_tudou’, $embed, $matches, $attr, $url, $rawattr ); } # music public function smartideo_embed_handler_music163( $matches, $attr, $url, $rawattr ) { $embed = $this->get_iframe(“//music.163.com/outchain/player?type=2&id={$matches[‘video_id’]}&auto=0&height=90″, ”, ‘100%’, ‘110px’); return apply_filters( ’embed_music163′, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_musicqq( $matches, $attr, $url, $rawattr ) { $embed = $this->get_iframe(“//cc.stream.qqmusic.qq.com/C100{$matches[‘video_id’]}.m4a?fromtag=52″, ”, ‘100%’, ‘110px’); return apply_filters( ’embed_musicqq’, $embed, $matches, $attr, $url, $rawattr ); } public function smartideo_embed_handler_xiami( $matches, $attr, $url, $rawattr ) { $embed = ‘
‘; return apply_filters( ’embed_xiami’, $embed, $matches, $attr, $url, $rawattr ); } private function get_embed($url = ”, $source = ”, $width = ”, $height = ”){ $html = ”; $html .= ‘
get_size_style($width, $height) . ‘>
‘; if($this->option[‘tips_status’] == 1 && !$this->edit){ if(empty($source)){ $source = ‘javascript:void(0);’; } $html .= ‘
‘; } $html .= ‘
‘; return $html; } private function get_iframe($url = ”, $source = ”, $width = ”, $height = ”){ $html = ”; $html .= ‘
get_size_style($width, $height) . ‘>
‘; if(isset($this->option[‘tips_status’]) && $this->option[‘tips_status’] == 1 && !$this->edit){ if(empty($source)){ $source = ‘javascript:void(0);’; } $html .= ‘
‘; } $html .= ‘
‘; return $html; } private function get_link($url){ $html = ”; $html .= ‘
get_size_style(0, 0) . ‘>
暂时无法播放,可回源网站播放
‘; return $html; } public function smartideo_scripts(){ wp_enqueue_style(‘smartideo_css’, SMARTIDEO_URL . ‘/static/smartideo.css’, array(), SMARTIDEO_VERSION, ‘screen’); wp_enqueue_script(‘smartideo_js’, SMARTIDEO_URL . ‘/static/smartideo.js’, array(), SMARTIDEO_VERSION, true); } public function admin_menu(){ add_plugins_page(‘Smartideo 设置’, ‘Smartideo 设置’, ‘manage_options’, ‘smartideo_settings’, array($this, ‘admin_settings’)); } public function admin_settings(){ require_once ‘smartideo-admin.php’; new smartideo_admin(); } private function is_https(){ if(strtolower($_SERVER[‘HTTPS’]) == ‘on’){ return true; }else{ return false; } } private function get_size_style($width, $height){ if(empty($width) || empty($height)){ $width = $height = 0; if($this->edit){ $width = $this->width; $height = $this->height; }else if($this->option[‘response’] == 0){ if(wp_is_mobile()){ $width = $this->option[‘width_mobile’]; $height = $this->option[‘height_mobile’]; }else{ $width = $this->option[‘width’]; $height = $this->option[‘height’]; } } } $style = ”; if(!empty($width)){ $style .= “width: {$width};”; } if(!empty($height)){ $style .= “height: {$height};”; } if(!empty($style)){ $style = ‘ style=”‘ . $style . ‘”‘; } return $style; } }