add 45 minute split

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@724 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2012-02-06 23:28:53 +00:00
parent 3f6e8754c6
commit d307699ab1
10 changed files with 225 additions and 7 deletions

View File

@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 0.9.1-1
Version: 0.9.1-2
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73),jim-cgi(>=0.5),service-control,busybox(>=1.19.3-1),lsof,epg(>=1.0.8),hmt(>=1.1.4),ssmtp,anacron,trm,openssl-command,nicesplice,id3v2

View File

@ -91,7 +91,8 @@ proc entry {file} {{i 0}} {
if {$ext in $::ignore || $ext ni $::include} { continue }
file stat $file st
set sz [pretty_size $st(size)]
set rsz $st(size)
set sz [pretty_size $rsz]
set base [file rootname $file]
@ -195,6 +196,7 @@ proc entry {file} {{i 0}} {
<a href=#>
<img class=\"opt va\" border=0 width=45 type=$type did=$i
locked=$locked encd=$encd def=$def new=$new bx=$bx
rsize=$rsz
odencd=$odencd dlna=$dlna
src=/images/181_1_00_Help5_OPT_Plus.png>
</a>

View File

@ -20,7 +20,10 @@ if {[system pkginst ffmpeg]} {
puts { <li><a href=#audio>Extract Audio</a></li> }
}
if $nicesplice {
puts { <li class="cut"><a href=#crop>Crop</a></li> }
puts {
<li class="cut"><a href=#crop>Crop</a></li>
<li class="cut"><a href=#chunk>Split (45m parts)</a></li>
}
}
puts {
<li class=separator><a href=#lock>Toggle Lock</a></li>

View File

@ -238,6 +238,11 @@ function preparemenu(el, menu)
else
$(menu).disableContextMenuItems('#crop');
if (el.attr('rsize') > 4294967296)
$(menu).enableContextMenuItems('#chunk');
else
$(menu).disableContextMenuItems('#chunk');
$(menu).enableContextMenuItems('#new');
if (el.attr('new') == 1)
$(menu).changeContextMenuItem('#new', 'Mark watched');
@ -276,6 +281,7 @@ function preparemenu(el, menu)
$(menu).disableContextMenuItems('#decrypt');
$(menu).disableContextMenuItems('#audio');
$(menu).disableContextMenuItems('#crop');
$(menu).disableContextMenuItems('#chunk');
}
}
@ -364,6 +370,11 @@ var menuclick = function(action, el, pos)
file;
break;
case 'chunk':
window.location.href = '/cgi-bin/browse/chunk/chunk.jim?file=' +
file;
break;
case 'decrypt':
window.location.href = '/cgi-bin/browse/decrypt.jim?file=' +
file;

View File

@ -0,0 +1,6 @@
div.progressbar
{
width: 200px;
}

View File

@ -0,0 +1,72 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require ts.class pretty_size
puts "Content-Type: text/html\r\n\r\n"
cgi_input
#cgi_dump
set rfile [cgi_get file]
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
# 45 minute chunks
set max $(45 * 60)
set len [$ts duration 1]
set esttime $(int($len * 0.025))
if {[$ts get definition] eq "HD"} { set esttime $($esttime * 4) }
header
puts "
<script type=text/javascript src=/js/jquery.progressbar.js></script>
<script type=text/javascript src=chunk.js></script>
<link href=/css/jquery.progressbar.css rel=stylesheet type=text/css />
<link href=chunk.css rel=stylesheet type=text/css />
<fieldset class=cleft>
<legend>Split recording into 45 minute segments</legend>
<table class=keyval cellpadding=5>
<tr><th>File:</th><td>$rfile</td></tr>
<tr><th>Length:</th><td>[clock format $len -format "%T"]</td></tr>
<tr><th>Size:</th><td>[pretty_size [$ts size]] ([$ts get definition])</td></tr>
<tr><th>Time:</th>
<td>Splitting will take around [clock format $esttime -format "%T"]</td></tr>
"
set bytesperminute $([$ts size] / ($len / 60))
while {$len > 0} {
incr part
incr len -$max
puts "<tr class=\"part hidden\">
<th>Part $part</th><td>
<div id=progresspart$part class=progressbar></div>
<div id=progressstat$part class=also>waiting...</div>
</td></tr>"
}
puts "
</table>
<span class=hidden id=params parts=$part bpm=$bytesperminute
file=\"[cgi_quote_url $rfile]\">
</span>
<div id=chunkdiv style=\"padding: 1em\">
<button id=chunkit>Split recording into $part parts</button>
</div>
<div id=findiv style=\"padding: 1em\" class=hidden>
<button id=back dir=\"[cgi_quote_url [file dirname $rfile]]\">
Back to Media Browser
</button>
</div>
</fieldset>
"

View File

@ -0,0 +1,73 @@
var handle;
var currentpart = 0;
function xprogress()
{
var file = $('#params').attr('file');
var bpm = $('#params').attr('bpm');
if (currentpart > 0)
$.get('progress.jim?part=' + currentpart + '&file=' + file,
function(data) {
if (currentpart > 0)
{
perc = (data / bpm) * 100 / 45;
$('#progresspart' + currentpart)
.reportprogress(perc);
}
});
}
function xpart(part)
{
var parts = $('#params').attr('parts');
var file = $('#params').attr('file');
if (part++ < parts)
{
if (window.console)
console.log('Extracting part: ' + part);
currentpart = part;
$('#progressstat' + part)
.text('extracting...')
.addClass('blood');
$.get('extract.jim?part=' + part + '&file=' + file,
function(data) {
$('#progressstat' + part)
.text('done...')
.removeClass('blood');
currentpart = 0;
$('#progresspart' + part)
.reportprogress(100);
xpart(part);
});
}
else
{
clearInterval(handle);
$('#findiv').show('slow');
}
}
$(function() {
$('div.progressbar').reportprogress(0);
$('#chunkit').button().click(function(e) {
e.preventDefault();
$('#chunkdiv').hide('slow');
$('tr.part').show('slow');
handle = setInterval("xprogress()", 1000);
xpart(0);
});
$('#back').button().click(function(e) {
e.preventDefault();
var dir = $(this).attr('dir');
window.location = '/cgi-bin/browse.jim?dir=' + dir;
});
});

View File

@ -0,0 +1,34 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require ts.class pretty_size
puts "Content-Type: text/html\r\n\r\n"
cgi_input
#cgi_dump
set rfile [cgi_get file]
set part [cgi_get part -]
if {$part eq "-"} exit
set start $(($part - 1) * 45 * 600 - 600)
set end $($part * 45 * 600 + 600)
puts "START: $start"
puts "END: $end"
set ts [ts fetch $rfile]
set base [file rootname $rfile]
set cmd [list /mod/bin/nicesplice -in $base -out "$base.part$part"]
if {$start > 0} { lappend cmd -cut 0 $start }
lappend cmd -cut $end 9999999
puts "CMD: ($cmd)"
puts [exec {*}$cmd]

View File

@ -0,0 +1,17 @@
#!/mod/bin/jimsh
package require cgi
source /mod/var/mongoose/lib/setup
require ts.class
puts "Content-Type: text/html\r\n\r\n"
cgi_input
#cgi_dump
set file [cgi_get file]
set part [cgi_get part]
set rfile "[file rootname $file].part$part"
puts [file size $rfile]

View File

@ -1,6 +1,6 @@
/* progress bar container */
#progressbar{
.progressbar, #progressbar{
border:1px solid black;
width:200px;
height:20px;
@ -8,7 +8,7 @@
color:black;
}
/* color bar */
#progressbar div.progress{
.progressbar div.progress,#progressbar div.progress{
position:absolute;
width:0;
height:100%;
@ -16,13 +16,13 @@
background-color:#369;
}
/* text on bar */
#progressbar div.progress .text{
.progressbar div.progress .text,#progressbar div.progress .text{
position:absolute;
text-align:center;
color:white;
}
/* text off bar */
#progressbar div.text{
.progressbar div.text,#progressbar div.text{
position:absolute;
width:100%;
height:100%;