From 070fd7a749bb3d5cda830b2285b0f9f8e84bed7f Mon Sep 17 00:00:00 2001 From: hummypkg Date: Tue, 5 Mar 2013 00:10:38 +0000 Subject: [PATCH] update git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1436 2a923420-c742-0410-a762-8d5b09965624 --- CONTROL/control | 2 +- CONTROL/postinst | 11 ++++ var/mongoose/cgi-bin/status.jim | 5 +- var/mongoose/html/browse/index.jim | 14 ++--- var/mongoose/html/browse/script.js | 37 +++++++------- var/mongoose/html/browse/shrunk.jim | 19 +++++-- var/mongoose/html/browse/strip/execute.jim | 1 + var/mongoose/lib/bin/auto | 14 +++-- var/mongoose/lib/bin/strip-update | 59 ++++++++++++++++++++++ 9 files changed, 126 insertions(+), 36 deletions(-) create mode 100755 var/mongoose/lib/bin/strip-update diff --git a/CONTROL/control b/CONTROL/control index 0fde3bc..0cc75ab 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: webif Priority: optional Section: web -Version: 0.13.1 +Version: 0.13.2 Architecture: mipsel Maintainer: af123@hummypkg.org.uk Depends: webif-channelicons(>=1.0.4-1),mongoose(>=3.0-7),jim(>=0.73-1),jim-oo,jim-sqlite3(>=0.73-1),jim-cgi(>=0.7),jim-binary,service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.10),hmt(>=1.1.13),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.1.2),smartmontools,tmenu(>=1.05) diff --git a/CONTROL/postinst b/CONTROL/postinst index d5718ab..be606d7 100755 --- a/CONTROL/postinst +++ b/CONTROL/postinst @@ -1,5 +1,7 @@ #!/bin/sh +echo "Postinstall $*" + export tmpf=/tmp/cronf.$$ # Add cron jobs @@ -27,5 +29,14 @@ $PKG_ROOT/etc/init.d/S02anacron start < /dev/null > /dev/null 2>&1 & [ -f /tmp/webif_auto.log ] && rm -f /tmp/webif_auto.log +if [ ! -f /mod/webif/.strip-updated ]; then + echo "*********************************" + echo "* Please wait while any shrunk recordings are flagged..." + echo "*********************************" + /mod/webif/lib/bin/strip-update + + touch /mod/webif/.strip-updated +fi + exit 0 diff --git a/var/mongoose/cgi-bin/status.jim b/var/mongoose/cgi-bin/status.jim index 5bd21e3..7c55324 100755 --- a/var/mongoose/cgi-bin/status.jim +++ b/var/mongoose/cgi-bin/status.jim @@ -63,7 +63,10 @@ if {[llength $data]} { foreach name [array names ndata] { if {![dict exists $seen $name]} { set seen($name) 0 } if {![dict exists $data $name]} { set data($name) 0 } - if {$ndata($name) == -1} { + if {[file exists "/mod/tmp/webif_auto/decrypting.$name.ts"]} { + set mode "Decrypting" + set icon "178_1_00_Icon_Lock.png style=\"padding: 0 0.2em 0 0.5em\"" + } elseif {$ndata($name) == -1} { incr rec incr play set mode "Chase Playing" diff --git a/var/mongoose/html/browse/index.jim b/var/mongoose/html/browse/index.jim index 9ad12ee..4a9a77d 100755 --- a/var/mongoose/html/browse/index.jim +++ b/var/mongoose/html/browse/index.jim @@ -152,6 +152,7 @@ proc entry {file} {{i 0}} { set def unknown set bx 0 set dlna 0 + set shrunk 0 if {$type eq "ts"} { set genre [$ts get genre] set glist [ts genrelist] @@ -204,12 +205,11 @@ proc entry {file} {{i 0}} { set dlna 1 } - # Shrunk (shown when necessary via Ajax) - icon "/img/compress.png" "Shrunk" \ - "id=\"sp_$tbfile\"" "va hidden" - # Timeshifted (shown when necessary via Ajax) -# icon "/img/clock.png" "Time-shifted Recording" \ -# "id=\"tsr_$tbfile\"" "va hidden" + # Shrunk + if {[$ts flag Shrunk]} { + icon "/img/compress.png" "Shrunk" + set shrunk 1 + } set bx [$ts get bookmarks] } @@ -220,7 +220,7 @@ proc entry {file} {{i 0}} { diff --git a/var/mongoose/html/browse/script.js b/var/mongoose/html/browse/script.js index 6778028..78b51e6 100755 --- a/var/mongoose/html/browse/script.js +++ b/var/mongoose/html/browse/script.js @@ -125,23 +125,23 @@ function new_folder_callback(data, status, xhr) $.each(data, set_folder_new); } -function insert_shrunk(file, perc) -{ - if (perc == 0) - { - file = file.replace(/[ ]/g, ''); - file = file.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1'); - //console.log("File: (%s) = (%s)", file, perc); - $('#sp_' + file).show(); - } -} +//function insert_shrunk(file, perc) +//{ +// if (perc == 0) +// { +// file = file.replace(/[ ]/g, ''); +// file = file.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1'); +// //console.log("File: (%s) = (%s)", file, perc); +// $('#sp_' + file).show(); +// } +//} -function shrunk_callback(data, status, xhr) -{ - //console.log("Status: %s", status); - //console.dir(data); - $.each(data, insert_shrunk); -} +//function shrunk_callback(data, status, xhr) +//{ +// //console.log("Status: %s", status); +// //console.dir(data); +// $.each(data, insert_shrunk); +//} function delete_callback(file, dir, id) { @@ -364,7 +364,6 @@ function preparedmenu(el, menu) $(document).ready(function() { dir = $('#dir').text(); -mediaroot = $('#mediaroot').text(); var menuclick = function(action, el, pos) { @@ -757,8 +756,8 @@ var dmenuclick = function(action, el, pos) folder_size_callback); // Flag shrunk recordings - $.getJSON('/browse/shrunk.jim?dir=' + encodeURIComponent(dir), - shrunk_callback); +// $.getJSON('/browse/shrunk.jim?dir=' + encodeURIComponent(dir), +// shrunk_callback); // Flag folders with unwatched items $.getJSON('/browse/newdir.jim?dir=' + encodeURIComponent(dir), diff --git a/var/mongoose/html/browse/shrunk.jim b/var/mongoose/html/browse/shrunk.jim index 0b98857..09b274a 100755 --- a/var/mongoose/html/browse/shrunk.jim +++ b/var/mongoose/html/browse/shrunk.jim @@ -2,18 +2,29 @@ package require cgi source /mod/webif/lib/setup +require ts.class httpheader "application/json" -set dir [cgi_get dir "/media/My Video/Children"] +set dir [cgi_get dir "-"] +if {$dir eq "-"} exit puts "{" foreach file [readdir -nocomplain $dir] { if {![string match {*.ts} $file]} { continue } - set xfile [file rootname $file] - if {[catch {set eit [exec /mod/bin/stripts -cq "$dir/$xfile"]}]} { - continue + if {[catch {set ts [ts fetch "$dir/$file"]}]} continue + + set eit 1 + if {[$ts flag "Shrunk"]} { set eit 0 } + + if {$eit} { + set xfile [file rootname $file] + if {[catch {set eit [\ + exec /mod/bin/stripts -cq "$dir/$xfile"]}]} { + continue + } + if {!$eit} { $ts set_shrunk } } puts " \"$file\": $eit," diff --git a/var/mongoose/html/browse/strip/execute.jim b/var/mongoose/html/browse/strip/execute.jim index 85982b0..a524f5a 100755 --- a/var/mongoose/html/browse/strip/execute.jim +++ b/var/mongoose/html/browse/strip/execute.jim @@ -43,6 +43,7 @@ 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" +exec /mod/bin/hmt "+shrunk" "$dir/$newname.hmt" set striptime [expr [expr [clock milliseconds] - $stripstart] / 1000.0] puts "Time taken: $striptime" diff --git a/var/mongoose/lib/bin/auto b/var/mongoose/lib/bin/auto index 1fe2288..cec8e73 100755 --- a/var/mongoose/lib/bin/auto +++ b/var/mongoose/lib/bin/auto @@ -134,6 +134,12 @@ proc do_shrink {ts} { } set file [file rootname [$ts get file]] + + if {[$ts inuse]} { + log " $file - in use." 1 + return + } + if {[catch { set perc [exec /mod/bin/stripts -aq $file] } msg]} { @@ -151,10 +157,6 @@ proc do_shrink {ts} { $ts set_shrunk return } - if {[$ts inuse]} { - log " In use." 1 - return - } set size [$ts size] dsc $size startclock @@ -227,6 +229,8 @@ proc do_decrypt {ts} { } set size [$ts size] dsc $size + set flagfile "$tmp/decrypting.$bfile" + exec /mod/bin/busybox/touch $flagfile startclock log " DECRYPT: $rfile" 1 log " DLNA: $url" 1 @@ -234,6 +238,7 @@ proc do_decrypt {ts} { if {[file size $file] != [file size "$tmp/$bfile"]} { log " File size mismatch." 1 + file delete $flagfile return } @@ -264,6 +269,7 @@ proc do_decrypt {ts} { tdelete "$rfile.encrypted" } log "Done... [endclock $size]" 1 + file delete $flagfile } proc do_mpg {ts} { diff --git a/var/mongoose/lib/bin/strip-update b/var/mongoose/lib/bin/strip-update new file mode 100755 index 0000000..0b43191 --- /dev/null +++ b/var/mongoose/lib/bin/strip-update @@ -0,0 +1,59 @@ +#!/mod/bin/jimsh + +source /mod/webif/lib/setup +require system.class ts.class + +proc do_shrink {ts} { + if {[$ts flag "Shrunk"]} { return } + + set file [file rootname [$ts get file]] + + if {[$ts inuse]} { return } + + if {[catch { + set perc [exec /mod/bin/stripts -aq $file] + } msg]} { + return + } + + if {[string match {*%} $perc]} { + set perc [string range $perc 0 end-1] + } else { + set perc 0 + } + + if {$perc == 0} { + puts " Flagging $file as shrunk..." + $ts set_shrunk + } +} + +proc entries {dir callback} { + foreach entry [readdir -nocomplain $dir] { + if {![string match {*.ts} $entry} continue + if {[catch {set ts [ts fetch "$dir/$entry"]}]} continue + if {$ts == 0} continue + $callback $ts + } +} + +proc scan {dir} { + puts "Scanning $dir..." + file stat "$dir/" st + if {$st(dev) != $::rootdev} { return } + + entries $dir do_shrink + + foreach entry [readdir -nocomplain $dir] { + if {[file isdirectory "$dir/$entry"]} { + scan "$dir/$entry" + } + } +} + +set root [system mediaroot] +file stat "$root/" rootstat +set rootdev $rootstat(dev) + +scan $root +