forked from hummypkg/sweeper
update
This commit is contained in:
parent
267c4627a8
commit
979a717da5
1
CONTROL/conffiles
Normal file
1
CONTROL/conffiles
Normal file
@ -0,0 +1 @@
|
||||
etc/sweeper.conf
|
@ -1,8 +1,8 @@
|
||||
Package: sweeper
|
||||
Priority: optional
|
||||
Section: misc
|
||||
Version: 1.0.2
|
||||
Version: 1.0.3
|
||||
Architecture: mipsel
|
||||
Maintainer: af123@hummypkg.org.uk
|
||||
Depends: webif(>=1.0.3-3)
|
||||
Depends: webif(>=1.0.5-3)
|
||||
Description: Automatically manage single recording files.
|
||||
|
4
etc/sweeper.conf
Normal file
4
etc/sweeper.conf
Normal file
@ -0,0 +1,4 @@
|
||||
# Example to move all one-off recordings into a directory called 'misc'
|
||||
# and create it if it doesn't already exist. Remove the # from the start
|
||||
# of the next line to enable it.
|
||||
#action {movecreate "misc"}
|
@ -30,7 +30,7 @@ proc ::sweeper::flag {ts flag} {
|
||||
return [$ts flag $flag]
|
||||
}
|
||||
|
||||
proc ::sweeper::channum {ts num} {
|
||||
proc ::sweeper::lcn {ts num} {
|
||||
return [::sweeper::intcomp [$ts get channel_num] $num]
|
||||
}
|
||||
|
||||
@ -83,12 +83,29 @@ proc ::sweeper::action {ts cmds} {
|
||||
|
||||
case $cmd {
|
||||
preserve { return 1 }
|
||||
movecreate {
|
||||
if {![file isdirectory "$root/$rest"]} {
|
||||
file mkdir "$root/$rest"
|
||||
}
|
||||
log "Moving [$ts get file] to $rest" 0
|
||||
foreach f [$ts fileset] {
|
||||
log " ....... $f"
|
||||
file rename $f "$root/$rest/[file tail $f]"
|
||||
if {$rest ni $::sweeper::recalc} {
|
||||
lappend ::sweeper::recalc $rest
|
||||
}
|
||||
}
|
||||
return 1
|
||||
}
|
||||
move {
|
||||
if {[file isdirectory "$root/$rest"]} {
|
||||
log "Moving [$ts get file] to $rest" 0
|
||||
foreach f [$ts fileset] {
|
||||
log " ....... $f"
|
||||
file rename $f "$root/$rest/[file tail $f]"
|
||||
if {$rest ni $::sweeper::recalc} {
|
||||
lappend ::sweeper::recalc $rest
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log " ... No such directory $root/$rest" 2
|
||||
@ -102,6 +119,8 @@ proc ::sweeper::action {ts cmds} {
|
||||
proc ::sweeper::runrule {ts rule} {
|
||||
log "Processing \[$rule]" 2
|
||||
|
||||
if {[string index $rule 0] eq "#" || [llength $rule] < 2} { return 0 }
|
||||
|
||||
while {[llength $rule] > 1} {
|
||||
set rule [lassign $rule cmd arg]
|
||||
log " $cmd\($arg)" 2
|
||||
@ -123,6 +142,8 @@ proc ::sweeper::apply {dir cf} {
|
||||
return
|
||||
}
|
||||
|
||||
set ::sweeper::recalc {}
|
||||
|
||||
set rules [split [read $fp] "\n"]
|
||||
$fp close
|
||||
|
||||
@ -154,6 +175,10 @@ proc ::sweeper::apply {dir cf} {
|
||||
if {[::sweeper::runrule $ts $rule]} break
|
||||
}
|
||||
}
|
||||
|
||||
foreach dir $::sweeper::recalc {
|
||||
ts resetnew "$::root/$dir"
|
||||
}
|
||||
}
|
||||
|
||||
proc ::sweeper::scan {args} {
|
||||
|
112
webif/plugin/sweeper/edit.jim
Executable file
112
webif/plugin/sweeper/edit.jim
Executable file
@ -0,0 +1,112 @@
|
||||
#!/mod/bin/jimsh
|
||||
|
||||
package require cgi
|
||||
source /mod/webif/lib/setup
|
||||
require system.class
|
||||
source helper
|
||||
|
||||
set dir [cgi_get dir ""]
|
||||
|
||||
if {$dir eq ""} {
|
||||
set dir [system mediaroot]
|
||||
set cf "/mod/etc/sweeper.conf"
|
||||
} else {
|
||||
set cf "[system mediaroot]/$dir/.rulelist"
|
||||
}
|
||||
|
||||
header
|
||||
|
||||
# Load rules
|
||||
if {![file exists $cf]} {
|
||||
set rules {}
|
||||
} else {
|
||||
if {[catch {set fp [open $cf r]} msg]} {
|
||||
log "Error opening sweeper ruleset ($cf), $msg" 0
|
||||
exit
|
||||
}
|
||||
set rules [split [$fp read] "\n"]
|
||||
}
|
||||
|
||||
puts "
|
||||
<link rel=stylesheet type=text/css href=style.css>
|
||||
<script type=text/javascript src=script.js></script>
|
||||
<fieldset width=100%>
|
||||
<legend>Sweeper rules for $dir</legend>
|
||||
"
|
||||
|
||||
set lcomment ""
|
||||
proc comment {id comment} {
|
||||
set ::lcomment $comment
|
||||
}
|
||||
|
||||
proc rule {id rule} {
|
||||
global clausedescr lcomment
|
||||
|
||||
if {$lcomment eq ""} { set lcomment "Unnamed rule" }
|
||||
|
||||
puts "<div id=\"rule_${id}\"><fieldset width=100%><legend>"
|
||||
|
||||
puts "<div id=\"comment_${id}\" class=comment>$lcomment"
|
||||
puts "<img class=editbutton src=/img/context/edit.png></div>"
|
||||
puts "<div id=\"comment_${id}_edit\" class=\"commentedit edit hidden\">
|
||||
<input id=\"${id}_comment\" name=\"${id}_comment\"
|
||||
value=\"$lcomment\" size=120 maxlength=255></div>"
|
||||
|
||||
set lcomment ""
|
||||
|
||||
puts "</legend><table class=\"keyval cleft\">"
|
||||
set c 0
|
||||
while {[llength $rule] > 1} {
|
||||
incr c
|
||||
set rule [lassign $rule cmd arg]
|
||||
if {$cmd eq "action"} break
|
||||
|
||||
if {[dict exists $clausedescr $cmd]} {
|
||||
set title $clausedescr($cmd)
|
||||
} else {
|
||||
set title [string totitle $cmd]
|
||||
}
|
||||
puts "<tr><th nowrap>$title</th><td>"
|
||||
puts "<div id=\"rule_${id}_${c}\">"
|
||||
set broken 0
|
||||
if {[catch {::display::$cmd $id $arg}]} {
|
||||
puts "<i>$arg</i>"
|
||||
set broken 1
|
||||
}
|
||||
if {!$broken} {
|
||||
puts "<img class=editbutton src=/img/context/edit.png>"
|
||||
puts "</div>"
|
||||
puts "<div id=\"rule_${id}_${c}_edit\"
|
||||
class=\"clauseedit edit\" hidden>"
|
||||
::edit::$cmd "rule_${id}_${c}" $arg
|
||||
}
|
||||
puts "</div>"
|
||||
puts "</td></tr>"
|
||||
}
|
||||
puts "</table><table class=\"keyval left padleft\">
|
||||
<tr><th>Action</th><td>"
|
||||
puts $arg
|
||||
puts "</td></tr></table>"
|
||||
puts "</fieldset></div>"
|
||||
}
|
||||
|
||||
set n 0
|
||||
foreach rule $rules {
|
||||
incr n
|
||||
if {[string index $rule 0] eq "#"} {
|
||||
if {[string index $rule 1] ne "#"} {
|
||||
comment $n [string range $rule 1 end]
|
||||
}
|
||||
continue
|
||||
}
|
||||
if {[llength $rule] < 2} continue
|
||||
rule $n $rule
|
||||
}
|
||||
|
||||
puts "
|
||||
</table>
|
||||
</fieldset>
|
||||
"
|
||||
|
||||
footer
|
||||
|
60
webif/plugin/sweeper/helper
Normal file
60
webif/plugin/sweeper/helper
Normal file
@ -0,0 +1,60 @@
|
||||
|
||||
proc ::edit::unknown {cmd args} {
|
||||
puts "Unhandled clause, $cmd"
|
||||
}
|
||||
|
||||
proc ::display::unknown {cmd args} {
|
||||
puts "Unhandled clause, $cmd"
|
||||
}
|
||||
|
||||
proc ::display::int {id val} {
|
||||
lassign $val op num
|
||||
|
||||
if {$num eq ""} {
|
||||
set num $op
|
||||
set op "=="
|
||||
}
|
||||
|
||||
puts [cgi_quote_html "$op $num"]
|
||||
}
|
||||
|
||||
proc ::edit::int {id val} {
|
||||
lassign $val op num
|
||||
|
||||
if {$num eq ""} {
|
||||
set num $op
|
||||
set op "=="
|
||||
}
|
||||
|
||||
puts "<select id=op_$id name=op_$id>"
|
||||
foreach pop {== > < >= <=} {
|
||||
set qpop [cgi_quote_html $pop]
|
||||
puts -nonewline "<option value=\"$qpop\""
|
||||
if {$op eq $pop} { puts -nonewline " selected" }
|
||||
puts ">$qpop"
|
||||
}
|
||||
puts "</select>"
|
||||
puts "<input name=\"num_$id\" type=number min=1 size=10 maxlength=10
|
||||
value=\"$num\">"
|
||||
}
|
||||
|
||||
proc ::display::substr {id val} {
|
||||
puts "contains '$val'"
|
||||
}
|
||||
|
||||
proc ::edit::substr {id val} {
|
||||
puts "<input name=\"str_$id\" type=text min=1
|
||||
size=40 maxlength=80 value=\"$val\">"
|
||||
}
|
||||
|
||||
set clausedescr {}
|
||||
|
||||
proc clause {id handler descr} {
|
||||
set ::clausedescr($id) $descr
|
||||
|
||||
alias ::display::$id ::display::$handler
|
||||
alias ::edit::$id ::edit::$handler
|
||||
}
|
||||
|
||||
source schema.def
|
||||
|
14
webif/plugin/sweeper/schema.def
Normal file
14
webif/plugin/sweeper/schema.def
Normal file
@ -0,0 +1,14 @@
|
||||
clause lcn int "Channel Number"
|
||||
clause duration int "Recording duration (in minutes)"
|
||||
clause schedduration int "Scheduled duration (in minutes)"
|
||||
clause size int "Recording size (in bytes)"
|
||||
#clause definition \
|
||||
# {select {{SD "Standard Definition"} {HD "High Definition"}} \
|
||||
# "Recording definition"
|
||||
clause title substr "Part of the recording title"
|
||||
clause synopsis substr "Part of the synopsis"
|
||||
clause guidance substr "Part of the guidance text"
|
||||
#clause flag tsflag "Recording flag"
|
||||
#clause genre tsgenre "Recording genre"
|
||||
#action preserve 0 "Leave recording alone"
|
||||
#action move folderpicker "Move recording to..."
|
18
webif/plugin/sweeper/script.js
Normal file
18
webif/plugin/sweeper/script.js
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
$(function() {
|
||||
|
||||
$('img.editbutton').hover(
|
||||
function() { $(this).css('cursor', 'pointer'); },
|
||||
function() { $(this).css('cursor', 'auto'); }
|
||||
).on('click', function(e) {
|
||||
e.preventDefault();
|
||||
var id = $(this).parent().attr('id');
|
||||
console.log('%O', id);
|
||||
$('.edit').hide('fast');
|
||||
$('#' + id + '_edit').show('slow');
|
||||
});;
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
11
webif/plugin/sweeper/style.css
Normal file
11
webif/plugin/sweeper/style.css
Normal file
@ -0,0 +1,11 @@
|
||||
|
||||
div.comment
|
||||
{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.padleft
|
||||
{
|
||||
padding-left: 3em;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user