diff --git a/CONTROL/control b/CONTROL/control index 4048596..af9b8a9 100644 --- a/CONTROL/control +++ b/CONTROL/control @@ -1,7 +1,7 @@ Package: sweeper Priority: optional Section: misc -Version: 2.0.8-6 +Version: 2.0.9 Architecture: mipsel Maintainer: af123@hummypkg.org.uk Depends: webif(>=1.2.3-2) diff --git a/webif/plugin/sweeper/action.js b/webif/plugin/sweeper/action.js new file mode 100644 index 0000000..2ab6d97 --- /dev/null +++ b/webif/plugin/sweeper/action.js @@ -0,0 +1,51 @@ + +var select_file_criteria = {}; +var select_folder_criteria = {}; +var select_global_criteria = {}; +$.each(schema.criterion, function(k, v) { + if (v.deprecated) + return; + switch (v['class']) + { + case 'file': + select_file_criteria[k] = v.desc; + break; + case 'folder': + select_folder_criteria[k] = v.desc; + break; + case 'global': + select_global_criteria[k] = v.desc; + break; + case 'all': + select_file_criteria[k] = v.desc; + select_folder_criteria[k] = v.desc; + select_global_criteria[k] = v.desc; + break; + } +}); + +var select_file_actions = {}; +var select_folder_actions = {}; +var select_global_actions = {}; +$.each(schema.action, function(k, v) { + if (v.deprecated) + return; + switch (v['class']) + { + case 'file': + select_file_actions[k] = v.desc; + break; + case 'folder': + select_folder_actions[k] = v.desc; + break; + case 'global': + select_global_actions[k] = v.desc; + break; + case 'all': + select_file_actions[k] = v.desc; + select_folder_actions[k] = v.desc; + select_global_actions[k] = v.desc; + break; + } +}); + diff --git a/webif/plugin/sweeper/auto.hook b/webif/plugin/sweeper/auto.hook index c575456..2a9e420 100644 --- a/webif/plugin/sweeper/auto.hook +++ b/webif/plugin/sweeper/auto.hook @@ -382,6 +382,10 @@ proc ::sweeper::wage {ts age folder} { return [::sweeper::intcomp $recage $age] } +proc ::sweeper::bookmarks {ts bookmarks folder} { + return [::sweeper::intcomp [$ts get bookmarks] $bookmarks] +} + proc ::sweeper::definition {ts def folder} { return [::sweeper::strcontains [$ts get definition] $def] } @@ -675,6 +679,8 @@ proc ::sweeper::action_delete {ts cmd arg folder} { return 1 } +eval_plugins sweeper + ###################################################################### # Handle action diff --git a/webif/plugin/sweeper/edit.jim b/webif/plugin/sweeper/edit.jim index 9da0c89..a3a44f6 100755 --- a/webif/plugin/sweeper/edit.jim +++ b/webif/plugin/sweeper/edit.jim @@ -2,14 +2,16 @@ package require cgi source /mod/webif/lib/setup -require system.class +require system.class plugin set dir [cgi_get dir ""] set root [system mediaroot] if {$dir eq ""} { set dir $root } -jscss {schema.js config.jim script.js} style.css +jscss {schema.js macro.js config.jim} style.css +eval_plugins sweeperjs +jscss {action.js script.js} jqplugin confirmAction enadis header diff --git a/webif/plugin/sweeper/macro.js b/webif/plugin/sweeper/macro.js new file mode 100644 index 0000000..61ffa2a --- /dev/null +++ b/webif/plugin/sweeper/macro.js @@ -0,0 +1,165 @@ + +var macros = { + seriesfiler: { + desc: 'Series-Filer', + rules: [ + { + "raw": "action {fileunder ""}", + "name": "Emulate Seriesfiler", + "type": "folder", + "enabled": "1", + "criteria": [ + { + "negate": 0, + "cmd": "series", + "arg": "" + } + ], + "action": { + "cmd": "fileunder", + "arg": "" + } + } + ] + }, + newk: { + desc: 'Remove New: prefix', + rules: [ + { + "raw": "title New:* action {settitle {%orig%regsub,New:\\s*,,}}", + "name": "Remove New: prefix.", + "type": "global", + "enabled": "1", + "criteria": [ + { + "negate": 0, + "cmd": "title", + "arg": "New:*" + } + ], + "action": { + "cmd": "settitle", + "arg": "%orig%regsub,New:\\s*,," + } + } + ] + }, + example: { + desc: 'Example rules', + rules: [ + { + "raw": "lcn {>= 70} lcn {<= 79} or {duration {>= 90} genre Film } action {move Children/Films}", + "name": "Move any Children's films", + "type": "file", + "enabled": "0", + "criteria": [ + { + "negate": 0, + "cmd": "lcn", + "arg": ">= 70" + }, + { + "negate": 0, + "cmd": "lcn", + "arg": "<= 79" + }, + { + "negate": 0, + "cmd": "or", + "arg": "duration {>= 90} genre Film ", + "criteria": [ + { + "negate": 0, + "cmd": "duration", + "arg": ">= 90" + }, + { + "negate": 0, + "cmd": "genre", + "arg": "Film" + } + ] + } + ], + "action": { + "cmd": "move", + "arg": "Children/Films" + } + }, + { + "raw": "lcn {>= 70} lcn {<= 79} action {move Children/Miscellaneous}", + "name": "Move anything else recorded from a children's channel", + "type": "file", + "enabled": "0", + "criteria": [ + { + "cmd": "lcn", + "arg": ">= 70" + }, + { + "cmd": "lcn", + "arg": "<= 79" + } + ], + "action": { + "cmd": "move", + "arg": "Children/Miscellaneous" + } + }, + { + "raw": "lcn {>= 70} lcn {<= 79} action {fileundercreate Children}", + "name": "Move any series recordings from a Children's channel (folder rule)", + "type": "folder", + "enabled": "0", + "criteria": [ + { + "cmd": "lcn", + "arg": ">= 70" + }, + { + "cmd": "lcn", + "arg": "<= 79" + } + ], + "action": { + "cmd": "fileundercreate", + "arg": "Children" + } + }, + { + "raw": "title {Formula 1} action {move F1}", + "name": "Move any one-off Formula 1 recordings into the F1 folder", + "type": "file", + "enabled": "0", + "criteria": [ + { + "cmd": "title", + "arg": "Formula 1" + } + ], + "action": { + "cmd": "move", + "arg": "F1" + } + }, + { + "raw": "age {> 120} action {movecreate Misc}", + "name": "Move any one-off recordings into a folder called Misc after a while", + "type": "file", + "enabled": "0", + "criteria": [ + { + "cmd": "age", + "arg": "> 120" + } + ], + "action": { + "cmd": "movecreate", + "arg": "Misc" + } + } +] + } + +}; + diff --git a/webif/plugin/sweeper/schema.js b/webif/plugin/sweeper/schema.js index 7ffd5aa..66cbd0d 100644 --- a/webif/plugin/sweeper/schema.js +++ b/webif/plugin/sweeper/schema.js @@ -1,3 +1,4 @@ + var schema = { criterion: { lcn: { @@ -49,6 +50,13 @@ var schema = { negate: true, def: "0" }, + bookmarks: { + 'class': 'all', + type: 'int', + desc: 'Number of bookmarks', + negate: true, + def: "0" + }, now: { 'class': 'all', type: 'int', @@ -284,217 +292,3 @@ var schema = { } }; -var macros = { - seriesfiler: { - desc: 'Series-Filer', - rules: [ - { - "raw": "action {fileunder ""}", - "name": "Emulate Seriesfiler", - "type": "folder", - "enabled": "1", - "criteria": [ - { - "negate": 0, - "cmd": "series", - "arg": "" - } - ], - "action": { - "cmd": "fileunder", - "arg": "" - } - } - ] - }, - newk: { - desc: 'Remove New: prefix', - rules: [ - { - "raw": "title New:* action {settitle {%orig%regsub,New:\\s*,,}}", - "name": "Remove New: prefix.", - "type": "global", - "enabled": "1", - "criteria": [ - { - "negate": 0, - "cmd": "title", - "arg": "New:*" - } - ], - "action": { - "cmd": "settitle", - "arg": "%orig%regsub,New:\\s*,," - } - } - ] - }, - example: { - desc: 'Example rules', - rules: [ - { - "raw": "lcn {>= 70} lcn {<= 79} or {duration {>= 90} genre Film } action {move Children/Films}", - "name": "Move any Children's films", - "type": "file", - "enabled": "0", - "criteria": [ - { - "negate": 0, - "cmd": "lcn", - "arg": ">= 70" - }, - { - "negate": 0, - "cmd": "lcn", - "arg": "<= 79" - }, - { - "negate": 0, - "cmd": "or", - "arg": "duration {>= 90} genre Film ", - "criteria": [ - { - "negate": 0, - "cmd": "duration", - "arg": ">= 90" - }, - { - "negate": 0, - "cmd": "genre", - "arg": "Film" - } - ] - } - ], - "action": { - "cmd": "move", - "arg": "Children/Films" - } - }, - { - "raw": "lcn {>= 70} lcn {<= 79} action {move Children/Miscellaneous}", - "name": "Move anything else recorded from a children's channel", - "type": "file", - "enabled": "0", - "criteria": [ - { - "cmd": "lcn", - "arg": ">= 70" - }, - { - "cmd": "lcn", - "arg": "<= 79" - } - ], - "action": { - "cmd": "move", - "arg": "Children/Miscellaneous" - } - }, - { - "raw": "lcn {>= 70} lcn {<= 79} action {fileundercreate Children}", - "name": "Move any series recordings from a Children's channel (folder rule)", - "type": "folder", - "enabled": "0", - "criteria": [ - { - "cmd": "lcn", - "arg": ">= 70" - }, - { - "cmd": "lcn", - "arg": "<= 79" - } - ], - "action": { - "cmd": "fileundercreate", - "arg": "Children" - } - }, - { - "raw": "title {Formula 1} action {move F1}", - "name": "Move any one-off Formula 1 recordings into the F1 folder", - "type": "file", - "enabled": "0", - "criteria": [ - { - "cmd": "title", - "arg": "Formula 1" - } - ], - "action": { - "cmd": "move", - "arg": "F1" - } - }, - { - "raw": "age {> 120} action {movecreate Misc}", - "name": "Move any one-off recordings into a folder called Misc after a while", - "type": "file", - "enabled": "0", - "criteria": [ - { - "cmd": "age", - "arg": "> 120" - } - ], - "action": { - "cmd": "movecreate", - "arg": "Misc" - } - } -] - } - -}; - -var select_file_criteria = {}; -var select_folder_criteria = {}; -var select_global_criteria = {}; -$.each(schema.criterion, function(k, v) { - if (v.deprecated) - return; - switch (v['class']) - { - case 'file': - select_file_criteria[k] = v.desc; - break; - case 'folder': - select_folder_criteria[k] = v.desc; - break; - case 'global': - select_global_criteria[k] = v.desc; - break; - case 'all': - select_file_criteria[k] = v.desc; - select_folder_criteria[k] = v.desc; - select_global_criteria[k] = v.desc; - break; - } -}); - -var select_file_actions = {}; -var select_folder_actions = {}; -var select_global_actions = {}; -$.each(schema.action, function(k, v) { - if (v.deprecated) - return; - switch (v['class']) - { - case 'file': - select_file_actions[k] = v.desc; - break; - case 'folder': - select_folder_actions[k] = v.desc; - break; - case 'global': - select_global_actions[k] = v.desc; - break; - case 'all': - select_file_actions[k] = v.desc; - select_folder_actions[k] = v.desc; - select_global_actions[k] = v.desc; - break; - } -}); -