diff --git a/CONTROL/control b/CONTROL/control index 8484457..193bc9c 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: webif Priority: optional Section: web -Version: 0.13.3-1 +Version: 0.13.3-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/var/mongoose/html/browse/assets.jim b/var/mongoose/html/browse/assets.jim index 1112095..f1ad784 100755 --- a/var/mongoose/html/browse/assets.jim +++ b/var/mongoose/html/browse/assets.jim @@ -23,8 +23,12 @@ if {[system pkginst ffmpeg]} { puts {
  • Extract Audio
  • Extract to MPG
  • +
  • Set Thumbnail
  • } } + +puts {
  • View Thumbnail
  • } + if $nicesplice { puts {
  • Crop
  • diff --git a/var/mongoose/html/browse/bmp.jim b/var/mongoose/html/browse/bmp.jim new file mode 100755 index 0000000..b48dd5f --- /dev/null +++ b/var/mongoose/html/browse/bmp.jim @@ -0,0 +1,19 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/webif/lib/setup +require cat + +set file [cgi_get file] +set file "[file rootname $file].thm" + +if {![file exists $file]} { + httpheader "text/plain" + puts "No such file, $file" + exit +} + +httpheader "image/bmp" +cat "/mod/webif/lib/bmpheader" +cat $file + diff --git a/var/mongoose/html/browse/index.jim b/var/mongoose/html/browse/index.jim index 4a9a77d..182ec5b 100755 --- a/var/mongoose/html/browse/index.jim +++ b/var/mongoose/html/browse/index.jim @@ -96,11 +96,13 @@ proc entry {file} {{i 0}} { set base [file rootname $file] + set thmok 0 if {$ext eq ".ts" && [file exists "${base}.nts"]} { set type ts set ts [ts fetch $file 1] set img Video_TS set omenu opt + if {[file exists "${base}.thm"]} { set thmok 1 } } elseif {$ext eq ".hmt"} { if {[file exists "${base}.ts"]} { continue } # Sole hmt file indicates failure to track. @@ -221,7 +223,7 @@ proc entry {file} {{i 0}} {
    diff --git a/var/mongoose/html/browse/script.js b/var/mongoose/html/browse/script.js index 4a4bb9a..f2e3335 100755 --- a/var/mongoose/html/browse/script.js +++ b/var/mongoose/html/browse/script.js @@ -178,6 +178,20 @@ function new_callback(file, type, id) $.get(url, function() { window.location.reload(true); }); } +function thumbnail_callback(file, type, id) +{ + var el = 'div.bf#' + id; + var results = el + ' .results'; + $(results) + .html('Generating thumbnail, ' + + 'please wait...') + .slideDown('slow') + .load('/browse/thumbnail.jim?file=' + file) + .delay(3000) + .slideUp('slow'); + $('div.bf#' + id + ' img.opt').attr('thmok', 1); +} + function rename_submit() { var s = $('#renameform_form').serialize(); @@ -257,6 +271,16 @@ function preparemenu(el, menu) else $(menu).disableContextMenuItems('#crop'); + if (el.attr('bx') > 0 && el.attr('odencd') == 0) + $(menu).enableContextMenuItems('#thm'); + else + $(menu).disableContextMenuItems('#thm'); + + if (el.attr('thmok') == 1) + $(menu).enableContextMenuItems('#vthm'); + else + $(menu).disableContextMenuItems('#vthm'); + $(menu).enableContextMenuItems('#strip'); if (el.attr('rsize') > 4294967296) @@ -424,6 +448,17 @@ var menuclick = function(action, el, pos) $('#renameform').dialog('open'); break; + case 'thm': + confirm_action('re-generate the thumbnail for', + thumbnail_callback, file, dir, id); + break; + + case 'vthm': + window.open('/browse/bmp.jim?file=' + file, 'hxwebifbmp', + 'height=78,width=140,toolbar=no,' + + 'scrollbars=no,menubar=no,location=no,titlebar=no'); + break; + case 'download': window.location.href = '/browse/download.jim?file=' + file + '&base=' + diff --git a/var/mongoose/html/browse/thumbnail.jim b/var/mongoose/html/browse/thumbnail.jim new file mode 100755 index 0000000..a5f1645 --- /dev/null +++ b/var/mongoose/html/browse/thumbnail.jim @@ -0,0 +1,13 @@ +#!/mod/bin/jimsh + +package require cgi +source /mod/webif/lib/setup +require ts.class + +httpheader + +set file [cgi_get file] +if {![catch {set ts [ts fetch $file]}]} { + $ts mkthm +} + diff --git a/var/mongoose/html/css/jquery.contextMenu.css b/var/mongoose/html/css/jquery.contextMenu.css index f0a49a2..e5e03f0 100644 --- a/var/mongoose/html/css/jquery.contextMenu.css +++ b/var/mongoose/html/css/jquery.contextMenu.css @@ -72,5 +72,6 @@ .contextMenu LI.mpg A { background-image: url(/img/context/mpg.png); } .contextMenu LI.mp3 A { background-image: url(/img/context/mp3.png); } .contextMenu LI.clock A { background-image: url(/img/context/clock.png); } +.contextMenu LI.thm A { background-image: url(/img/context/thumb.png); } diff --git a/var/mongoose/html/img/context/thumb.png b/var/mongoose/html/img/context/thumb.png new file mode 100644 index 0000000..a12a1d0 Binary files /dev/null and b/var/mongoose/html/img/context/thumb.png differ diff --git a/var/mongoose/lib/bmpheader b/var/mongoose/lib/bmpheader new file mode 100644 index 0000000..ccd1262 Binary files /dev/null and b/var/mongoose/lib/bmpheader differ diff --git a/var/mongoose/lib/cat b/var/mongoose/lib/cat index 229d6b3..4bce9c5 100644 --- a/var/mongoose/lib/cat +++ b/var/mongoose/lib/cat @@ -2,7 +2,7 @@ if {![exists -proc cat]} { proc cat {file} { if {[catch {set fp [open $file r}]} { return } - puts [read $fp] + puts -nonewline [read $fp] close $fp } } diff --git a/var/mongoose/lib/ts.class b/var/mongoose/lib/ts.class index cecdafc..b0d6b22 100644 --- a/var/mongoose/lib/ts.class +++ b/var/mongoose/lib/ts.class @@ -235,6 +235,22 @@ ts method dlnaloc {{urlbase 0}} { if {$url ne "" } { return [list $url $mime] } else { return {} } } +ts method mkthm {} { + if {!$bookmarks} { + puts "No bookmarks found." + return + } + lassign [$self bookmarks] s + puts "Grabbing thumbnail from $s second(s) in." + set bfile [file rootname $file] + puts [exec /mod/bin/ffmpeg -loglevel fatal -ss $s -i $file \ + -frames 1 -pix_fmt argb -vf vflip -s 140x78 \ + $bfile.bmp] + puts [exec /bin/dd if=$bfile.bmp of=$bfile.thm bs=54 skip=1] + tdelete $bfile.bmp + puts "Done." +} + proc {ts renamegroup} {from to} { global tsgroup