improve status with centralised operation tracking and plugin support
git-svn-id: file:///root/webif/svn/pkg/webif/trunk@3339 2a923420-c742-0410-a762-8d5b09965624
This commit is contained in:
parent
46a539c739
commit
8cd924c8ac
@ -1,7 +1,7 @@
|
||||
Package: webif
|
||||
Priority: optional
|
||||
Section: web
|
||||
Version: 1.3.2-11
|
||||
Version: 1.3.2-12
|
||||
Architecture: mipsel
|
||||
Maintainer: af123@hpkg.tv
|
||||
Depends: tcpfix,webif-channelicons(>=1.1.24),lighttpd(>=1.4.39-1),jim(>=0.76-2),jim-oo,jim-sqlite3(>=0.76),jim-cgi(>=0.7-1),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.3),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.9),webif-charts(>=1.2-1),stripts(>=1.2.5-3),tmenu(>=1.08),ffmpeg,id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.95)
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require system.class findhsvc epg.class rsv.class
|
||||
require system.class findhsvc epg.class rsv.class plugin
|
||||
|
||||
set runmode cli
|
||||
if {[string match {*jim} $argv0]} { set runmode cgi }
|
||||
@ -32,8 +32,29 @@ if {[catch {set pid [exec pgrep -n humaxtv]}]} {
|
||||
|
||||
set exts {.ts .avi .mpg .mpeg .wmv .mkv .mp3 .mp4 .mov .hmt .m4v .m4a}
|
||||
|
||||
set statusops {
|
||||
decrypt { "Decrypting"
|
||||
"/img/decrypt.png style=\"padding: 0 0.2em 0 0.5em\""
|
||||
}
|
||||
mpg { "Extracting MPG"
|
||||
"/img/mpg.png style=\"padding: 0 0.2em 0 0.5em\""
|
||||
}
|
||||
mp3 { "Extracting MP3"
|
||||
"/img/mp3.png style=\"padding: 0 0.2em 0 0.5em\""
|
||||
}
|
||||
shrink { "Shrinking"
|
||||
"/img/compress.png style=\"padding: 0 0.2em 0 0.5em\""
|
||||
}
|
||||
}
|
||||
|
||||
proc register_statusop {op name icon} {
|
||||
set statusops($op) [list $name $icon]
|
||||
}
|
||||
|
||||
eval_plugins status
|
||||
|
||||
proc get_data {} {
|
||||
global pid exts opfile
|
||||
global pid exts
|
||||
|
||||
set ret {}
|
||||
if {[catch {set data \
|
||||
@ -75,8 +96,10 @@ proc get_data {} {
|
||||
}
|
||||
}
|
||||
}
|
||||
if {$opfile ne "" && $opfile ni $ret && [file exists $opfile]} {
|
||||
set ret($opfile) [file size $opfile]
|
||||
}
|
||||
foreach file [dict keys $::ops] {
|
||||
if {![dict exists $ret $file] && [file exists $file]} {
|
||||
set ret($file) [file size $file]
|
||||
}
|
||||
}
|
||||
return $ret
|
||||
@ -85,17 +108,26 @@ proc get_data {} {
|
||||
set play 0
|
||||
set rec 0
|
||||
set output {}
|
||||
set ops {}
|
||||
set model [system model]
|
||||
|
||||
set opfile ""
|
||||
if {[file exists "/mod/tmp/webif_auto/.op"]} {
|
||||
set fp [open "/mod/tmp/webif_auto/.op"]
|
||||
lassign [split [string trim [$fp read]] ":"] op opfile
|
||||
$fp close
|
||||
if {[system model] eq "HDR"} {
|
||||
set opfile [string map {/media/ /mnt/hd2/} $opfile]
|
||||
foreach opfile [glob -nocomplain -directory /tmp -tails -- ".bgop.*"] {
|
||||
set op [string range $opfile 6 end]
|
||||
lassign [split [file read "/tmp/$opfile"] "\n"] file oppid
|
||||
if {$model eq "HDR"} {
|
||||
set file [string map {/media/ /mnt/hd2/} $file]
|
||||
}
|
||||
debug "OP: $op - $opfile"
|
||||
|
||||
# Check that the lock is still held
|
||||
if {![system checkop $op]} {
|
||||
debug "$op/$file/$oppid - process not found."
|
||||
file delete "/tmp/$opfile"
|
||||
} else {
|
||||
set ops($file) $op
|
||||
}
|
||||
}
|
||||
|
||||
debug "OPS: $ops"
|
||||
|
||||
set data {}
|
||||
if {$type eq "full"} {
|
||||
@ -132,8 +164,8 @@ if {[llength $data]} {
|
||||
foreach file [array names data] {
|
||||
set bname [file rootname [file tail $file]]
|
||||
|
||||
if {$file eq $opfile} {
|
||||
set mode $op
|
||||
if {[dict exists $ops $file]} {
|
||||
set mode $ops($file)
|
||||
} elseif {$data($file) == -1} {
|
||||
set mode chase
|
||||
} elseif {$rr} {
|
||||
@ -168,25 +200,13 @@ if {[llength $data]} {
|
||||
set mode "Playing"
|
||||
set icon "745_1_10_Video_2Live.png"
|
||||
}
|
||||
dec {
|
||||
set mode "Decrypting"
|
||||
set icon "/img/decrypt.png "
|
||||
append icon "style=\"padding: 0 0.2em 0 0.5em\""
|
||||
default {
|
||||
if {[dict exists $statusops $mode]} {
|
||||
lassign $statusops($mode) mode icon
|
||||
} else {
|
||||
set mode "Unknown"
|
||||
set icon "/img/blank.gif"
|
||||
}
|
||||
mpg {
|
||||
set mode "Extracting MPG"
|
||||
set icon "/img/mpg.png "
|
||||
append icon "style=\"padding: 0 0.2em 0 0.5em\""
|
||||
}
|
||||
mp3 {
|
||||
set mode "Extracting MP3"
|
||||
set icon "/img/mp3.png "
|
||||
append icon "style=\"padding: 0 0.2em 0 0.5em\""
|
||||
}
|
||||
shrink {
|
||||
set mode "Shrinking"
|
||||
set icon "/img/compress.png "
|
||||
append icon "style=\"padding: 0 0.2em 0 0.5em\""
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,9 @@ if {![[settings] audiomp3]} {
|
||||
lappend cmd "${base}.mp3"
|
||||
|
||||
#puts "$cmd"
|
||||
system startop mp3 $rfile
|
||||
puts [exec {*}$cmd]
|
||||
system endop mp3
|
||||
|
||||
if {[system pkginst id3v2]} {
|
||||
puts [exec /mod/bin/id3v2 \
|
||||
|
@ -38,7 +38,9 @@ if {[file exists "$origdir/$shname.ts"]} {
|
||||
exit
|
||||
}
|
||||
|
||||
system startop decrypt $rfile
|
||||
exec wget -O "$rfile.decrypting" $url
|
||||
system endop decrypt
|
||||
|
||||
puts "Moving recording to $origdir"
|
||||
|
||||
|
@ -18,10 +18,12 @@ set base [file rootname $rfile]
|
||||
set shname [file tail $base]
|
||||
puts "Processing $shname"
|
||||
|
||||
system startop mpg $rfile
|
||||
puts [exec /mod/bin/ffmpeg -y -benchmark -v 0 \
|
||||
-i $rfile \
|
||||
-map 0:0 -map 0:1 \
|
||||
-vcodec copy -acodec copy "${base}.mpg"]
|
||||
endop mpg
|
||||
|
||||
set xtime [expr [expr [clock milliseconds] - $xstart] / 1000.0]
|
||||
puts "Time taken: $xtime"
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require ts.class pretty_size
|
||||
require system.class ts.class pretty_size
|
||||
|
||||
httpheader
|
||||
|
||||
@ -35,11 +35,12 @@ foreach ext $tsgroup {
|
||||
file rename "$base.$ext" "${origdir}/$tail.$ext"
|
||||
}
|
||||
|
||||
system startop shrink $rfile
|
||||
puts [exec /mod/bin/stripts \
|
||||
"$origdir/$shname" \
|
||||
"$dir/$shname" \
|
||||
]
|
||||
|
||||
system endop shrink
|
||||
|
||||
# Set the file time to match the old file
|
||||
ts touchgroup "$dir/$shname.ts" "$origdir/$shname.ts"
|
||||
|
@ -197,18 +197,6 @@ proc dorecalc {dir} {
|
||||
incr recalc -1
|
||||
}
|
||||
|
||||
proc startop {op file} {
|
||||
global tmp
|
||||
set fp [open "$tmp/.op" "w"]
|
||||
puts $fp "$op:$file"
|
||||
$fp close
|
||||
}
|
||||
|
||||
proc endop {} {
|
||||
global tmp
|
||||
file delete "$tmp/.op"
|
||||
}
|
||||
|
||||
proc dedup {dir {flag ""}} {
|
||||
log "DEDUP: \[$dir]" 2
|
||||
loop i 0 1 {
|
||||
@ -267,7 +255,7 @@ proc do_shrink {ts} {
|
||||
}
|
||||
set size [$ts size]
|
||||
dsc $size
|
||||
startop shrink [$ts get file]
|
||||
system startop shrink [$ts get file]
|
||||
runplugin preshrink $ts
|
||||
startclock
|
||||
log " SHRINK: $file" 0
|
||||
@ -282,7 +270,7 @@ proc do_shrink {ts} {
|
||||
} msg]} {
|
||||
log "Error during shrink: $msg" 0
|
||||
system notify "$file - auto-shrink - error $msg."
|
||||
endop
|
||||
system endop shrink
|
||||
return
|
||||
}
|
||||
|
||||
@ -313,7 +301,7 @@ proc do_shrink {ts} {
|
||||
log "Done... [endclock $size]" 0
|
||||
lappend processed_files [$ts get file]
|
||||
runplugin postshrink $ts
|
||||
endop
|
||||
system endop shrink
|
||||
}
|
||||
|
||||
proc do_decrypt {ts} {
|
||||
@ -375,7 +363,7 @@ proc do_decrypt {ts} {
|
||||
set size [$ts size]
|
||||
dsc $size
|
||||
runplugin predecrypt $ts
|
||||
startop dec $file
|
||||
system startop decrypt $file
|
||||
startclock
|
||||
log " DECRYPT: $rfile" 0
|
||||
log " DLNA: $url" 0
|
||||
@ -387,7 +375,7 @@ proc do_decrypt {ts} {
|
||||
if {[file size $file] != [file size "$tmp/$bfile"]} {
|
||||
log " $file - File size mismatch." 0
|
||||
file tdelete "$tmp/$bfile"
|
||||
endop
|
||||
system endop decrypt
|
||||
return
|
||||
}
|
||||
|
||||
@ -396,7 +384,7 @@ proc do_decrypt {ts} {
|
||||
if {[inuse $ts]} {
|
||||
log " $file - In use."
|
||||
file tdelete "$tmp/$bfile"
|
||||
endop
|
||||
system endop decrypt
|
||||
return
|
||||
}
|
||||
|
||||
@ -411,7 +399,7 @@ proc do_decrypt {ts} {
|
||||
log " $file - File did not decrypt properly." 0
|
||||
system notify "$file - auto-decrypt failed."
|
||||
file tdelete "$tmp/$bfile"
|
||||
endop
|
||||
system endop decrypt
|
||||
return
|
||||
}
|
||||
|
||||
@ -447,7 +435,7 @@ proc do_decrypt {ts} {
|
||||
lappend processed_files [$ts get file]
|
||||
$ts unflag "ODEncrypted"
|
||||
runplugin postdecrypt $ts
|
||||
endop
|
||||
system endop decrypt
|
||||
}
|
||||
|
||||
proc do_mpg {ts} {
|
||||
@ -474,7 +462,7 @@ proc do_mpg {ts} {
|
||||
log " $file - In use."
|
||||
return
|
||||
}
|
||||
startop mpg [$ts get file]
|
||||
system startop mpg [$ts get file]
|
||||
runplugin prempg $ts
|
||||
dsc [$ts size]
|
||||
|
||||
@ -491,7 +479,7 @@ proc do_mpg {ts} {
|
||||
} msg]} {
|
||||
log "Error during mpg extract: $msg" 0
|
||||
system notify "$file - auto-mpg - error $msg."
|
||||
endop
|
||||
system endop mpg
|
||||
return
|
||||
}
|
||||
|
||||
@ -499,7 +487,7 @@ proc do_mpg {ts} {
|
||||
file rename $tmp/mpg.mpg $file.mpg
|
||||
lappend processed_files [$ts get file]
|
||||
runplugin postmpg $ts
|
||||
endop
|
||||
system endop mpg
|
||||
}
|
||||
|
||||
proc do_mp3 {ts} {
|
||||
@ -527,7 +515,7 @@ proc do_mp3 {ts} {
|
||||
log " $file - In use."
|
||||
return
|
||||
}
|
||||
startop mp3 [$ts get file]
|
||||
system startop mp3 [$ts get file]
|
||||
runplugin premp3 $ts
|
||||
dsc [$ts size]
|
||||
|
||||
@ -545,7 +533,7 @@ proc do_mp3 {ts} {
|
||||
} msg]} {
|
||||
log "Error during mp3 extract: $msg" 0
|
||||
system notify "$file - auto-mp3 - error $msg."
|
||||
endop
|
||||
system endop mp3
|
||||
return
|
||||
}
|
||||
|
||||
@ -562,7 +550,7 @@ proc do_mp3 {ts} {
|
||||
file rename $tmp/mp3.mp3 $file.mp3
|
||||
lappend processed_files [$ts get file]
|
||||
runplugin postmp3 $ts
|
||||
endop
|
||||
system endop mp3
|
||||
}
|
||||
|
||||
proc entries {dir callback {flag ""}} {
|
||||
|
@ -743,3 +743,55 @@ proc {system has} {comp} {
|
||||
return 0
|
||||
}
|
||||
|
||||
set ::system::ops {}
|
||||
|
||||
proc {system checkop} {op} {
|
||||
if {![regexp -nocase -- {^[a-z0-9]+$} $op]} { return 0 }
|
||||
if {[catch {set fp [open "/tmp/.bgop.$op" "a"]}]} {
|
||||
return 0
|
||||
}
|
||||
set ret 1
|
||||
if {[$fp lock]} {
|
||||
$fp unlock
|
||||
set ret 0
|
||||
}
|
||||
$fp close
|
||||
return $ret
|
||||
}
|
||||
|
||||
proc {system startop} {op file} {
|
||||
if {![regexp -nocase -- {^[a-z0-9]+$} $op]} { return 0 }
|
||||
if {[dict exists $::system::ops $op]} {
|
||||
system endop $op
|
||||
}
|
||||
if {[catch {
|
||||
set fp [open "/tmp/.bgop.$op" "a"]
|
||||
if {[$fp lock]} {
|
||||
$fp puts "$file\n[pid]"
|
||||
$fp flush
|
||||
set ::system::ops($op) $fp
|
||||
} else {
|
||||
$fp close
|
||||
error "Could not lock op file."
|
||||
}
|
||||
}]} { return 0 }
|
||||
return 1
|
||||
}
|
||||
|
||||
proc {system endop} {op} {
|
||||
if {![regexp -nocase -- {^[a-z0-9]+$} $op]} { return 0 }
|
||||
if {[dict exists $::system::ops $op]} {
|
||||
catch {
|
||||
set fp $::system::ops($op)
|
||||
$fp unlock
|
||||
$fp close
|
||||
}
|
||||
dict unset ::system::ops $op
|
||||
}
|
||||
if {[file exists "/tmp/.bgop.$op"]} {
|
||||
file delete "/tmp/.bgop.$op"
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user