From d307699ab19948ea523164b1843c81ac483fd9a1 Mon Sep 17 00:00:00 2001 From: hummypkg Date: Mon, 6 Feb 2012 23:28:53 +0000 Subject: [PATCH] add 45 minute split git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@724 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 2 +- var/mongoose/cgi-bin/browse.jim | 4 +- var/mongoose/cgi-bin/browse/assets.jim | 5 +- var/mongoose/cgi-bin/browse/browse.js | 11 +++ var/mongoose/cgi-bin/browse/chunk/chunk.css | 6 ++ var/mongoose/cgi-bin/browse/chunk/chunk.jim | 72 ++++++++++++++++++ var/mongoose/cgi-bin/browse/chunk/chunk.js | 73 +++++++++++++++++++ var/mongoose/cgi-bin/browse/chunk/extract.jim | 34 +++++++++ .../cgi-bin/browse/chunk/progress.jim | 17 +++++ var/mongoose/html/css/jquery.progressbar.css | 8 +- 10 files changed, 225 insertions(+), 7 deletions(-) create mode 100644 var/mongoose/cgi-bin/browse/chunk/chunk.css create mode 100755 var/mongoose/cgi-bin/browse/chunk/chunk.jim create mode 100644 var/mongoose/cgi-bin/browse/chunk/chunk.js create mode 100755 var/mongoose/cgi-bin/browse/chunk/extract.jim create mode 100755 var/mongoose/cgi-bin/browse/chunk/progress.jim diff --git a/CONTROL/control b/CONTROL/control index 855113d..86c370b 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -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 diff --git a/var/mongoose/cgi-bin/browse.jim b/var/mongoose/cgi-bin/browse.jim index f94e017..4e88f7f 100755 --- a/var/mongoose/cgi-bin/browse.jim +++ b/var/mongoose/cgi-bin/browse.jim @@ -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}} { diff --git a/var/mongoose/cgi-bin/browse/assets.jim b/var/mongoose/cgi-bin/browse/assets.jim index 5d8dcc0..8534ef1 100755 --- a/var/mongoose/cgi-bin/browse/assets.jim +++ b/var/mongoose/cgi-bin/browse/assets.jim @@ -20,7 +20,10 @@ if {[system pkginst ffmpeg]} { puts {
  • Extract Audio
  • } } if $nicesplice { - puts {
  • Crop
  • } + puts { +
  • Crop
  • +
  • Split (45m parts)
  • + } } puts {
  • Toggle Lock
  • diff --git a/var/mongoose/cgi-bin/browse/browse.js b/var/mongoose/cgi-bin/browse/browse.js index e7d9670..2cdc6b4 100755 --- a/var/mongoose/cgi-bin/browse/browse.js +++ b/var/mongoose/cgi-bin/browse/browse.js @@ -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; diff --git a/var/mongoose/cgi-bin/browse/chunk/chunk.css b/var/mongoose/cgi-bin/browse/chunk/chunk.css new file mode 100644 index 0000000..9b75129 --- /dev/null +++ b/var/mongoose/cgi-bin/browse/chunk/chunk.css @@ -0,0 +1,6 @@ + +div.progressbar +{ + width: 200px; +} + diff --git a/var/mongoose/cgi-bin/browse/chunk/chunk.jim b/var/mongoose/cgi-bin/browse/chunk/chunk.jim new file mode 100755 index 0000000..6d3ecc8 --- /dev/null +++ b/var/mongoose/cgi-bin/browse/chunk/chunk.jim @@ -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 " + + + + + +
    +Split recording into 45 minute segments + + + + + + +" + +set bytesperminute $([$ts size] / ($len / 60)) + +while {$len > 0} { + incr part + incr len -$max + puts " + " +} + +puts " +
    File:$rfile
    Length:[clock format $len -format "%T"]
    Size:[pretty_size [$ts size]] ([$ts get definition])
    Time:Splitting will take around [clock format $esttime -format "%T"]
    Part $part +
    +
    waiting...
    +
    + + +
    + +
    + + + +
    +" + diff --git a/var/mongoose/cgi-bin/browse/chunk/chunk.js b/var/mongoose/cgi-bin/browse/chunk/chunk.js new file mode 100644 index 0000000..cee4103 --- /dev/null +++ b/var/mongoose/cgi-bin/browse/chunk/chunk.js @@ -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; +}); + +}); + diff --git a/var/mongoose/cgi-bin/browse/chunk/extract.jim b/var/mongoose/cgi-bin/browse/chunk/extract.jim new file mode 100755 index 0000000..7e46953 --- /dev/null +++ b/var/mongoose/cgi-bin/browse/chunk/extract.jim @@ -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] + diff --git a/var/mongoose/cgi-bin/browse/chunk/progress.jim b/var/mongoose/cgi-bin/browse/chunk/progress.jim new file mode 100755 index 0000000..a21b3c7 --- /dev/null +++ b/var/mongoose/cgi-bin/browse/chunk/progress.jim @@ -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] + diff --git a/var/mongoose/html/css/jquery.progressbar.css b/var/mongoose/html/css/jquery.progressbar.css index 495a609..9df96de 100644 --- a/var/mongoose/html/css/jquery.progressbar.css +++ b/var/mongoose/html/css/jquery.progressbar.css @@ -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%;