fix: wrapped hash in try/except to detect empty feeds
Also changed file mode of install.sh to +x
This commit is contained in:
parent
0de8e237a0
commit
f70b18040a
2 changed files with 12 additions and 6 deletions
12
discorss.py
12
discorss.py
|
@ -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
0
install.sh
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue