various bug fixes

This commit is contained in:
hummypkg 2015-06-22 20:16:48 +00:00
parent 173df12fa7
commit b8833af068
6 changed files with 91 additions and 36 deletions

View File

@ -1,7 +1,7 @@
Package: sweeper Package: sweeper
Priority: optional Priority: optional
Section: misc Section: misc
Version: 2.0.8-4 Version: 2.0.8-5
Architecture: mipsel Architecture: mipsel
Maintainer: af123@hummypkg.org.uk Maintainer: af123@hummypkg.org.uk
Depends: webif(>=1.2.3-2) Depends: webif(>=1.2.3-2)

View File

@ -87,6 +87,9 @@ proc ::sweeper::expand {ts str {orig ""}} {
"%channel" [$ts get channel_name] \ "%channel" [$ts get channel_name] \
"%duration" [$ts duration] \ "%duration" [$ts duration] \
\ \
%epname [$ts episode_name] \
%episode [$ts epstr] \
\
"%timestamp" $timestamp \ "%timestamp" $timestamp \
"%yyyymmdd" $yyyymmdd \ "%yyyymmdd" $yyyymmdd \
"%hhmm" $hhmm \ "%hhmm" $hhmm \
@ -740,16 +743,11 @@ proc ::sweeper::clause {folder cmd arg ts} {
###################################################################### ######################################################################
proc ::sweeper::runrule {ts rule} { proc ::sweeper::runrule {ts rule folder} {
log "Processing \[$rule]" 2 log "Processing \[$rule]" 2
if {[string index $rule 0] eq "#" || [llength $rule] < 2} { return 0 } if {[string index $rule 0] eq "#" || [llength $rule] < 2} { return 0 }
set folder 0
if {[lindex $rule 0] eq "folder"} {
set folder 1
set rule [lrange $rule 1 end]
}
while {[llength $rule] > 1} { while {[llength $rule] > 1} {
set rule [lassign $rule cmd arg] set rule [lassign $rule cmd arg]
set ret [::sweeper::clause $folder $cmd $arg $ts] set ret [::sweeper::clause $folder $cmd $arg $ts]
@ -777,7 +775,10 @@ proc ::sweeper::apply {dir cf} {
set runfolder 0 set runfolder 0
set nrules 0 set nrules 0
foreach rule $rules { foreach rule $rules {
if {[lindex $rule 0] eq "folder"} { incr runfolder } switch -- [lindex $rule 0] {
folder -
global { incr runfolder }
}
if {[string index $rule 0] ne "#" && [llength $rule] > 1} { if {[string index $rule 0] ne "#" && [llength $rule] > 1} {
incr nrules incr nrules
} }
@ -812,10 +813,13 @@ proc ::sweeper::apply {dir cf} {
} }
foreach rule $rules { foreach rule $rules {
if {[lindex $rule 0] eq "folder"} continue
if {[string index $rule 0] eq "#" || if {[string index $rule 0] eq "#" ||
[llength $rule] < 2} continue [llength $rule] < 2} continue
if {[::sweeper::runrule $ts $rule]} break switch -- [lindex $rule 0] {
folder continue
global { set rule [lrange $rule 1 end] }
}
if {[::sweeper::runrule $ts $rule 0]} break
} }
} }
@ -840,14 +844,12 @@ proc ::sweeper::apply {dir cf} {
} }
set ts 0 set ts 0
foreach de [readdir -nocomplain $entry] { foreach de [lsort -command [lambda {a b} {
upvar entry e
return $([file mtime "$e/$b"] - [file mtime "$e/$a"])
}] [lsearch -glob -all -inline \
[readdir -nocomplain $entry] {*.ts}]] {
set dentry "$entry/$de" set dentry "$entry/$de"
if {[file isdirectory $dentry]} {
set ts 0
break
}
if {$ts ne "0"} continue
if {![string match {*.ts} $dentry]} continue
log " --- Considering $dentry" 2 log " --- Considering $dentry" 2
@ -876,9 +878,13 @@ proc ::sweeper::apply {dir cf} {
foreach rule $rules { foreach rule $rules {
if {[string index $rule 0] eq "#" || if {[string index $rule 0] eq "#" ||
[llength $rule] < 2} continue [llength $rule] < 3} continue
if {[lindex $rule 0] ne "folder"} continue switch -- [lindex $rule 0] {
if {[::sweeper::runrule $ts $rule]} break folder -
global { set rule [lrange $rule 1 end] }
default continue
}
if {[::sweeper::runrule $ts $rule 1]} break
} }
} }

View File

@ -61,10 +61,10 @@ Add pre-defined ruleset:
<fieldset class=rule> <fieldset class=rule>
<legend class=comment> <legend class=comment>
<span class=commentleft> <span class=commentleft>
<span class="ruleicon folder hidden"> <span class="ruleicon folder global hidden">
<img src=/images/711_1_09_Media_Folder.png> <img src=/images/711_1_09_Media_Folder.png>
</span> </span>
<span class="ruleicon file hidden"> <span class="ruleicon file global hidden">
<img src=/img/Video_TS_New.png> <img src=/img/Video_TS_New.png>
</span> </span>
<span class=comment>Unnamed rule</span> <span class=comment>Unnamed rule</span>
@ -101,6 +101,10 @@ Add pre-defined ruleset:
<div class="foldercomment hidden"> <div class="foldercomment hidden">
For each sub-folder, inspect a recording within and: For each sub-folder, inspect a recording within and:
</div> </div>
<div class="globalcomment hidden">
For each recording and sub-folder, inspect a recording
within and:
</div>
<a href=# class=addcriterion> <a href=# class=addcriterion>
<img src=img/plus.png <img src=img/plus.png
title="Add condition"> title="Add condition">
@ -164,6 +168,8 @@ For pattern matching, the following special sequences may appear in the pattern:
value='file' checked />Process Files value='file' checked />Process Files
<input name=newrule_type id=newrule_type_folder type=radio <input name=newrule_type id=newrule_type_folder type=radio
value='folder' />Process Folders value='folder' />Process Folders
<input name=newrule_type id=newrule_type_global type=radio
value='global' />Process Files &amp; Folders
<br> <br>
Description: Description:
<input name=newrule_comment id=newrule_comment size=80 maxlength=255 /> <input name=newrule_comment id=newrule_comment size=80 maxlength=255 />

View File

@ -96,11 +96,18 @@ proc rule {id rule} {
} }
if {$lcomment eq ""} { set lcomment "Unnamed rule" } if {$lcomment eq ""} { set lcomment "Unnamed rule" }
if {[lindex $rule 0] eq "folder"} { switch -- [lindex $rule 0] {
set type "folder" folder {
set rule [lrange $rule 1 end] set type "folder"
} else { set rule [lrange $rule 1 end]
set type "file" }
global {
set type "global"
set rule [lrange $rule 1 end]
}
default {
set type "file"
}
} }
if {$id > 1} { add_json ",\n" } if {$id > 1} { add_json ",\n" }
@ -135,7 +142,7 @@ proc rule {id rule} {
set arg "continue" set arg "continue"
} }
} }
lassign $arg cmd arg lassign "$arg" cmd arg
if {$cmd eq "preserve"} { set cmd 'stop' } if {$cmd eq "preserve"} { set cmd 'stop' }
add_json " ],\n" add_json " ],\n"
add_json " \"action\": {\n" add_json " \"action\": {\n"

View File

@ -467,6 +467,7 @@ var macros = {
var select_file_criteria = {}; var select_file_criteria = {};
var select_folder_criteria = {}; var select_folder_criteria = {};
var select_global_criteria = {};
$.each(schema.criterion, function(k, v) { $.each(schema.criterion, function(k, v) {
if (v.deprecated) if (v.deprecated)
return; return;
@ -478,15 +479,20 @@ $.each(schema.criterion, function(k, v) {
case 'folder': case 'folder':
select_folder_criteria[k] = v.desc; select_folder_criteria[k] = v.desc;
break; break;
case 'global':
select_global_criteria[k] = v.desc;
break;
case 'all': case 'all':
select_file_criteria[k] = v.desc; select_file_criteria[k] = v.desc;
select_folder_criteria[k] = v.desc; select_folder_criteria[k] = v.desc;
select_global_criteria[k] = v.desc;
break; break;
} }
}); });
var select_file_actions = {}; var select_file_actions = {};
var select_folder_actions = {}; var select_folder_actions = {};
var select_global_actions = {};
$.each(schema.action, function(k, v) { $.each(schema.action, function(k, v) {
if (v.deprecated) if (v.deprecated)
return; return;
@ -498,9 +504,13 @@ $.each(schema.action, function(k, v) {
case 'folder': case 'folder':
select_folder_actions[k] = v.desc; select_folder_actions[k] = v.desc;
break; break;
case 'global':
select_global_actions[k] = v.desc;
break;
case 'all': case 'all':
select_file_actions[k] = v.desc; select_file_actions[k] = v.desc;
select_folder_actions[k] = v.desc; select_folder_actions[k] = v.desc;
select_global_actions[k] = v.desc;
break; break;
} }
}); });

View File

@ -6,7 +6,8 @@ function quot(str)
if (!str) if (!str)
return '""'; return '""';
if (str.indexOf(" ") == -1 && str.indexOf('"') == -1) if (str.indexOf(" ") == -1 && str.indexOf('"') == -1
&& str.indexOf("\\") == -1)
return str; return str;
return '{' + str + '}'; return '{' + str + '}';
} }
@ -132,6 +133,8 @@ function ruleconf(rule)
s += '## '; s += '## ';
if (rule.attr('type') == 'folder') if (rule.attr('type') == 'folder')
s += 'folder '; s += 'folder ';
else if (rule.attr('type') == 'global')
s += 'global ';
s += clauseconf(rule); s += clauseconf(rule);
@ -318,13 +321,20 @@ function addrule(id, data)
.removeClass('hidden'); .removeClass('hidden');
rule.find('span.comment').html(data.name); rule.find('span.comment').html(data.name);
if (data.type == 'folder') switch (data.type)
{ {
case 'global':
rule.find('.commentleft > span.global').show();
rule.find('.globalcomment').show();
break;
case 'folder':
rule.find('.commentleft > span.folder').show(); rule.find('.commentleft > span.folder').show();
rule.find('.foldercomment').show(); rule.find('.foldercomment').show();
} break;
else default:
rule.find('.commentleft > span.file').show(); rule.find('.commentleft > span.file').show();
break;
}
rule.attr('type', data.type); rule.attr('type', data.type);
var $c = rule.find('table.criteria'); var $c = rule.find('table.criteria');
@ -725,10 +735,18 @@ function addcriterion(rule, target)
{ {
var type = rule.attr('type'); var type = rule.attr('type');
if (type == 'folder') switch (type)
{
case 'folder':
options = select_folder_criteria; options = select_folder_criteria;
else break;
case 'global':
options = select_global_criteria;
break;
default:
options = select_file_criteria; options = select_file_criteria;
break;
}
// Populate select box and reset form. // Populate select box and reset form.
$('#newcondition_cmd').empty(); $('#newcondition_cmd').empty();
@ -862,10 +880,18 @@ $('#ruleset')
var rule = $(this).closest('div.rule'); var rule = $(this).closest('div.rule');
var type = rule.attr('type'); var type = rule.attr('type');
if (type == 'folder') switch (type)
{
case 'folder':
options = select_folder_actions; options = select_folder_actions;
else break;
case 'global':
options = select_global_actions;
break;
default:
options = select_file_actions; options = select_file_actions;
break;
}
$('#edit_action_act').empty(); $('#edit_action_act').empty();
$.each(options, function(k, v) { $.each(options, function(k, v) {