0

Merge branch 'dev'

This commit is contained in:
2016-03-30 15:55:48 +03:00
4 changed files with 164 additions and 39 deletions

View File

@@ -66,28 +66,15 @@ public class Onlinelife implements KinoWarez {
}
}
boolean has_player = is_serial(name);
name = name.replaceAll("\\[.+", "").trim();
Kino kino = new Kino(name, url, this);
kino.setPlayer(has_player);
kino.setPlayer(true);
outList.add(kino);
}
return outList;
}
private boolean is_serial(String name) {
Pattern pattern = Pattern.compile("\\[(.+)\\]");
Matcher matcher = pattern.matcher(name);
if (matcher.find()) {
int idx = matcher.group().indexOf("1");
return !(idx >= 0);
} else {
return false;
}
}
@Override
public String player(String page) {
String movie_id = page.substring(1,page.indexOf("-"));
@@ -102,7 +89,8 @@ public class Onlinelife implements KinoWarez {
if (jsonObj.has("file")) {
String fileMp4 = jsonObj.get("file").getAsString().substring("http://".length());
return "{\"file\":\"/proxy/onlinelife/" + fileMp4 + "\"}";
String title = jsonObj.get("comment").getAsString();
return "{\"file\":\"/proxy/onlinelife/" + fileMp4 + "\",\"title\":\"" + title + "\"}";
} else if (jsonObj.has("pl")) {
browser.setEncoding("utf-8");
return replaceToProxy(browser.get(jsonObj.get("pl").getAsString()));

View File

@@ -1,4 +1,16 @@
<div class="news row">
<div class="col-sm-2">
<time datetime="2016-03-30">30.03.2016</time>
</div>
<div class="col-sm-10">
<p><em>Version 2.0.7c</em></p>
<ul>
<li>[эксперементально] плеер воспроизводит сериалы</li>
<li>возможность продолжить просмотр с сохранённой позиции</li>
<li>название фильма/серии над плеером</li>
</ul>
</div>
<div class="col-sm-2">
<time datetime="2016-03-26">26.03.2016</time>
</div>

View File

@@ -1,42 +1,161 @@
<#include "/header.inc.html">
<script type="text/javascript" src="${basedir}/js/js.cookie-2.1.0.min.js"></script>
<script type="text/javascript">
var video_data = ${json};
var player;
var origDocTitle;
var isSerial = false;
function msToTime(ms) {
function addZ(n) { return (n<10? '0':'') + n; }
var _ms = ms % 1000;
ms = (ms - _ms) / 1000;
var _sec = ms % 60;
ms = (ms - _sec) / 60;
var _min = ms % 60;
var _hr = (ms - _min) / 60;
return {
's': addZ(_sec),
'm': addZ(_min),
'h': addZ(_hr)
};
}
function setTitle(text) {
document.title = text + " :: " + origDocTitle;
$('#title').text(text);
$('#title').show();
}
function setSeason(idx) {
var season_title = video_data.playlist[idx].comment;
$('#dropdownSeason').html(season_title + '&nbsp;<span class="caret"></span>');
$('#dropdownSerial').html('Serials&nbsp;<span class="caret"></span>');
var serial_menu = $('#pl-serial-menu');
serial_menu.html('');
video_data.playlist[idx].playlist.forEach(function(item, i){
serial_menu.append('<li><a data-file="' + item.file + '" data-season="' + idx + '" href="#" onclick="setSerial('+ idx + ',' + i + ');return false;">' + item.comment + '</a></li>');
});
/*
serial_menu.find('a').bind('click', function(){
$('#dropdownSerial').html(this.text + '&nbsp;<span class="caret"></span>');
player.attr('src', '${basedir}'+this.attributes['data-file'].value);
player.attr('data-season', this.attributes['data-season'].value);
player.attr('data-serial', this.attributes['data-serial'].value);
setTitle(this.text);
});
*/
$('#pl-serial').removeClass('hide');
}
function setSerial(idx, sidx) {
var serial_title = video_data.playlist[idx].playlist[sidx].comment;
$('#dropdownSerial').html(serial_title + '&nbsp;<span class="caret"></span>');
var serial_file = video_data.playlist[idx].playlist[sidx].file;
player.attr('src', '${basedir}' + serial_file);
player.attr('data-season', idx);
player.attr('data-serial', sidx);
setTitle(serial_title);
}
$(function(){
player = $('#player');
origDocTitle = document.title;
if (typeof(video_data.title) !== 'undefined') {
setTitle(video_data.title);
} else {
$('#title').hide();
}
// set video
if (typeof(video_data.file) !== 'undefined') {
$('#player').attr('src', '${basedir}'+video_data.file);
player.attr('src', '${basedir}'+video_data.file);
$('#plbr').hide();
} else if (typeof(video_data.playlist) !== 'undefined') {
isSerial = true;
$('#pl-season').removeClass('hide');
menu = $('#pl-season-menu');
menu.html('');
video_data.playlist.forEach(function(item, i){
menu.append('<li><a data-tag="' + i + '" href="#" onclick="return false;">' + item.comment + '</a></li>');
});
ddBtn = $('#dropdownSeason');
smenu = $('#pl-serial-menu');
menu.find('a').bind('click', function(){
ddBtn.html(this.text + '&nbsp;<span class="caret"></span>');
$('#dropdownSerial').html('Serials&nbsp;<span class="caret"></span>');
smenu.html('');
video_data.playlist[this.attributes['data-tag'].value].playlist.forEach(function(item){
smenu.append('<li><a data-file="' + item.file + '" href="#" onclick="return false;">' + item.comment + '</a></li>');
});
smenu.find('a').bind('click', function(){
$('#dropdownSerial').html(this.text + '&nbsp;<span class="caret"></span>');
$('#player').attr('src', '${basedir}'+this.attributes['data-file'].value);
});
$('#pl-serial').removeClass('hide');
menu.append('<li><a data-tag="' + i + '" href="#" onclick="setSeason(' + i + ');return false;">' + item.comment + '</a></li>');
});
}
// load video time
var path = window.location.pathname.substr("${basedir}".length);
data = Cookies.getJSON(path);
if (data != null) {
var fulltime = msToTime(data.time * 1000);
$('#mdl-vtime').text(fulltime.h + ':' + fulltime.m + ':' + fulltime.s);
if (isSerial) {
$('#mdl-season').text(data.season + 1);
$('#mdl-serial').text(data.serial + 1);
}
$('#modal').modal('show');
} else {
player.load();
}
// save video time
var tl;
player.bind('play', function(){
tl = $.now();
});
player.bind('timeupdate', function(){
var tc = $.now();
var sec = Math.floor((tc-tl)/1000);
if (sec >= 5) {
if (Math.floor(player[0].currentTime) <= 10) return;
save_data = {time:player[0].currentTime};
if (isSerial) {
save_data.season = parseInt(player.attr('data-season'), 10);
save_data.serial = parseInt(player.attr('data-serial'), 10);
}
Cookies.set(path, save_data);
tl = tc;
console.debug(save_data);
}
});
});
function continueVideo() {
if (isSerial) {
setSeason(data.season);
setSerial(data.season, data.serial);
}
player[0].currentTime = data.time;
player[0].load();
}
</script>
<div class="modal fade" tabindex="-1" role="dialog" id="modal">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title">Продолжить просмотр?</h4>
</div>
<div class="modal-body">
<b>Время:</b> <span id="mdl-vtime"></span>
<div id="mdl-blk-serial">
<b>Сезон:</b> <span id="mdl-season"></span><br>
<b>Серия:</b> <span id="mdl-serial"></span>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal" onclick="continueVideo()">Да</button>
<button type="button" class="btn btn-default" data-dismiss="modal" onclick="player[0].load()">Нет</button>
</div>
</div>
</div>
</div>
<hr>
<div id="pl-season" class="dropdown hide" style="display: inline-block;">
@@ -59,8 +178,12 @@
</ul>
</div>
<br><br>
<br id="plbr">
<video id="player" class="center-block" controls="controls"></video>
<h2 id="title"></h2>
<br>
<video id="player" class="center-block" controls="controls" preload="none"></video>
<br>
<#include "/fother.inc.html">

2
webapp/js/js.cookie-2.1.0.min.js vendored Normal file
View File

@@ -0,0 +1,2 @@
/*! js-cookie v2.1.0 | MIT */
!function(a){if("function"==typeof define&&define.amd)define(a);else if("object"==typeof exports)module.exports=a();else{var b=window.Cookies,c=window.Cookies=a();c.noConflict=function(){return window.Cookies=b,c}}}(function(){function a(){for(var a=0,b={};a<arguments.length;a++){var c=arguments[a];for(var d in c)b[d]=c[d]}return b}function b(c){function d(b,e,f){var g;if(arguments.length>1){if(f=a({path:"/"},d.defaults,f),"number"==typeof f.expires){var h=new Date;h.setMilliseconds(h.getMilliseconds()+864e5*f.expires),f.expires=h}try{g=JSON.stringify(e),/^[\{\[]/.test(g)&&(e=g)}catch(i){}return e=c.write?c.write(e,b):encodeURIComponent(String(e)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),b=encodeURIComponent(String(b)),b=b.replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent),b=b.replace(/[\(\)]/g,escape),document.cookie=[b,"=",e,f.expires&&"; expires="+f.expires.toUTCString(),f.path&&"; path="+f.path,f.domain&&"; domain="+f.domain,f.secure?"; secure":""].join("")}b||(g={});for(var j=document.cookie?document.cookie.split("; "):[],k=/(%[0-9A-Z]{2})+/g,l=0;l<j.length;l++){var m=j[l].split("="),n=m[0].replace(k,decodeURIComponent),o=m.slice(1).join("=");'"'===o.charAt(0)&&(o=o.slice(1,-1));try{if(o=c.read?c.read(o,n):c(o,n)||o.replace(k,decodeURIComponent),this.json)try{o=JSON.parse(o)}catch(i){}if(b===n){g=o;break}b||(g[n]=o)}catch(i){}}return g}return d.get=d.set=d,d.getJSON=function(){return d.apply({json:!0},[].slice.call(arguments))},d.defaults={},d.remove=function(b,c){d(b,"",a(c,{expires:-1}))},d.withConverter=b,d}return b(function(){})});