add crop
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@501 2a923420-c742-0410-a762-8d5b09965624
@ -2,7 +2,7 @@
|
||||
|
||||
package require cgi
|
||||
source /mod/var/mongoose/lib/setup
|
||||
require ts.class pretty_size
|
||||
require ts.class pretty_size system.class
|
||||
|
||||
puts "Content-Type: text/html"
|
||||
puts ""
|
||||
@ -82,6 +82,7 @@ proc entry {file} {{i 0}} {
|
||||
set locked 0
|
||||
set encd 0
|
||||
set def unknown
|
||||
set bx 0
|
||||
if {$type eq "ts"} {
|
||||
# HD / SD
|
||||
if {[$ts get definition] eq "HD"} {
|
||||
@ -114,6 +115,8 @@ proc entry {file} {{i 0}} {
|
||||
src=/images/174_1_26_GuidancePolicy.png
|
||||
height=21>"
|
||||
}
|
||||
|
||||
set bx [$ts get bookmarks]
|
||||
}
|
||||
|
||||
# Opt+ button
|
||||
@ -121,7 +124,7 @@ proc entry {file} {{i 0}} {
|
||||
puts "
|
||||
<a href=#>
|
||||
<img class=\"opt va\" border=0 width=45 type=$type did=$i
|
||||
locked=$locked encd=$encd def=$def new=$new
|
||||
locked=$locked encd=$encd def=$def new=$new bx=$bx
|
||||
src=/images/181_1_00_Help5_OPT_Plus.png>
|
||||
</a>
|
||||
<div class=\"results blood\" style=\"margin: 0 0 0 5em\"></div>
|
||||
@ -129,11 +132,7 @@ proc entry {file} {{i 0}} {
|
||||
puts "</div>"
|
||||
}
|
||||
|
||||
if {[dict exists $_cgi dir]} {
|
||||
set dir [dict get $_cgi dir]
|
||||
} else {
|
||||
set dir "/media/My Video"
|
||||
}
|
||||
set dir [cgi_get dir [system mediaroot]]
|
||||
|
||||
######################################################################
|
||||
# Render web page
|
||||
@ -145,12 +144,17 @@ puts {
|
||||
<script type="text/javascript" src="/js/jquery.contextMenu.js"></script>
|
||||
|
||||
<ul id=optmenu class=contextMenu>
|
||||
<li><a href=#delete>Delete</a></li>
|
||||
<li class=delete><a href=#delete>Delete</a></li>
|
||||
<li><a href=#lock>Toggle Lock</a></li>
|
||||
<li><a href=#enc>Toggle Enc</a></li>
|
||||
<li><a href=#new>Toggle New</a></li>
|
||||
<li><a href=#rename>Rename</a></li>
|
||||
<li><a href=#download>Download</a></li>
|
||||
}
|
||||
if {[file exists /mod/bin/nicesplice]} {
|
||||
puts { <li class="cut separator"><a href=#crop>Crop</a></li> }
|
||||
}
|
||||
puts {
|
||||
</ul>
|
||||
|
||||
<div id=renameform title="Rename media file" style="display: none">
|
||||
|
@ -127,13 +127,16 @@ function preparemenu(el, menu)
|
||||
$('#optmenu').enableContextMenuItems('#enc');
|
||||
if (el.attr('encd') == 1)
|
||||
$(menu).changeContextMenuItem('#enc',
|
||||
'Remove ENC');
|
||||
'Remove Enc');
|
||||
else
|
||||
$(menu).changeContextMenuItem('#enc',
|
||||
'Set ENC');
|
||||
'Set Enc');
|
||||
$('#optmenu').disableContextMenuItems('#crop');
|
||||
}
|
||||
else if (el.attr('bx') > 0)
|
||||
$('#optmenu').enableContextMenuItems('#crop');
|
||||
else
|
||||
$('#optmenu').disableContextMenuItems('#enc');
|
||||
$('#optmenu').disableContextMenuItems('#crop');
|
||||
|
||||
$('#optmenu').enableContextMenuItems('#new');
|
||||
if (el.attr('new') == 1)
|
||||
@ -160,6 +163,7 @@ function preparemenu(el, menu)
|
||||
$('#optmenu').disableContextMenuItems('#lock');
|
||||
$('#optmenu').disableContextMenuItems('#enc');
|
||||
$('#optmenu').disableContextMenuItems('#new');
|
||||
$('#optmenu').disableContextMenuItems('#crop');
|
||||
}
|
||||
|
||||
}
|
||||
@ -219,6 +223,11 @@ var menuclick = function(action, el, pos)
|
||||
encodeURIComponent(file);
|
||||
break;
|
||||
|
||||
case 'crop':
|
||||
window.location.href = '/cgi-bin/browse/crop.jim?file=' +
|
||||
encodeURIComponent(file);
|
||||
break;
|
||||
|
||||
default:
|
||||
alert('Unhandled action: ' + action);
|
||||
break;
|
||||
|
155
var/mongoose/cgi-bin/browse/crop.jim
Executable file
@ -0,0 +1,155 @@
|
||||
#!/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 tsfile [cgi_get file]
|
||||
set rfile [file normalize $tsfile]
|
||||
set ts [ts fetch $rfile]
|
||||
set dir [file dirname $rfile]
|
||||
|
||||
set len [$ts duration 1]
|
||||
|
||||
if {[cgi_get do] eq "it"} {
|
||||
set base [file rootname $rfile]
|
||||
set origdir "$dir/_original"
|
||||
if {![file exists $origdir]} { file mkdir $origdir }
|
||||
|
||||
set shname [file tail $base]
|
||||
puts "Processing $shname"
|
||||
|
||||
puts "Moving recording to $origdir"
|
||||
|
||||
foreach f [glob -nocomplain "${base}.*"] {
|
||||
set tail [file tail $f]
|
||||
puts " $tail"
|
||||
file rename $f "${origdir}/$tail"
|
||||
}
|
||||
|
||||
puts [exec /mod/bin/nicesplice \
|
||||
-in "$origdir/$shname" \
|
||||
-out "$dir/$shname" \
|
||||
-cutBookMarks]
|
||||
|
||||
exit
|
||||
}
|
||||
|
||||
header
|
||||
|
||||
puts "
|
||||
<link href=/css/jquery.progressbar.css rel=stylesheet type=text/css />
|
||||
<script type=\"text/javascript\" src=\"/js/jquery.progressbar.js\"></script>
|
||||
|
||||
<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>Bookmarks:</th><td>[$ts get bookmarks] @ "
|
||||
|
||||
set flag 0
|
||||
foreach b [$ts bookmarks] {
|
||||
if $flag { puts -nonewline ", " }
|
||||
incr flag
|
||||
puts -nonewline [clock format $b -format "%T"]
|
||||
}
|
||||
|
||||
puts "</td></tr>
|
||||
</table>
|
||||
|
||||
<div style=\"position: relative; top: 15px; left: 20px\">
|
||||
"
|
||||
|
||||
proc div {type left right} {
|
||||
set width $($right - $left)
|
||||
puts "<div class=$type style=\"left: ${left}px; width: ${width}px\">
|
||||
$type</div>"
|
||||
}
|
||||
|
||||
set last 0
|
||||
set start -1
|
||||
foreach b [$ts bookmarks] {
|
||||
if {$start < 0} {
|
||||
set start $b
|
||||
continue
|
||||
}
|
||||
set end $b
|
||||
|
||||
set left $($start * 500 / $len)
|
||||
set right $($end * 500 / $len)
|
||||
|
||||
div cut $last $($left - 1)
|
||||
div keep $left $($right - 1)
|
||||
|
||||
set last $right
|
||||
|
||||
set start -1
|
||||
}
|
||||
|
||||
if {$start > 0} {
|
||||
div keep $start 500
|
||||
} else {
|
||||
div cut $last 500
|
||||
}
|
||||
|
||||
puts "</div>"
|
||||
|
||||
puts {
|
||||
|
||||
<div style="margin-top: 50px"></div>
|
||||
|
||||
<div id=cropdiv><button id=cropit>Perform crop operation</button></div>
|
||||
<div id=progressdiv style="display: none">
|
||||
Cropping: <div id=progressbar></div>
|
||||
}
|
||||
puts "<button id=back dir=\"[cgi_quote_url $dir]\"
|
||||
style=\"display: none\">Back to media list</button>"
|
||||
puts {
|
||||
<div id=output class=pre style="margin-top: 10px"></div>
|
||||
</div>
|
||||
|
||||
<script type=text/javascript>
|
||||
|
||||
var handle = 0;
|
||||
var pct = 0;
|
||||
|
||||
function update()
|
||||
{
|
||||
$('#progressbar').reportprogress(++pct);
|
||||
if (pct == 100)
|
||||
{
|
||||
clearInterval(handle);
|
||||
pct = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$('#progressbar').reportprogress(0);
|
||||
|
||||
$('#back').button().click(function() {
|
||||
window.location = '/cgi-bin/browse.jim?dir=' + $(this).attr('dir');
|
||||
});
|
||||
|
||||
$('#cropit').button().click(function() {
|
||||
$('#cropdiv').hide('slow');
|
||||
$('#progressdiv').show('slow');
|
||||
handle = setInterval("update()", 100);
|
||||
$('#output').load(document.URL + '&do=it', function() {
|
||||
$('#progressbar').reportprogress(100);
|
||||
clearInterval(handle);
|
||||
pct = 0;
|
||||
$('#back').show();
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
}
|
||||
|
@ -79,16 +79,22 @@ if {$type eq "ts"} {
|
||||
<td>$sz</td>
|
||||
"
|
||||
set dlna [$ts dlnaloc]
|
||||
lassign $dlna url
|
||||
if {[llength $dlna]} {
|
||||
puts "</tr><tr><th>DLNA URL</th><td>[lindex $dlna 0]</td>"
|
||||
puts "</tr><tr><th>DLNA URL</th>
|
||||
<td><a href=\"$url\">$url</a></td>"
|
||||
}
|
||||
puts "
|
||||
</tr><tr>
|
||||
<th>Flags</th>
|
||||
<td>[$ts get flags]</td>
|
||||
</tr>
|
||||
</table>
|
||||
"
|
||||
<td>[$ts get flags]
|
||||
"
|
||||
if {[$ts get bookmarks]} {
|
||||
puts " \[Bookmarks: [$ts get bookmarks]\]"
|
||||
}
|
||||
|
||||
puts "</tr>"
|
||||
puts "</table>"
|
||||
exit
|
||||
}
|
||||
|
||||
|
@ -54,9 +54,15 @@
|
||||
classes to the respective LI element(s)
|
||||
*/
|
||||
|
||||
.contextMenu LI.edit A { background-image: url(images/page_white_edit.png); }
|
||||
.contextMenu LI.cut A { background-image: url(images/cut.png); }
|
||||
.contextMenu LI.copy A { background-image: url(images/page_white_copy.png); }
|
||||
.contextMenu LI.paste A { background-image: url(images/page_white_paste.png); }
|
||||
.contextMenu LI.delete A { background-image: url(images/page_white_delete.png); }
|
||||
.contextMenu LI.quit A { background-image: url(images/door.png); }
|
||||
.contextMenu LI.pwedit A { background-image: url(/img/context/page_white_edit.png); }
|
||||
.contextMenu LI.pwcopy A { background-image: url(/img/context/page_white_copy.png); }
|
||||
.contextMenu LI.pwpaste A { background-image: url(/img/context/page_white_paste.png); }
|
||||
.contextMenu LI.pwdelete A { background-image: url(/img/context/page_white_delete.png); }
|
||||
.contextMenu LI.edit A { background-image: url(/img/context/edit.png); }
|
||||
.contextMenu LI.copy A { background-image: url(/img/context/copy.png); }
|
||||
.contextMenu LI.paste A { background-image: url(/img/context/paste.png); }
|
||||
.contextMenu LI.delete A { background-image: url(/img/context/delete.png); }
|
||||
.contextMenu LI.cut A { background-image: url(/img/context/cut.png); }
|
||||
.contextMenu LI.quit A { background-image: url(/img/context/door.png); }
|
||||
|
||||
|
||||
|
@ -263,3 +263,25 @@ input.text
|
||||
border: 2px solid red;
|
||||
}
|
||||
|
||||
div.cut, div.keep
|
||||
{
|
||||
position: absolute;
|
||||
top: 0px;
|
||||
text-align: center;
|
||||
overflow: hidden;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
}
|
||||
|
||||
div.keep
|
||||
{
|
||||
background: green;
|
||||
color: white;
|
||||
}
|
||||
|
||||
div.cut
|
||||
{
|
||||
background: #ff4000;
|
||||
color: black;
|
||||
}
|
||||
|
||||
|
BIN
var/mongoose/html/img/context/cut.png
Normal file
After Width: | Height: | Size: 648 B |
BIN
var/mongoose/html/img/context/delete.png
Normal file
After Width: | Height: | Size: 431 B |
BIN
var/mongoose/html/img/context/door.png
Normal file
After Width: | Height: | Size: 412 B |
BIN
var/mongoose/html/img/context/edit.png
Normal file
After Width: | Height: | Size: 814 B |
BIN
var/mongoose/html/img/context/page_white_copy.png
Normal file
After Width: | Height: | Size: 309 B |
BIN
var/mongoose/html/img/context/page_white_delete.png
Normal file
After Width: | Height: | Size: 536 B |
BIN
var/mongoose/html/img/context/page_white_edit.png
Normal file
After Width: | Height: | Size: 618 B |
BIN
var/mongoose/html/img/context/page_white_paste.png
Normal file
After Width: | Height: | Size: 620 B |
BIN
var/mongoose/html/img/context/plus.png
Normal file
After Width: | Height: | Size: 511 B |
@ -16,10 +16,13 @@ class ts {
|
||||
flags ""
|
||||
error ""
|
||||
guidance ""
|
||||
bookmarks 0
|
||||
}
|
||||
|
||||
ts method duration {} {
|
||||
return [expr [expr $end - $start] / 60]
|
||||
ts method duration {{raw 0}} {
|
||||
set d [expr $end - $start]
|
||||
if {!$raw} { set d $($d / 60) }
|
||||
return $d
|
||||
}
|
||||
|
||||
ts method size {} {
|
||||
@ -30,15 +33,15 @@ ts method size {} {
|
||||
ts method _parse {line} {
|
||||
set vars [split $line "\t"]
|
||||
|
||||
set title [lindex $vars 0]
|
||||
set synopsis [lindex $vars 1]
|
||||
set definition [lindex $vars 2]
|
||||
set channel_num [lindex $vars 3]
|
||||
set channel_name [lindex $vars 4]
|
||||
set start [lindex $vars 5]
|
||||
set end [lindex $vars 6]
|
||||
set flags [split [string range [lindex $vars 7] 0 end-1] ,]
|
||||
set guidance [lindex $vars 8]
|
||||
lassign [split $line "\t"] \
|
||||
title synopsis definition channel_num channel_name \
|
||||
start end flags_list guidance bookmarks
|
||||
|
||||
set flags [split [string range $flags_list 0 end-1] ,]
|
||||
}
|
||||
|
||||
ts method bookmarks {} {
|
||||
return [exec /mod/bin/hmt -bookmarks $file]
|
||||
}
|
||||
|
||||
ts method flag {f} {
|
||||
|