Skip to content

Commit

Permalink
[nozomi] implement searching for negated terms (#388)
Browse files Browse the repository at this point in the history
It's incredibly slow and resource intensive (> 1GB of memory),
but that is also how it is implemented on nozomi.la itself.
  • Loading branch information
mikf committed Oct 17, 2019
1 parent 1c03a38 commit ae98dbc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions gallery_dl/extractor/nozomi.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,20 @@ def metadata(self):
return {"search_tags": self.tags}

def posts(self):
index = None
result = set()

def nozomi(path):
url = "https://j.nozomi.la/" + path + ".nozomi"
return self._unpack(self.request(url).content)

for tag in self.tags:
url = "https://j.nozomi.la/nozomi/{}.nozomi".format(tag)
items = self._unpack(self.request(url).content)
if tag[0] == "-":
if not index:
index = set(nozomi("index"))
items = index.difference(nozomi("nozomi/" + tag[1:]))
else:
items = nozomi("nozomi/" + tag)

if result:
result.intersection_update(items)
Expand Down

0 comments on commit ae98dbc

Please sign in to comment.