diff --git a/CONTROL/control b/CONTROL/control index cf59f4e..c3d8831 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: sweeper Priority: optional Section: misc -Version: 1.0.3 +Version: 1.0.4 Architecture: mipsel Maintainer: af123@hummypkg.org.uk Depends: webif(>=1.0.5-3) diff --git a/webif/plugin/sweeper/auto.hook b/webif/plugin/sweeper/auto.hook index c453f8e..c945a72 100644 --- a/webif/plugin/sweeper/auto.hook +++ b/webif/plugin/sweeper/auto.hook @@ -6,6 +6,36 @@ proc ::sweeper::unknown {cmd args} { return 0 } +proc ::sweeper::expand {ts str} { + if {[string first "%" $str] == -1} { + return $str + } + + set glist [ts genrelist] + set tsg [$ts get genre] + if {![dict exists $glist $tsg]} { + set genre "Unknown" + } else { + set genre [lindex $glist($tsg) 0] + } + + set timestamp [clock format [$ts get start] -format "%Y%m%d%H%M%S"] + + set map [list \ + "%title" [$ts get title] \ + "%genre" $genre \ + "%definition" [$ts get definition] \ + "%lcn" [$ts get channel_num] \ + "%channel" [$ts get channel_name] \ + "%duration" [$ts duration] \ + "%timestamp" $timestamp \ + ] + + set ret [string map $map $str] + log " Expanded to \[$ret]" 2 + return $ret +} + proc ::sweeper::intcomp {ref val} { lassign $val op num @@ -81,11 +111,23 @@ proc ::sweeper::action {ts cmds} { log "ACTION: $cmd\($rest)" 2 - case $cmd { + switch $cmd { preserve { return 1 } + move - movecreate { + set rest [::sweeper::expand $ts $rest] if {![file isdirectory "$root/$rest"]} { - file mkdir "$root/$rest" + if {$cmd eq "move"} { + log " ... No such directory $root/$rest" 2 + return 1 + } + system mkdir_p "$root/$rest" + if {![file isdirectory "$root/$rest"]} { + log "Error creating directory $root/$rest" 1 + return 1 + } else { + log " ... created directory $root/$rest" 2 + } } log "Moving [$ts get file] to $rest" 0 foreach f [$ts fileset] { @@ -97,21 +139,6 @@ proc ::sweeper::action {ts cmds} { } 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 - } - return 1 - } } return 0 }