This commit is contained in:
hummypkg 2013-09-03 20:38:54 +00:00
parent 979a717da5
commit ef6139671f
2 changed files with 45 additions and 18 deletions

View File

@ -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)

View File

@ -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,24 +111,24 @@ 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"
}
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
}
}
if {$cmd eq "move"} {
log " ... No such directory $root/$rest" 2
return 1
}
move {
if {[file isdirectory "$root/$rest"]} {
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] {
log " ....... $f"
@ -107,9 +137,6 @@ proc ::sweeper::action {ts cmds} {
lappend ::sweeper::recalc $rest
}
}
} else {
log " ... No such directory $root/$rest" 2
}
return 1
}
}