Instagram2Fedi/src/already_posted.py

15 lines
419 B
Python
Raw Normal View History

2021-09-06 08:39:24 +00:00
def already_posted(id, id_filename):
with open(id_filename) as file:
content = file.read().split("\n")
sha1 = hashlib.sha1(bytes(id, "utf-8")).hexdigest()
if sha1 in content:
return True
return False
def mark_as_posted(id, id_filename):
with open(id_filename, 'a') as file:
sha1 = hashlib.sha1(bytes(id, "utf-8")).hexdigest()
file.write(sha1+'\n')