fix bugs in crop, improve screen

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@507 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2011-11-04 20:47:27 +00:00
parent ebe6a0f64c
commit 436db53de3
3 changed files with 53 additions and 24 deletions

View File

@ -1,7 +1,7 @@
Package: webif Package: webif
Priority: optional Priority: optional
Section: web Section: web
Version: 0.8.0-1 Version: 0.8.0-2
Architecture: mipsel Architecture: mipsel
Maintainer: af123@hummypkg.org.uk Maintainer: af123@hummypkg.org.uk
Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4),jim-oo,jim-pack,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.7),hmt(>=1.1.0),ssmtp Depends: mongoose(>=3.0-2),jim(>=0.71-1),jim-sqlite3(>=0.71-1),jim-cgi(>=0.4),jim-oo,jim-pack,service-control,busybox(>=1.18.3-1),lsof,epg(>=1.0.7),hmt(>=1.1.0),ssmtp

View File

@ -2,7 +2,7 @@
package require cgi package require cgi
source /mod/var/mongoose/lib/setup source /mod/var/mongoose/lib/setup
require ts.class require ts.class pretty_size
puts "Content-Type: text/html\r\n\r\n" puts "Content-Type: text/html\r\n\r\n"
@ -17,6 +17,9 @@ set dir [file dirname $rfile]
set len [$ts duration 1] set len [$ts duration 1]
if {[cgi_get do] eq "it"} { if {[cgi_get do] eq "it"} {
set cropstart [clock milliseconds]
set base [file rootname $rfile] set base [file rootname $rfile]
set origdir "$dir/_original" set origdir "$dir/_original"
if {![file exists $origdir]} { file mkdir $origdir } if {![file exists $origdir]} { file mkdir $origdir }
@ -24,15 +27,17 @@ if {[cgi_get do] eq "it"} {
set shname [file tail $base] set shname [file tail $base]
puts "Processing $shname" puts "Processing $shname"
puts "Moving recording to $origdir" if {[file exists "$origdir/$shname.ts"]} {
puts "This recording already exists within _original"
puts "Cannot continue."
exit
}
puts "Moving recording to $origdir"
foreach f [glob -nocomplain "${base}.*"] { foreach f [glob -nocomplain "${base}.*"] {
set tail [file tail $f] set tail [file tail $f]
puts " $tail" puts " $tail"
while {[file exists "$origdir/$tail"]} { file rename $f "$origdir/$tail"
append tail "~"
}
file rename $f "${origdir}/$tail"
} }
puts [exec /mod/bin/nicesplice \ puts [exec /mod/bin/nicesplice \
@ -40,6 +45,14 @@ if {[cgi_get do] eq "it"} {
-out "$dir/$shname" \ -out "$dir/$shname" \
-cutBookMarks] -cutBookMarks]
set newname "$shname-[clock seconds]"
puts "Renaming file group to $newname"
ts renamegroup "$dir/$shname.ts" $newname
exec /mod/bin/hmt "+setfilename=$newname" "$dir/$newname.hmt"
set croptime [expr [expr [clock milliseconds] - $cropstart] / 1000.0]
puts "Time taken: $croptime"
exit exit
} }
@ -52,6 +65,7 @@ puts "
<table class=keyval cellpadding=5> <table class=keyval cellpadding=5>
<tr><th>File:</th><td>$rfile</td></tr> <tr><th>File:</th><td>$rfile</td></tr>
<tr><th>Length:</th><td>[clock format $len -format "%T"]</td></tr> <tr><th>Length:</th><td>[clock format $len -format "%T"]</td></tr>
<tr><th>Size:</th><td>[pretty_size [$ts size]]</td></tr>
<tr><th>Bookmarks:</th><td>[$ts get bookmarks] @ " <tr><th>Bookmarks:</th><td>[$ts get bookmarks] @ "
set flag 0 set flag 0
@ -61,11 +75,9 @@ foreach b [$ts bookmarks] {
puts -nonewline [clock format $b -format "%T"] puts -nonewline [clock format $b -format "%T"]
} }
puts "</td></tr> puts "</td></tr><tr><th>File</th><td>"
</table>
<div style=\"position: relative; top: 15px; left: 20px\"> puts "<div style=\"position: relative; top: -10px\">"
"
proc div {type left right} { proc div {type left right} {
set width $($right - $left) set width $($right - $left)
@ -73,6 +85,7 @@ proc div {type left right} {
$type</div>" $type</div>"
} }
set keeping 0
set last 0 set last 0
set start -1 set start -1
foreach b [$ts bookmarks] { foreach b [$ts bookmarks] {
@ -82,6 +95,8 @@ foreach b [$ts bookmarks] {
} }
set end $b set end $b
incr keeping $($end - $start)
set left $($start * 500 / $len) set left $($start * 500 / $len)
set right $($end * 500 / $len) set right $($end * 500 / $len)
@ -94,6 +109,7 @@ foreach b [$ts bookmarks] {
} }
if {$start > 0} { if {$start > 0} {
incr keeping $($len - $start)
set left $($start * 500 / $len) set left $($start * 500 / $len)
div cut $last $($left - 1) div cut $last $($left - 1)
div keep $left 500 div keep $left 500
@ -101,13 +117,24 @@ if {$start > 0} {
div cut $last 500 div cut $last 500
} }
puts "</div>" set keepperc $($keeping * 100.0 / $len)
set esttime $(int($keeping * 0.025))
puts "
</div>
</td></tr>
<tr><th>Keeping:</th><td>
[clock format $keeping -format "%T"] ([format "%.2f" $keepperc]%)
</td></tr>
<tr><th>Time:</th>
<td>Cropping will take around [clock format $esttime -format "%T"]</td></tr>
</table>
"
puts { puts {
<div id=cropdiv>
<div style="margin-top: 50px"></div> <button id=cropit>Perform crop operation</button>
</div>
<div id=cropdiv><button id=cropit>Perform crop operation</button></div>
<div id=progressdiv style="display: none"> <div id=progressdiv style="display: none">
Cropping: <div id=progressbar></div> Cropping: <div id=progressbar></div>
} }
@ -143,8 +170,9 @@ $('#back').button().click(function() {
$('#cropit').button().click(function() { $('#cropit').button().click(function() {
$('#cropdiv').hide('slow'); $('#cropdiv').hide('slow');
$('#progressdiv').show('slow'); $('#progressdiv').show('slow');
handle = setInterval("update()", 100); handle = setInterval("update()", 1000);
$('#output').load(document.URL + '&do=it', function() { $('#output').text('Please do not interrupt...')
.load(document.URL + '&do=it', function() {
clearInterval(handle); clearInterval(handle);
handle = 0; handle = 0;
$('#back').show(); $('#back').show();

View File

@ -9,15 +9,16 @@ puts "Content-Type: text/html\r\n\r\n"
cgi_input cgi_input
#cgi_dump #cgi_dump
set tsfile [cgi_get file] set tsfile [file normalize [cgi_get file]]
set rfile [file normalize $tsfile]
set nfile [file rootname $rfile]
if {![file exists "$rfile.decrypting"]} { set origfile "[file dirname $tsfile]/_original/[file tail $tsfile]"
set newfile [file rootname $tsfile]
if {![file exists $newfile]} {
puts "0" puts "0"
} else { } else {
set sz [file size $rfile] set sz [file size $origfile]
set nsz [file size $nfile] set nsz [file size $newfile]
puts [expr $nsz * 100 / $sz] puts [expr $nsz * 100 / $sz]
} }