已完成编写的Sky动漫网主页如下
PC电脑端效果截图:
APP手机端效果截图:
数据库相关表设计如下:
主要有:动漫主体信息表、视频播放源表、文章资讯表、主题专辑表、经典语录表、图片图集表、评论表等等
信息采集使用jsoup爬取
各大视频网站(优酷、爱奇艺、搜狐、腾讯、哔哩哔哩、乐视、新浪、土豆、芒果、PPTV等等)共享的内嵌播放器源码整理如下:
function openurl(){ var sourceurl = $("#sourceurl").val(); window.open(sourceurl); } function checkplayer(obj){ var sourceurl = $("#sourceurl").val(); var vid = $("#vid").val(); var tvid = $("#tvid").val(); var sourceplatform = $("#sourceplatform").val(); var sourceurl2 = sourceurl; var page = "1"; if(sourceplatform=='爱奇艺'){ if(vid!=''&&vid!=null){ if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)){ document.getElementById('player').innerHTML = (''); // } else { document.getElementById('player').innerHTML = ' '; //document.getElementById('player').innerHTML = (' '); } }else{ document.getElementById('player').innerHTML = (''); } }else if(sourceplatform=='优酷'){ sourceurl2=sourceurl2.substring(sourceurl2.indexOf("id_")+3,sourceurl2.indexOf(".html")); if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)) { document.getElementById('player').innerHTML = (''); }else{ //document.getElementById('player').innerHTML = (' '); //document.getElementById('player').innerHTML = '
';
document.getElementById('player').innerHTML = ('
');
}
}else if(sourceplatform=='搜狐'){
if(vid!=''&&vid!=null){
if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))
{
document.getElementById('player').innerHTML = ('
');
}else{
document.getElementById('player').innerHTML = '
';
}
}else{
document.getElementById('player').innerHTML = ('
');
}
}else if(sourceplatform=='哔哩哔哩'){
if(sourceurl2.indexOf(".html")!=-1){
page = sourceurl2.substring(sourceurl2.lastIndexOf("/index_")+7,sourceurl2.indexOf(".html"));
}
sourceurl2=sourceurl2.substring(sourceurl2.indexOf("av")+2,sourceurl2.lastIndexOf("/"));
if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))
{
document.getElementById('player').innerHTML = ('
');
}else{
document.getElementById('player').innerHTML = ('
');
}
//
//flashvars="aid=15280493&page=1" pluginspage="//www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash"> //static.hdslb.com/miniloader.swf?aid=15280493&page=1
//https://www.bilibili.com/video/av15280493/
// if (navigator.userAgent.match(/(Android)/i))
// {
// document.getElementById('player').innerHTML = ('
');
// }else if(navigator.userAgent.match(/(iPhone|iPod|ios|iPad)/i))
// {document.getElementById('player').innerHTML = ('
');
// }else{
// document.getElementById('player').innerHTML = '
点击进入 ';
// }
// if (navigator.userAgent.match(/(iPhone|iPod|ios|iPad)/i)){
// if(u3==null){
// document.getElementById('player').innerHTML = ('
');
// }
// else{
// document.getElementById('player').innerHTML = ('
');
// }
// }
// else if (navigator.userAgent.match(/(Android)/i))
// {
// document.getElementById('player').innerHTML = '
';
// }
// else
// {
// document.getElementById('player').innerHTML = '
';
// }
// document.getElementById('player').innerHTML = ('
');
}else if(sourceplatform=='PPTV'){
sourceurl2=sourceurl2.substring(sourceurl2.lastIndexOf("/")+1,sourceurl2.indexOf(".html"));
if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))
{
if(vid!=''&&vid!=null){
document.getElementById('player').innerHTML = ('
');
}else{
document.getElementById('player').innerHTML = ('
');
}
}else{
document.getElementById('player').innerHTML = '
';
}
}else if(sourceplatform=='腾讯'){
sourceurl2=sourceurl2.substring(sourceurl2.lastIndexOf("/")+1,sourceurl2.indexOf(".html"));
if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))
{
document.getElementById('player').innerHTML = ('
');
}else{
document.getElementById('player').innerHTML = '
';
}
}
else if(sourceplatform=='芒果'){
sourceurl2=sourceurl2.substring(sourceurl2.lastIndexOf("/")+1,sourceurl2.indexOf(".html"));
if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))
{
document.getElementById('player').innerHTML = ('
');
}else{
document.getElementById('player').innerHTML = '
';
}
}else if(sourceplatform=='土豆'){
//sourceurl2=sourceurl2.substring(sourceurl2.lastIndexOf("/")+1,sourceurl2.indexOf(".html"));
//if (navigator.userAgent.match(/(iPhone|Android|ios)/i))
//{
//document.getElementById('player').innerHTML = ('
');
//}else{
//document.getElementById('player').innerHTML = '
';
//}
document.getElementById('player').innerHTML = ('
');
//}else if(sourceplatform=='新浪'){
// if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))
// {
// document.getElementById('player').innerHTML = ('
');
// }else{
// document.writeln(str);
// document.getElementById('player').innerHTML = '
'; // } }else if(sourceplatform=='乐视'){ sourceurl2=sourceurl2.substring(sourceurl2.lastIndexOf("/")+1,sourceurl2.indexOf(".html")); if (navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i)) { document.getElementById('player').innerHTML = (''); }else{ document.getElementById('player').innerHTML = ''; } }else{ //document.getElementById('player').innerHTML = ('
'); } $(".sourceli").removeClass('active'); $(obj).parent("li").addClass('active'); divResize(); } checkplayer(this);
java部分相关代码如下:
try { if (bfpt.equals("爱奇艺")) { docbftp=Jsoup.connect(string3).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31").timeout(5000).get(); String docString=docbftp.html(); Elements elements = docbftp.select("div#flashbox"); if (elements.size()==0) { elements = docbftp.select("div.cms-qipuId");//$(".cms-qipuId").attr("data-qipuId"); for(Element elementq : elements){ aqy=elementq.attr("data-qipuId"); } docbftp=Jsoup.connect("http://www.iqiyi.com/v_" + aqy + ".html").userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31").timeout(5000).get(); elements = docbftp.select("div#flashbox"); for(Element elementq : elements){ vid=elementq.attr("data-player-videoid"); tvid=elementq.attr("data-player-tvid"); } }else { for(Element elementq : elements){ vid=elementq.attr("data-player-videoid"); tvid=elementq.attr("data-player-tvid"); } } if (vid.equals("")||StringUtils.isBlank(tvid)) { Pattern pvid = Pattern.compile("\"vid\":\".*\",\"cid\""); Pattern ptvid = Pattern.compile(",\"tvId\":.*,\"vid\":\""); Matcher mvid = pvid.matcher(docString); Matcher mtvid = ptvid.matcher(docString); while (mvid.find()) { vid=mvid.group().replaceAll("\"vid\":\"", "").replaceAll("\",\"cid\"", ""); } while (mtvid.find()) { tvid=mtvid.group().replaceAll(",\"tvId\":", "").replaceAll(",\"vid\":\"", ""); } } }else if (bfpt.equals("搜狐")) { docbftp=Jsoup.connect(string3).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31").timeout(5000).get(); hString=docbftp.html(); tvid=hString.substring(hString.indexOf("var playlistId=")+16, hString.indexOf("var o_playlistId=")-5); vid=hString.substring(hString.indexOf("var vid=")+9, hString.indexOf("var nid = ")-5); }else if (bfpt.equals("PPTV")) { docbftp=Jsoup.connect(string3).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31").timeout(5000).get(); Elements elementbfs = docbftp.select("input#share-input3"); for(Element elementbfpt : elementbfs){ flashvars=elementbfpt.attr("value"); vid=flashvars.substring(flashvars.indexOf("#id=")+4, flashvars.indexOf("&ctx=")); } }else { } } catch (Exception e) { vid=""; tvid=""; } string3 = string3.replaceAll("'", ""); sql3="insert into tb_video_source values ("+bf+",'"+tbVideo.getId()+"','"+StrUtils.getNow()+"','1','"+string3+"','"+bfpt+"','"+bfsort+"','"+copyjishu+"','"+vid+"','"+tvid+"');\r\n";
log_maxid++; logsource="更新数据-更新动漫视频信息成功。共更新"+logvideo_cnt+"个动漫视频信息"; logsource=logsource.replaceAll("'", ""); Db.update("insert into data_log values ("+log_maxid+",'tb_video','更新数据','"+logsource+"','"+StrUtils.getNow()+"','1');\r\n"); log_maxid++; logsource="更新数据-插入播放源成功。共新增"+logsource_cnt+"个播放源"; logsource=logsource.replaceAll("'", ""); Db.update("insert into data_log values ("+log_maxid+",'tb_video_source','更新数据','"+logsource+"','"+StrUtils.getNow()+"','1');\r\n"); connection.commit();
主要html相关代码如下:
<% var headContent = { include("/template/dm/includes/header.html"){} %> <% }; var bodyContent = { include("/template/dm/includes/header_menu2.html"){} %>
<% if(!strutil.isEmpty(item.thumbnail)){ %> alt=""> <% } else { %> <% } %> ${item.status==1?item.jishu+'集全':'更新至'+item.gxjishu+'集共'+item.jishu+'集'} ${item.name}
类型: ${item.types}
年份: ${item.year}
地区: ${javaweb.showVideoArea(item.area)}
版本: ${javaweb.showVideoVersions(item.versions)}
导演: ${item.daoyan}
演员: ${item.yanyuan}
简介:${item.remark} ${item.name}在线播放高清视频资源由sky动漫岛[www.51skydao.com]收集整理,是${item.year}年${javaweb.showVideoArea(item.area)}${javaweb.toReplaceAll(item.types,"/","、")}类的${javaweb.showVideoVersions(item.versions)}动漫,是一部不错的作品哦!
<% for (item3 in listsou){ %>
<%} %>
更多推荐 <% for(item in videos){ %>
<% if(!strutil.isEmpty(item.thumbnail)){ %> data-original="${BASE_PATH }file_manage/dm/video_image/${item.thumbnail}" alt="${item.name}"> <% } else { %> alt="${item.name}"> <% } %> ${item.status==1?item.jishu+'集全':'更新至'+item.gxjishu+'集'} title="${item.name}"> title="${item.name}">${item.name}
<% } %>
<%}; layout("/pages/template/_layout.html",{head:headContent,body:bodyContent}){} %>