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 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
|
||||||
|
try:
|
||||||
new_hash = hashlib.sha3_512(
|
new_hash = hashlib.sha3_512(
|
||||||
bytes(latest_post["title"] + str(published_time), "utf-8")
|
bytes(latest_post["title"] + str(published_time), "utf-8")
|
||||||
).hexdigest()
|
).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
0
install.sh
Normal file → Executable file
Loading…
Add table
Add a link
Reference in a new issue