Skip to content

Commit 4d461f0

Browse files
committed
queries: added 'tagged' (#47)
1 parent 1cdcbbd commit 4d461f0

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

src/pyrocore/util/matching.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,9 @@ def pre_filter(self):
154154
"""
155155
inner = self._inner.pre_filter()
156156
if inner:
157-
if inner.startswith('"'):
157+
if inner.startswith('"not=$') and inner.endswith('"') and '\\' not in inner:
158+
return inner[6:-1] # double negation, return inner command
159+
elif inner.startswith('"'):
158160
inner = '"$' + inner[1:]
159161
else:
160162
inner = '$' + inner
@@ -205,6 +207,8 @@ class FieldFilter(Filter):
205207
custom_tm_completed = "d.custom=tm_completed",
206208
custom_tm_loaded = "d.custom=tm_loaded",
207209
custom_tm_started = "d.custom=tm_started",
210+
211+
tagged = "d.custom=tags",
208212
)
209213

210214
#active last time a peer was connected
@@ -214,7 +218,6 @@ class FieldFilter(Filter):
214218
#is_private private flag set (no DHT/PEX)?
215219
#leechtime time taken from start to completion
216220
#seedtime total seeding time after completion
217-
#tagged has certain tags? (not related to the 'tagged' view)
218221
#traits automatic classification of this item (audio, video, tv, movie, etc.)
219222
#views views this item is attached to
220223
#xfer transfer rate
@@ -323,6 +326,20 @@ class TaggedAsFilter(FieldFilter):
323326
of tags.
324327
"""
325328

329+
def pre_filter(self):
330+
""" Return rTorrent condition to speed up data transfer.
331+
"""
332+
if self._name in self.PRE_FILTER_FIELDS:
333+
if not self._value:
334+
return '"not=${}"'.format(self.PRE_FILTER_FIELDS[self._name])
335+
else:
336+
val = self._value
337+
if self._exact:
338+
val = val.copy().pop()
339+
return '"string.contains_i=${},{}"'.format(
340+
self.PRE_FILTER_FIELDS[self._name], val)
341+
return ''
342+
326343
def validate(self):
327344
""" Validate filter condition (template method).
328345
"""

0 commit comments

Comments
 (0)