Skip to content

Commit

Permalink
queries: added 'tagged' (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
pyroscope committed Apr 9, 2017
1 parent 1cdcbbd commit 4d461f0
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/pyrocore/util/matching.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,9 @@ def pre_filter(self):
"""
inner = self._inner.pre_filter()
if inner:
if inner.startswith('"'):
if inner.startswith('"not=$') and inner.endswith('"') and '\\' not in inner:
return inner[6:-1] # double negation, return inner command
elif inner.startswith('"'):
inner = '"$' + inner[1:]
else:
inner = '$' + inner
Expand Down Expand Up @@ -205,6 +207,8 @@ class FieldFilter(Filter):
custom_tm_completed = "d.custom=tm_completed",
custom_tm_loaded = "d.custom=tm_loaded",
custom_tm_started = "d.custom=tm_started",

tagged = "d.custom=tags",
)

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

def pre_filter(self):
""" Return rTorrent condition to speed up data transfer.
"""
if self._name in self.PRE_FILTER_FIELDS:
if not self._value:
return '"not=${}"'.format(self.PRE_FILTER_FIELDS[self._name])
else:
val = self._value
if self._exact:
val = val.copy().pop()
return '"string.contains_i=${},{}"'.format(
self.PRE_FILTER_FIELDS[self._name], val)
return ''

def validate(self):
""" Validate filter condition (template method).
"""
Expand Down

0 comments on commit 4d461f0

Please sign in to comment.