add support for filtering by user
This commit is contained in:
parent
35621f169f
commit
b9ba6ef0d7
11
bink.py
11
bink.py
@ -9,6 +9,8 @@ import tempfile
|
||||
from math import floor
|
||||
|
||||
home = os.path.expanduser("~/.bink")
|
||||
filters = []
|
||||
filters_path = f"{home}/.binkfilters"
|
||||
max_body_length = 64_000
|
||||
|
||||
helptext = """see https://git.tilde.town/nebula/bink for details
|
||||
@ -21,6 +23,12 @@ try:
|
||||
except FileExistsError:
|
||||
pass
|
||||
|
||||
try:
|
||||
with open(filters_path, "r") as f:
|
||||
filters = json.load(f.read())
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
try:
|
||||
editor = os.environ["EDITOR"]
|
||||
except KeyError:
|
||||
@ -41,6 +49,9 @@ def generate_feed(before=None, count=200):
|
||||
file_object(path) for path in glob("/home/**/.bink/*")
|
||||
if os.path.isfile(path) and not os.path.islink(path)
|
||||
]
|
||||
for post in posts.copy():
|
||||
if post[1] in filters:
|
||||
posts.remove(post)
|
||||
if before:
|
||||
posts = [post for post in posts if post[0] < before]
|
||||
posts.sort(key=lambda x: x[0], reverse=True)
|
||||
|
Loading…
x
Reference in New Issue
Block a user