fix: wrapped hash in try/except to detect empty feeds

Also changed file mode of install.sh to +x
This commit is contained in:
A.M. Rowsell 2025-04-19 09:04:42 -04:00
commit f70b18040a
Signed by: amr
GPG key ID: 0B6E2D8375CF79A9
2 changed files with 12 additions and 6 deletions

View file

@ -19,6 +19,7 @@ import json
import time import time
import os import os
import sys import sys
import argparse
import re import re
config_dir = os.environ.get("XDG_CONFIG_HOME") config_dir = os.environ.get("XDG_CONFIG_HOME")
@ -144,9 +145,13 @@ def main():
) )
# Hash the title and time of the latest post and use that to determine if it's been posted # Hash the title and time of the latest post and use that to determine if it's been posted
# Yes, SHA3-512 is totally unnecessary for this purpose, but I love SHA3 # Yes, SHA3-512 is totally unnecessary for this purpose, but I love SHA3
new_hash = hashlib.sha3_512( try:
bytes(latest_post["title"] + str(published_time), "utf-8") new_hash = hashlib.sha3_512(
).hexdigest() bytes(latest_post["title"] + str(published_time), "utf-8")
).hexdigest()
except TypeError:
logger.error("Title of %s isn't hashing correctly", hook["name"])
continue
try: try:
if hook["lasthash"] != new_hash: if hook["lasthash"] != new_hash:
app_config["feeds"][i]["lasthash"] = new_hash app_config["feeds"][i]["lasthash"] = new_hash
@ -169,10 +174,10 @@ def main():
{ {
"title": str(latest_post["title"]), "title": str(latest_post["title"]),
"url": str(latest_post["link"]), "url": str(latest_post["link"]),
"color": 216128, "color": 2123412,
"footer": { "footer": {
"name": "DiscoRSS", "text": "DiscoRSS",
# "url": "https://git.frzn.dev/amr/discorss", "icon_url": "https://frzn.dev/~amr/images/discorss.png",
}, },
"author": { "author": {
"name": str(hook["name"]), "name": str(hook["name"]),
@ -184,6 +189,7 @@ def main():
"value": get_description(latest_post), "value": get_description(latest_post),
} }
], ],
# "timestamp": str(now),
} }
], ],
"attachments": [], "attachments": [],

0
install.sh Normal file → Executable file
View file