From ebfbc6b153b8e6e4314ce14b4f1fe73c47d9cca2 Mon Sep 17 00:00:00 2001 From: Martin Herkt Date: Fri, 27 Oct 2017 08:36:36 +0200 Subject: [PATCH] Add NSFW filter to address query commands --- fhost.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fhost.py b/fhost.py index bd642f9..920ad5e 100755 --- a/fhost.py +++ b/fhost.py @@ -459,9 +459,12 @@ def queryhash(h): query(su.enbase(f.id, 1)) @manager.command -def queryaddr(a): +def queryaddr(a, nsfw=False): res = File.query.filter_by(addr=a) + if nsfw: + res = res.filter(File.nsfw_score > app.config["NSFW_THRESHOLD"]) + for f in res: query(su.enbase(f.id, 1)) @@ -497,15 +500,15 @@ def update_nsfw(): @manager.command -def querybl(): +def querybl(nsfw=False): if os.path.isfile(app.config["FHOST_UPLOAD_BLACKLIST"]): with open(app.config["FHOST_UPLOAD_BLACKLIST"], "r") as bl: for l in bl.readlines(): if not l.startswith("#"): if not ":" in l: - queryaddr("::ffff:" + l.rstrip()) + queryaddr("::ffff:" + l.rstrip(), nsfw) else: - queryaddr(l.strip()) + queryaddr(l.strip(), nsfw) if __name__ == "__main__": manager.run()