forked from hummypkg/sweeper
add context help for actions, allow absolute paths
This commit is contained in:
parent
a67715928a
commit
270701873d
@ -1,9 +1,9 @@
|
||||
Package: sweeper
|
||||
Priority: optional
|
||||
Section: misc
|
||||
Version: 1.0.18
|
||||
Version: 1.0.19
|
||||
Architecture: mipsel
|
||||
Maintainer: af123@hummypkg.org.uk
|
||||
Depends: webif(>=1.0.14-8)
|
||||
Description: Sweeper is a package for managing recordings in a variety of ways using custom rules [See forum thread]
|
||||
Description: Sweeper is a package for managing recordings in a variety of ways using custom rules [Add delete action. Some online help.]
|
||||
Tags: http://hummy.tv/forum/threads/5138/
|
||||
|
@ -44,6 +44,14 @@ proc ::sweeper::expand {ts str} {
|
||||
return $ret
|
||||
}
|
||||
|
||||
proc ::sweeper::resolvedir {dir} {
|
||||
global root
|
||||
|
||||
if {$dir eq ""} { return $root }
|
||||
if {[string index $dir 0] eq "/"} { return $dir }
|
||||
return "$root/$dir"
|
||||
}
|
||||
|
||||
proc ::sweeper::intcomp {ref val} {
|
||||
lassign $val op num
|
||||
|
||||
@ -166,18 +174,19 @@ proc ::sweeper::action {ts cmds} {
|
||||
move -
|
||||
movecreate {
|
||||
set rest [::sweeper::expand $ts $rest]
|
||||
if {![file isdirectory "$root/$rest"]} {
|
||||
set dir [::sweeper::resolvedir $rest]
|
||||
if {![file isdirectory $dir]} {
|
||||
if {$cmd eq "move"} {
|
||||
log " ... No such directory $root/$rest" 2
|
||||
log " ... No such directory $dir" 2
|
||||
return 1
|
||||
}
|
||||
if {!$::sweeper::dryrun} {
|
||||
system mkdir_p "$root/$rest"
|
||||
if {![file isdirectory "$root/$rest"]} {
|
||||
log "Error creating $root/$rest" 1
|
||||
system mkdir_p $dir
|
||||
if {![file isdirectory $dir]} {
|
||||
log "Error creating $dir" 1
|
||||
return 1
|
||||
} else {
|
||||
log " ... created $root/$rest" 2
|
||||
log " ... created $dir" 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -185,9 +194,9 @@ proc ::sweeper::action {ts cmds} {
|
||||
foreach f [$ts fileset] {
|
||||
log " ....... $f"
|
||||
if {!$::sweeper::dryrun} {
|
||||
file rename $f "$root/$rest/[file tail $f]"
|
||||
if {"$root/$rest" ni $::sweeper::recalc} {
|
||||
lappend ::sweeper::recalc "$root/$rest"
|
||||
file rename $f "$dir/[file tail $f]"
|
||||
if {"$dir" ni $::sweeper::recalc} {
|
||||
lappend ::sweeper::recalc $dir
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -280,7 +289,7 @@ proc ::sweeper::folder_apply {dir callback} {
|
||||
}
|
||||
}
|
||||
|
||||
proc ::sweeper:folder_merge {src dst} {
|
||||
proc ::sweeper:folder_merge {src dst {op rename}} {
|
||||
if {$src eq $dst} return
|
||||
log "Moving recordings from $src to $dst" 0
|
||||
foreach e [readdir -nocomplain $src] {
|
||||
@ -305,11 +314,13 @@ proc ::sweeper:folder_merge {src dst} {
|
||||
}
|
||||
|
||||
foreach f [$ts fileset] {
|
||||
if {$op eq "copy" \
|
||||
&& [file exists "$dst/[file tail $f]"]} continue
|
||||
log " ....... $f"
|
||||
file rename $f "$dst/[file tail $f]"
|
||||
file $op $f "$dst/[file tail $f]"
|
||||
}
|
||||
}
|
||||
if {![system rmdir_if_empty $src]} {
|
||||
if {$op eq "rename" && ![system rmdir_if_empty $src]} {
|
||||
log "Failed to remove directory" 0
|
||||
foreach l [system rmdir_if_empty $src 1] {
|
||||
log "Blocking file: $l" 0
|
||||
@ -337,39 +348,46 @@ proc ::sweeper::folder_action {ts cmds} {
|
||||
movecreate -
|
||||
move {
|
||||
set rest [::sweeper::expand $ts $rest]
|
||||
if {![file isdirectory "$root/$rest"]} {
|
||||
set dir [::sweeper::resolvedir $rest]
|
||||
if {![file isdirectory $dir]} {
|
||||
if {$cmd eq "move"} {
|
||||
log " ... No such directory $root/$rest" 2
|
||||
log " ... No such directory $dir" 2
|
||||
return 1
|
||||
}
|
||||
if {!$::sweeper::dryrun} {
|
||||
system mkdir_p "$root/$rest"
|
||||
if {![file isdirectory "$root/$rest"]} {
|
||||
log "Error creating $root/$rest" 1
|
||||
system mkdir_p $dir
|
||||
if {![file isdirectory $dir]} {
|
||||
log "Error creating $dir" 1
|
||||
return 1
|
||||
} else {
|
||||
log " ... created $root/$rest" 2
|
||||
log " ... created $dir" 2
|
||||
}
|
||||
}
|
||||
}
|
||||
if {!$::sweeper::dryrun} {
|
||||
::sweeper:folder_merge $folder "$root/$rest"
|
||||
::sweeper:folder_merge $folder $dir
|
||||
}
|
||||
return 1
|
||||
}
|
||||
fileundercreate -
|
||||
fileunder {
|
||||
if {![file isdirectory "$root/$rest"]} {
|
||||
log " ... No such directory $root/$rest" 2
|
||||
set dir [::sweeper::resolvedir $rest]
|
||||
if {![file isdirectory $dir]} {
|
||||
log " ... No such directory $dir" 2
|
||||
return 1
|
||||
}
|
||||
log " - searching for $lfolder under $root/$rest" 2
|
||||
set target [::sweeper::find $root/$rest $lfolder $folder]
|
||||
log " - searching for $lfolder under $dir" 2
|
||||
set target [::sweeper::find $dir $lfolder $folder]
|
||||
log " = $target" 2
|
||||
if {$target eq "" || ![file isdirectory $target]} {
|
||||
log "Did not find directory." 2
|
||||
if {$cmd ne "fileundercreate"} { return 1 }
|
||||
set target "$root/$rest/$lfolder"
|
||||
set target "$dir/$lfolder"
|
||||
if {$target eq $folder} {
|
||||
log "Skipping merge to self." 2
|
||||
return 1
|
||||
}
|
||||
|
||||
log "Creating $target" 0
|
||||
if {!$::sweeper::dryrun} {
|
||||
system mkdir_p $target
|
||||
|
@ -161,6 +161,19 @@ Add pre-defined ruleset:
|
||||
<div class=hidden id=edit_action title="Rule Action">
|
||||
<select name=edit_action_act id=edit_action_act></select>
|
||||
<input name=edit_action_arg id=edit_action_arg size=60 maxlength=255 />
|
||||
<div class="hidden edit_action_help blood" id=edit_action_help_folder>
|
||||
Enter one of:
|
||||
<ul>
|
||||
<li>Relative folder path (e.g. <i>Films/Children</i>);</li>
|
||||
<li>Absolute path (e.g. <i>/media/drive1/archive</i>);</li>
|
||||
<li>Leave blank to indicate the media root (i.e. My Video).</li>
|
||||
</ul>
|
||||
Tokens may be used, for example <i>Archive/%genre</i>
|
||||
</div>
|
||||
<div class="hidden edit_action_help blood"
|
||||
id=edit_action_help_filenamebase>
|
||||
Enter new filename base (no extension) e.g. %title_%yyyymmdd_%hhmm
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class=hidden id=testresults title="Test current ruleset">
|
||||
|
@ -183,7 +183,7 @@ var schema = {
|
||||
},
|
||||
renamefile: {
|
||||
'class': 'all',
|
||||
argtype: 'string',
|
||||
argtype: 'filenamebase',
|
||||
desc: 'Rename recording files to...',
|
||||
continues: true
|
||||
},
|
||||
|
@ -504,7 +504,7 @@ $('#buttons')
|
||||
dir: $('span.dir').text(),
|
||||
data: conffile()
|
||||
}, function(data) {
|
||||
$('#output').html(data)
|
||||
$('#output').fadeIn('fast').html(data)
|
||||
.delay(5000).fadeOut('slow');
|
||||
changed(0);
|
||||
});
|
||||
@ -759,6 +759,9 @@ $('#ruleset')
|
||||
else
|
||||
$('#edit_action_arg').enable();
|
||||
|
||||
$('.edit_action_help').hide();
|
||||
$('#edit_action_help_' + schema.action[cmd].argtype).show();
|
||||
|
||||
if (schema.action[cmd].argtype == 'folder' && arg == mroot)
|
||||
arg = '';
|
||||
|
||||
@ -832,6 +835,8 @@ $('#ruleset')
|
||||
$('#edit_action_arg').disable();
|
||||
else
|
||||
$('#edit_action_arg').enable();
|
||||
$('.edit_action_help').hide();
|
||||
$('#edit_action_help_' + schema.action[cmd].argtype).show();
|
||||
})
|
||||
|
||||
// Set up macros
|
||||
|
@ -154,3 +154,8 @@ tr.blank td
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
.edit_action_help
|
||||
{
|
||||
margin: 1em 0 0 10em;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user