介绍
原先我是一直在用泽泽的一款Violet主题,在Violet中泽泽有做一个影视模板,所以我博客上部分文章都是基于这个影视模板,由于今天是刚上手handsome主题,handsome里暂未发现影视模板,没办法只能搬运Violet主题中的视频模板部分。由于我也就是简单的做一个适配,并没来得及对handsome做完全适配,OωO毕竟我现在也仅仅是临时用用,然后后期的话会对handsome主题中特有的tab功能做一个适配handsome主题的视频模板,大牛们也可以自己上手。
教程
首先我们在handsome主题下post.php,的文章内容上面加入以下代码
<!--调用影视模板-->
<?php if ($this->fields->mp4): ?><?php $this->need('video.php'); ?><?php endif; ?>
然后在handsome主题下创建一个video.php文件并写上以下代码
<?php if (!defined('__TYPECHO_ROOT_DIR__')) exit; ?>
<div class="container-fluid mt-4">
<div class="row">
<div class="col-md-12">
<div class="mb-4">
<?php if ($this->fields->mp4): ?>
<link class="dplayer-css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.css">
<!--<script src="https://cdn.jsdelivr.net/npm/flv.js/dist/flv.min.js"></script>-->
<script src="https://cdn.jsdelivr.net/npm/hls.js/dist/hls.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dplayer/dist/DPlayer.min.js"></script>
<div id="dplayer"></div>
<?php
//$geturl = $this->fields->iframe;$str1 = explode('aid=', $geturl);$str2 = explode('&cid=', $str1[1]);$av = $str2[0];
?>
<?php
$duoji="";
if($this->fields->duoji && strpos($this->fields->duoji,'$') !== false){
$hang = explode("\r\n", $this->fields->duoji);
$shu=count($hang);
for($i=0;$i<$shu;$i++){
$cid=explode("$",$hang[$i])[1];
$this->widget('Widget_Archive@duoji'.$cid, 'pageSize=1&type=post', 'cid='.$cid)->to($ji);
if($ji->cid==$this->cid){
$duoji=$duoji."<span class=\"btn btn-outline-danger btn-sm ml-1 border-0 disabled\">".explode("$",$hang[$i])[0]."</span>";
}else{
$duoji=$duoji."<a href=\"".$ji->permalink."\" class=\"btn btn-outline-danger btn-sm ml-1 border-0\">".explode("$",$hang[$i])[0]."</a>";
}
}
}
$spurl=$this->fields->mp4;
$x=0;
if(strpos($this->fields->mp4,'$') !== false){
$j=0;
if(isset($_GET['action'])){
if($_GET['action'] == 'get' && 'GET' == $_SERVER['REQUEST_METHOD'] ) {
$j=$_GET['p']-1;
}}
$txt=$this->fields->mp4;
$string_arr = explode("\r\n", $txt);
$long=count($string_arr);
$list="";
for($i=0;$i<$long;$i++){
if($j==$i){$c="class=\"btn btn-primary c\"";}else{$c="class=\"btn btn-outline-primary\"";}
$p=$i+1;
$list=$list."<a href=\"".$this->permalink."?action=get&p=".$p."\"".$c.">".explode("$",$string_arr[$i])[0]."</a>";
}
$list= '<div class="card d-block mb-3"> <div class="card-header"><span>剧集</span>'.$duoji.'</div>
<div class="card-body button-list">'.$list.'</div></div>';
$spurl=explode("$",$string_arr[$j])[1];
}
?>
<script>
const dp = new DPlayer({
container: document.getElementById('dplayer'),
screenshot: false,lang: 'zh-cn',
//autoplay: true,
video: {
url: '<?php echo $spurl; ?>',type: 'auto',
//pic: '',
//thumbnails: '',
},
});
</script>
<?php endif; ?>
</div>
<?php echo $list; ?>
然后这样子就行了,如何调用呢:
撰写新文章在自定义字段中,字段名mp4
字段值写集数$链接
如下:
第01集$https://sina.com-h-sina.com/20180802/5253_78a83b77/index.m3u8
第02集$https://sina.com-h-sina.com/20180802/5254_e22c0bb9/index.m3u8
第03集$https://sina.com-h-sina.com/20180802/5255_0bd23948/index.m3u8
第04集$https://sina.com-h-sina.com/20180802/5256_00f52865/index.m3u8
第05集$https://sina.com-h-sina.com/20180802/5257_d6359aa1/index.m3u8
第06集$https://sina.com-h-sina.com/20180802/5258_db42db52/index.m3u8
第07集$https://sina.com-h-sina.com/20180802/5259_4acf60cb/index.m3u8
第08集$https://sina.com-h-sina.com/20180802/5260_0b6a0c88/index.m3u8
第09集$https://sina.com-h-sina.com/20180802/5261_80a954a6/index.m3u8
第10集$https://sina.com-h-sina.com/20180802/5262_486042e0/index.m3u8
第11集$https://sina.com-h-sina.com/20180802/5263_cfb8afbc/index.m3u8
第12集$https://sina.com-h-sina.com/20180802/5264_05b73401/index.m3u8
第13集$https://sina.com-h-sina.com/20180802/5265_241f8a82/index.m3u8
第14集$https://sina.com-h-sina.com/20180802/5266_a723779d/index.m3u8
注:只能解析m3u8和mp4后缀的视频文件
然后如果是多季想要同时展示的话就先按照以上方法把各季的视频都发布
最后在写有各季的文章里添加字段名duoji
字段值填写季数$cid
如下:
第一季$3
第二季$4
永远的我的鸟笼$6
发条装置之哀女神$7
然后就可以啦,记住每一季文章都要添加duoji
字段哟
演示文章
影视资源可以在影视资源网中找到复制下来即可

推荐OK资源网地址:http://okzyw.com/ 如果链接失效了怎么办呢:
这个泽泽都为大家想好了,插件地址:https://qqdie.com/archives/tereplace-plugin-typecho.html
因为现在暂时是直接移植泽泽的代码所以完全适配插件的替换MP4字段内容 当然还是先备份一下数据库以防万一嘛!!!
最后由于是搬运泽泽的嘛,麻烦有使用的去支持一下泽泽,网址:https://qqdie.com/
|´・ω・)ノ我这边正常使用暂时没有什么问题,如果有bug,或还不会怎么用可以在下方评论告诉我。
这个泽泽都为大家想好了,插件地址:https://qqdie.com/archives/tereplace-plugin-typecho.html
因为现在暂时是直接移植泽泽的代码所以完全适配插件的替换MP4字段内容 当然还是先备份一下数据库以防万一嘛!!!
最后由于是搬运泽泽的嘛,麻烦有使用的去支持一下泽泽,网址:https://qqdie.com/
|´・ω・)ノ我这边正常使用暂时没有什么问题,如果有bug,或还不会怎么用可以在下方评论告诉我。
有问题的话,去加一下交流群764558144
每次播放必须刷新一下
请问影视网能不能发下
http://okzyw.com/,别的资源网也行哟,只要是m3u8和mp4后缀的都可以。
前来打卡
欢迎打卡
功能是个好功能,就是你不加自动播放有点难受。已修自动播放。
咨询你一个问题加我9876351
我这也是刚刚移植过来还没来得及做这些细节,后面会慢慢整改。