use file size over file stat, add mp3 type preference

git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1814 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
hummypkg 2014-03-03 14:00:46 +00:00
parent ceccfd9c1d
commit 9fd84a8938
11 changed files with 73 additions and 27 deletions

View File

@ -1,10 +1,10 @@
Package: webif
Priority: optional
Section: web
Version: 1.0.9-6
Version: 1.0.10
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif-channelicons(>=1.1.9),mongoose(>=3.0.11),jim(>=0.75),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.13),hmt(>=1.1.14),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.05),ffmpeg,id3v2,multienv(>=1.6)
Depends: webif-channelicons(>=1.1.9),mongoose(>=3.0.11),jim(>=0.75-1),jim-oo,jim-sqlite3(>=0.75),jim-cgi(>=0.7),jim-binary(>=0.75),service-control(>=1.2),busybox(>=1.20.2-1),lsof,epg(>=1.0.13),hmt(>=1.1.14),ssmtp,anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.0.2),webif-charts(>=1.2),stripts(>=1.2.5-3),smartmontools,tmenu(>=1.05),ffmpeg,id3v2,multienv(>=1.6)
Suggests:
Description: An evolving web interface for the Humax.
Tags: http://hummy.tv/forum/threads/4659/

View File

@ -48,6 +48,7 @@ set xepghours [$settings xepghours]
if {$xepghours == 0} { set xepghours 4 }
set genrededup [$settings genrededup]
set autolog [$settings autolog]
set audiomp3 [$settings audiomp3]
# Handle updates
@ -95,6 +96,7 @@ handle_int_update chanchangenc $chanchangenc \
handle_int_update nounwatchedcount $nounwatchedcount "Disable unwatched count"
handle_int_update genrededup $genrededup "Genre search dedup"
handle_int_update autolog $autolog "Auto-processing log level"
handle_int_update audiomp3 $audiomp3 "MP3 type"
set acluser [cgi_get acluser "-"]
set aclpass [cgi_get aclpass "-"]
@ -199,7 +201,7 @@ puts "<option value=1"
if {$autolog == 1} { puts " selected" }
puts ">Actions, errors and scan information\n"
puts "<option value=2"
if {$autolog == 1} { puts " selected" }
if {$autolog == 2} { puts " selected" }
puts ">Debugging information\n"
puts "
</select>
@ -212,6 +214,30 @@ puts "
</tr>
"
puts -nonewline "
<tr>
<form class=auto id=audiomp3 method=get action=$env(REQUEST_URI)>
<th class=key>Audio extraction type</th>
<td><select id=audiomp3 name=audiomp3
class=\"text ui-widget-content ui-corner-all\">
"
puts "<option value=0"
if {$audiomp3 == 0} { puts " selected" }
puts ">[$settings audiomp3descr 0] - very fast but less compatible.\n"
puts "<option value=1"
if {$audiomp3 == 1} { puts " selected" }
puts ">[$settings audiomp3descr 1] - around 60 times slower.\n"
puts "
</select>
<small>
<input name=audiomp3 value=\"set\" type=submit>
</small>
<div id=audiomp3_output></div>
</td>
</form>
</tr>
"
puts "
</table></fieldset></div>

View File

@ -3,18 +3,20 @@
package require sqlite3
package require cgi
source /mod/webif/lib/setup
require ts.class system.class
require ts.class system.class settings.class
jqplugin progressbar
jscss audio.js
header
set s [settings]
set type [$s audiomp3descr [$s audiomp3]]
set rfile [cgi_get file]
set ts [ts fetch $rfile]
set dir [file dirname $rfile]
set len [$ts duration 1]
puts "
<fieldset class=cleft>
@ -31,7 +33,7 @@ puts "
></span>
<div id=audiodiv style=\"padding: 1em\">
<button id=audioit>Perform audio extraction</button>
<button id=audioit>Perform audio extraction - $type</button>
</div>
<div id=progressdiv class=hidden>

View File

@ -3,7 +3,7 @@
package require sqlite3
package require cgi
source /mod/webif/lib/setup
require ts.class system.class
require ts.class system.class settings.class
httpheader
@ -18,9 +18,15 @@ set base [file rootname $rfile]
set shname [file tail $base]
puts "Processing $shname"
puts [exec /mod/bin/ffmpeg -y -benchmark -v 0 \
-i $rfile -f mp3 \
-vn -acodec copy "${base}.mp3"]
set cmd [list ffmpeg -y -benchmark -v 0 -i "$rfile" -f mp3 -vn]
if {![[settings] audiomp3]} {
lappend cmd -acodec copy
}
lappend cmd "${base}.mp3"
#puts "$cmd"
puts [exec {*}$cmd]
if {[system pkginst id3v2]} {
puts [exec /mod/bin/id3v2 \

View File

@ -11,8 +11,7 @@ set type [cgi_get type]
if {$file == 0} exit
file stat $file st
set sz [pretty_size $st(size)]
set sz [pretty_size [file size $file]]
if {$type eq "ts"} {
require epg.class ts.class

View File

@ -103,8 +103,7 @@ proc entry {file} {{i 0}} {
set ext [string tolower [file extension $file]]
if {$ext in $::ignore || $ext ni $::include} { return }
file stat $file st
set rsz $st(size)
set rsz [file size $file]
set sz [pretty_size $rsz]
set base [file rootname $file]

View File

@ -54,8 +54,7 @@ proc entry {file {i 0}} {
set ext [file extension $file]
if {$ext in $::ignore || $ext ni $::include} { return }
file stat $file st
set rsz $st(size)
set rsz [file size $file]
set sz [pretty_size $rsz]
set base [file rootname $file]
@ -192,9 +191,9 @@ proc s_time {a b} {
}
if {[catch {file stat $a l}]} { return 0}
set at $l(ctime)
set at $l(mtime)
if {[catch {file stat $b l}]} { return 0}
set bt $l(ctime)
set bt $l(mtime)
if {$at < $bt} { return -1 }
if {$at > $bt} { return 1 }

View File

@ -4,7 +4,9 @@ source /mod/webif/lib/setup
require lock system.class ts.class tdelete pretty_size browse.class \
safe_delete settings.class plugin
set loglevel [[settings] autolog]
set settings [settings]
set loglevel [$settings autolog]
set audiomp3 [$settings audiomp3]
if {![acquire_lock webif_auto]} {
puts "Cannot acquire exclusive lock, terminating."
@ -443,12 +445,14 @@ proc do_mp3 {ts} {
dsc [$ts size]
log " MP3: $file" 0
log " Converting..." 0
log " Converting... [$::settings audiomp3descr $::audiomp3]" 0
if {[catch {
foreach line [split \
[exec nice -n 19 /mod/bin/ffmpeg -y -benchmark -v 0 \
-i $file.ts \
-f mp3 -vn -acodec copy $tmp/mp3.mp3] "\n"] {
set cmd [list nice -n 19 \
/mod/bin/ffmpeg -y -benchmark -v 0 -i "$file.ts" \
-f mp3 -vn]
if {!$::audiomp3} { lappend cmd -acodec copy }
lappend cmd "$tmp/mp3.mp3"
foreach line [split [exec {*}$cmd] "\n"] {
log $line 0
}
} msg]} {

View File

@ -7,7 +7,7 @@ if {![exists -proc pretty_size]} {
set size $($size / 1024.0)
}
set size [format "%.2f" $size]
set size [string trimright [format "%.2f" $size] "0."]
return "$size [lindex $units $i]"
}

View File

@ -32,6 +32,7 @@ class settings {
genrededup 0
autolog 0
changechangenc 0
audiomp3 0
}
settings method hostname {{name ""}} {
@ -197,6 +198,17 @@ settings method autolog {{level -1}} {
return [$self _nval_setting autolog $level]
}
settings method audiomp3 {{val -1}} {
return [$self _nval_setting audiomp3 $val]
}
settings method audiomp3descr {val} {
switch $val {
1 { return "MPEG-1 Audio Layer III (MP3)" }
default { return "MPEG-1 Audio Layer II (MP2)" }
}
}
settings method channel_groups {} {
set ret ""
set db [sqlite3.open /var/lib/humaxtv/setup.db]

View File

@ -34,8 +34,7 @@ ts method duration {{raw 0}} {
}
ts method size {} {
file stat $file st
return $st(size)
return [file size $file]
}
ts method _parse {line} {