master
cn.yimian.xyz 4 years ago
parent 396eb12f5b
commit 154870d767
  1. 32
      index.html

@ -175,16 +175,18 @@
} }
}; };
/* if no GET video url */ /* if no GET video url */
session.onload(()=>{
if(Object.keys(page.params).length === 0 || !page.params.hasOwnProperty("url")){ if(Object.keys(page.params).length === 0 || !page.params.hasOwnProperty("url")){
if(!cookie.get('last_watch')){ if(!session.get('acg/last_watch')){
page.params.url = "https://api.yimian.xyz/video/?path=404.mp4"; page.params.url = "https://api.yimian.xyz/video/?path=404.mp4";
}else{ }else{
page.params.url = cookie.get('last_watch'); page.params.url = session.get('acg/last_watch');
history.pushState({},page.title,"https://acg.watch/player?url="+cookie.get('last_watch')); history.pushState({},page.title,"https://acg.watch/player?url="+session.get('acg/last_watch'));
} }
}else{ }else{
cookie.set('last_watch', page.params.url); session.set('acg/last_watch', page.params.url);
} }
});
var dp = {}; var dp = {};
var isWaiting = false; var isWaiting = false;
$.get("https://acg.watch/api/getVideoByUrl?url="+page.params.url, function(res){ $.get("https://acg.watch/api/getVideoByUrl?url="+page.params.url, function(res){
@ -195,18 +197,22 @@
dp = new DPlayer(options); dp = new DPlayer(options);
/* recover history playing */ /* recover history playing */
if(options.video.quality[0].url && options.video.quality[0].url != 'https://api.yimian.xyz/video?path=404.mp4'){ if(options.video.quality[0].url && options.video.quality[0].url != 'https://api.yimian.xyz/video?path=404.mp4'){
if(cookie.get($.md5(options.video.quality[0].url)) != null){ session.onload(()=>{
dp.seek(cookie.get($.md5(options.video.quality[0].url))); if(session.get($.md5(options.video.quality[0].url)) != null){
options.video.playFrom = cookie.get($.md5(options.video.quality[0].url)); dp.seek(session.get($.md5(options.video.quality[0].url)));
options.video.playFrom = session.get($.md5(options.video.quality[0].url));
dp.notice("已恢复到上次播放位置", 4000); dp.notice("已恢复到上次播放位置", 4000);
} }
});
} }
/* record seek point */ /* record seek point */
setInterval(function(){ setInterval(function(){
if(!dp.video.paused && dp.video.currentTime > 10){ if(!dp.video.paused && dp.video.currentTime > 10){
cookie.set($.md5(options.video.quality[0].url), dp.video.currentTime); session.onload(()=>{
} session.set($.md5(options.video.quality[0].url), dp.video.currentTime);
}, 1000); });
}
}, 8000);
/* print info */ /* print info */
getInfo(res); getInfo(res);
/* next video */ /* next video */
@ -219,12 +225,13 @@
}); });
var next_video = function() { var next_video = function() {
cookie.set($.md5(options.video.quality[0].url), "0"); session.onload(()=>{
session.set($.md5(options.video.quality[0].url), "0");
$.get("https://acg.watch/api/getNextByUrl?url="+options.video.quality[0].url, function(res){ $.get("https://acg.watch/api/getNextByUrl?url="+options.video.quality[0].url, function(res){
//res = JSON.parse(res); //res = JSON.parse(res);
dp.notice("正在跳转至下一集", 4000); dp.notice("正在跳转至下一集", 4000);
setTimeout(function(){ setTimeout(function(){
cookie.set('last_watch', res.url); session.set('acg/last_watch', res.url);
history.pushState({},page.title,"https://acg.watch/player?url="+res.url); history.pushState({},page.title,"https://acg.watch/player?url="+res.url);
page.params.url = res.url; page.params.url = res.url;
@ -257,6 +264,7 @@
}, 2000); }, 2000);
}); });
});
} }
var getQuality = function(res){ var getQuality = function(res){
var quality = [ var quality = [

Loading…
Cancel
Save