add series

This commit is contained in:
hummypkg 2015-09-04 20:51:43 +00:00
parent b90690c808
commit 6ae2d773d5
6 changed files with 242 additions and 5 deletions

View File

@ -1,9 +1,9 @@
Package: sweeper
Priority: optional
Section: misc
Version: 2.0.9
Version: 2.0.10
Architecture: mipsel
Maintainer: af123@hummypkg.org.uk
Depends: webif(>=1.2.3-2)
Depends: webif(>=1.2.4-3)
Description: Sweeper is a package for managing recordings in a variety of ways using custom rules [See forum for details]
Tags: http://hummy.tv/forum/threads/5138/

View File

@ -83,12 +83,16 @@ proc ::sweeper::expand {ts str {orig ""}} {
"%title" [$ts get title] \
"%genre" $genre \
"%definition" [$ts get definition] \
"%synopsis" [$ts get synopsis] \
"%lcn" [$ts get channel_num] \
"%channel" [$ts get channel_name] \
"%duration" [$ts duration] \
\
%epname [$ts episode_name] \
%episode [$ts epstr] \
%series [$ts get seriesnum] \
%episodes [$ts get episodetot] \
%episode [$ts get episodenum] \
%epdescr [$ts epstr] \
\
"%timestamp" $timestamp \
"%yyyymmdd" $yyyymmdd \
@ -113,13 +117,13 @@ proc ::sweeper::expand {ts str {orig ""}} {
"%emm" $emm \
]
log $map 2
# log $map 2
set ret [string map $map $str]
log " Expanded \[$str] -> \[$ret]" 2
foreach {fn params} $::sweeper::expand_fns {
log " Looking for %$fn" 2
# log " Looking for %$fn" 2
lassign $params numargs
@ -445,6 +449,28 @@ proc ::sweeper::series {ts flag folder} {
return 1
}
proc ::sweeper::textmatch {ts str folder} {
if {![regexp -- {^([^~]+)~~(.*)$} $str x target pattern]} {
log "No pattern in textmatch." 1
return 0
}
log "Textmatch ($target) against ($pattern)" 2
return [::sweeper::strcontains [::sweeper::expand $ts $target] $pattern]
}
proc ::sweeper::intmatch {ts str folder} {
if {![regexp -- {^([^~]+)~~(.*)$} $str x target pattern]} {
log "No pattern in intmatch." 1
return 0
}
if {[llength [split $pattern " "]] != 2} {
log "Invalid pattern in numeric comparison." 0
return 0
}
log "Intmatch ($target) against ($pattern)" 2
return [::sweeper::intcomp [::sweeper::expand $ts $target] $pattern]
}
########################
# Deprecated conditions

View File

@ -5,3 +5,8 @@ lappend plugins(dmenu) {sweeper {desc "Sweeper Rules"}}
lappend plugins(dmenu) {nosweep {desc "Toggle no-sweep flag"}}
lappend plugins(buttons) "sweeper {
desc {<img src=/plugin/sweeper/img/icon16.png>Sweeper Rules}
link {/plugin/sweeper/edit.jim?dir=[cgi_quote_url $dir]}
}"

View File

@ -161,6 +161,44 @@ For pattern matching, the following special sequences may appear in the pattern:
</select>
</div>
<div class=hidden id=edit_textmatch title="Edit textmatch">
<input name=edit_textmatch_target id=edit_textmatch_target
size=20 maxlength=255 />
<input name=edit_textmatch_pattern id=edit_textmatch_pattern
size=20 maxlength=255 />
<div class="hidden edit_textmatch_help blood"
id=edit_textmatch_help_textmatch>
<br>
You can enter either a substring which must be found somewhere or a pattern<br>
which must be matched.
<br>
For pattern matching, the following special sequences may appear in the pattern:
<div style="width: 600px;margin: 1em">
* - Matches any sequence of characters in string, including none.
<br>
? - Matches any single character in string.
<br>
[chars] - Matches any character in the set given by chars. If a sequence of the form x-y appears in chars, then any character between x and y, inclusive, will match.
<br>
\x - Matches the single character x. This provides a way of avoiding the special interpretation of the characters \*?[] in pattern.
</div>
</div>
</div>
<div class=hidden id=edit_intmatch title="Edit intmatch">
<input name=edit_intmatch_target id=edit_intmatch_target
size=20 maxlength=255 />
<select name=edit_intmatch_op id=edit_intmatch_op>
<option value='='>=</option>
<option value='&gt;'>&gt;</option>
<option value='&lt;'>&lt;</option>
<option value='&gt;='>&gt;=</option>
<option value='&lt;='>&lt;=</option>
</select>
<input name=edit_intmatch_field id=edit_intmatch_field type=number
size=5 maxlength=6 />
</div>
<div class=hidden id=showconf title="Generated Configuration File">
</div>

View File

@ -186,6 +186,20 @@ var schema = {
negate: true,
def: ""
},
textmatch: {
'class': 'all',
type: 'textmatch',
desc: 'Text comparison',
negate: true,
def: 'Enter text here...'
},
intmatch: {
'class': 'all',
type: 'intmatch',
desc: 'Numeric comparison',
negate: true,
def: "0"
},
'or': {
'class': 'all',
type: 'composite',

View File

@ -1,5 +1,6 @@
var mroot = '(Media Root)';
var matchesp = ' ~matches~ ';
function quot(str)
{
@ -40,6 +41,7 @@ function changed(c)
changed.last = c;
}
// Setters convert from config file format to display
var setters = {
noarg: function(cmd, a) {
return '';
@ -66,9 +68,16 @@ var setters = {
},
select: function(cmd, a) {
return schema.criterion[cmd].select[a];
},
textmatch: function(cmd, a) {
return a.replace('~~', matchesp);
},
intmatch: function(cmd, a) {
return a.replace('~~', matchesp);
}
};
// Getters convert from display to config file format
var getters = {
noarg: function(cmd, a) {
return '';
@ -94,6 +103,12 @@ var getters = {
if (c[key] == a)
return key;
return 'UNKNOWNKEY (' + a + ')';
},
textmatch: function(cmd, a) {
return a.replace(matchesp, '~~');
},
intmatch: function(cmd, a) {
return a.replace(matchesp, '~~');
}
};
@ -469,6 +484,89 @@ function edit_select(obj, title, options, val, callback)
});
}
function edit_textmatch(obj, title, target, pattern, callback, typ)
{
$('#edit_textmatch_target').val(target);
$('#edit_textmatch_pattern').val(pattern);
$('#edit_textmatch').dialog({
title: title,
height: 'auto', width: 'auto',
draggable: true, resizable: false,
autoOpen: true,
position: {
my: 'bottom left',
at: 'top right',
of: obj,
collision: 'fit'
},
buttons: {
"Save": function() {
var pattern =
$.trim($('#edit_textmatch_pattern').val());
var target =
$.trim($('#edit_textmatch_target').val());
if (!pattern)
alert("Bad pattern");
else if (!target)
alert("Bad target");
else
{
callback(obj, target, pattern);
$(this).dialog('close');
}
},
"Close": function() {
$(this).dialog('close');
}
}
});
$('.edit_textmatch_help').hide();
if (typ)
$('#edit_textmatch_help_' + typ).show();
// if (text == 'Enter text here...')
// $('#edit_text_field').focus().select();
}
function edit_intmatch(obj, title, target, op, val, callback)
{
$('#edit_intmatch_target').val(target);
$('#edit_intmatch_op').val(op);
$('#edit_intmatch_field').val(val);
$('#edit_intmatch').dialog({
title: title,
height: 'auto', width: 'auto',
draggable: true, resizable: false,
autoOpen: true,
position: {
my: 'bottom left',
at: 'top right',
of: obj,
collision: 'fit'
},
buttons: {
"Save": function() {
var target =
$.trim($('#edit_intmatch_target').val());
var op = $.trim($('#edit_intmatch_op').val());
var val =
$.trim($('#edit_intmatch_field').val());
if (!target)
alert('Bad target');
else if (!op || !val)
alert("Bad value");
else
{
callback(obj, target, op, val);
$(this).dialog('close');
}
},
"Close": function() {
$(this).dialog('close');
}
}
});
}
function edit_clause(obj)
{
var cmd = $(obj).find('th.cmd').attr('cmd');
@ -512,6 +610,62 @@ function edit_clause(obj)
changed(1);
});
break;
case 'textmatch':
if (tval == 'Enter text here...')
{
tgt = "%field";
ptn = tval;
}
else
{
b = tval.split(matchesp);
if (b.length != 2)
{
alert('Bad textmatch value');
break;
}
tgt = b[0];
ptn = b[1];
}
edit_textmatch(target, title, tgt, ptn,
function(obj, tgt, ptn) {
$(obj).html(tgt + matchesp + ptn);
rulerefresh($(obj).closest('div.rule'));
changed(1);
});
break;
case 'intmatch':
if (tval == "0")
{
tgt = "%field";
op = "=";
val = "0";
}
else
{
b = tval.split(matchesp);
if (b.length != 2)
{
alert('Bad intmatch value');
break;
}
c = b[1].split(" ");
if (c.length != 2)
{
alert('Bad intmatch value');
break;
}
tgt = b[0];
op = c[0];
val = c[1];
}
edit_intmatch(target, title, tgt, op, val,
function(obj, tgt, op, val) {
$(obj).html(tgt + matchesp + op + ' ' + val);
rulerefresh($(obj).closest('div.rule'));
changed(1);
});
break;
case 'noarg':
alert('This condition cannot be edited.');
break;