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 os
import sys
import argparse
import re
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
# Yes, SHA3-512 is totally unnecessary for this purpose, but I love SHA3
try:
new_hash = hashlib.sha3_512(
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:
if hook["lasthash"] != new_hash:
app_config["feeds"][i]["lasthash"] = new_hash
@ -169,10 +174,10 @@ def main():
{
"title": str(latest_post["title"]),
"url": str(latest_post["link"]),
"color": 216128,
"color": 2123412,
"footer": {
"name": "DiscoRSS",
# "url": "https://git.frzn.dev/amr/discorss",
"text": "DiscoRSS",
"icon_url": "https://frzn.dev/~amr/images/discorss.png",
},
"author": {
"name": str(hook["name"]),
@ -184,6 +189,7 @@ def main():
"value": get_description(latest_post),
}
],
# "timestamp": str(now),
}
],
"attachments": [],

0
install.sh Normal file → Executable file
View file