forked from hummypkg/sweeper
1.0.4
This commit is contained in:
parent
979a717da5
commit
ef6139671f
@ -1,7 +1,7 @@
|
|||||||
Package: sweeper
|
Package: sweeper
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Section: misc
|
Section: misc
|
||||||
Version: 1.0.3
|
Version: 1.0.4
|
||||||
Architecture: mipsel
|
Architecture: mipsel
|
||||||
Maintainer: af123@hummypkg.org.uk
|
Maintainer: af123@hummypkg.org.uk
|
||||||
Depends: webif(>=1.0.5-3)
|
Depends: webif(>=1.0.5-3)
|
||||||
|
@ -6,6 +6,36 @@ proc ::sweeper::unknown {cmd args} {
|
|||||||
return 0
|
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} {
|
proc ::sweeper::intcomp {ref val} {
|
||||||
lassign $val op num
|
lassign $val op num
|
||||||
|
|
||||||
@ -81,11 +111,23 @@ proc ::sweeper::action {ts cmds} {
|
|||||||
|
|
||||||
log "ACTION: $cmd\($rest)" 2
|
log "ACTION: $cmd\($rest)" 2
|
||||||
|
|
||||||
case $cmd {
|
switch $cmd {
|
||||||
preserve { return 1 }
|
preserve { return 1 }
|
||||||
|
move -
|
||||||
movecreate {
|
movecreate {
|
||||||
|
set rest [::sweeper::expand $ts $rest]
|
||||||
if {![file isdirectory "$root/$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
|
log "Moving [$ts get file] to $rest" 0
|
||||||
foreach f [$ts fileset] {
|
foreach f [$ts fileset] {
|
||||||
@ -97,21 +139,6 @@ proc ::sweeper::action {ts cmds} {
|
|||||||
}
|
}
|
||||||
return 1
|
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
|
return 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user