[nozomi] implement searching for negated terms (#388)
It's incredibly slow and resource intensive (> 1GB of memory), but that is also how it is implemented on nozomi.la itself.
This commit is contained in:
@@ -155,11 +155,20 @@ class NozomiSearchExtractor(NozomiExtractor):
|
|||||||
return {"search_tags": self.tags}
|
return {"search_tags": self.tags}
|
||||||
|
|
||||||
def posts(self):
|
def posts(self):
|
||||||
|
index = None
|
||||||
result = set()
|
result = set()
|
||||||
|
|
||||||
|
def nozomi(path):
|
||||||
|
url = "https://j.nozomi.la/" + path + ".nozomi"
|
||||||
|
return self._unpack(self.request(url).content)
|
||||||
|
|
||||||
for tag in self.tags:
|
for tag in self.tags:
|
||||||
url = "https://j.nozomi.la/nozomi/{}.nozomi".format(tag)
|
if tag[0] == "-":
|
||||||
items = self._unpack(self.request(url).content)
|
if not index:
|
||||||
|
index = set(nozomi("index"))
|
||||||
|
items = index.difference(nozomi("nozomi/" + tag[1:]))
|
||||||
|
else:
|
||||||
|
items = nozomi("nozomi/" + tag)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
result.intersection_update(items)
|
result.intersection_update(items)
|
||||||
|
|||||||
Reference in New Issue
Block a user