Compare commits

..

No commits in common. "38e78bcdf45454993d2093abe4bce59634c2bd7d" and "cdbaa552fb5a75fee01618f3ee49f9f06adb57df" have entirely different histories.

View file

@ -1,5 +1,4 @@
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: UTF-8 -*-
# SPDX-License-Identifier: MPL-2.0 # SPDX-License-Identifier: MPL-2.0
# SPDX-FileCopyrightText: © 2025 A.M. Rowsell <https://frzn.dev/~amr> # SPDX-FileCopyrightText: © 2025 A.M. Rowsell <https://frzn.dev/~amr>
@ -45,12 +44,10 @@ def main():
now = time.mktime(time.localtime()) now = time.mktime(time.localtime())
last_check = app_config["lastupdate"] last_check = app_config["lastupdate"]
for hook in app_config["feeds"]: for hook in app_config["feeds"]:
# Get the feed
feed = feedparser.parse(hook["url"]) feed = feedparser.parse(hook["url"])
published_time = time.mktime(feed.entries[0]["published_parsed"]) published_time = time.mktime(feed.entries[0]["published_parsed"])
published_time = published_time + hook["offset"] published_time = published_time + hook["offset"]
print(feed.entries[0]["published"], published_time, now) print(feed.entries[0]["published"], published_time, now)
# Generate the webhook
webhook = { webhook = {
"embeds": [ "embeds": [
{ {
@ -59,19 +56,15 @@ def main():
"description": getDescription(feed), "description": getDescription(feed),
"provider": "DiscoRSS", "provider": "DiscoRSS",
} }
] ],
} }
customHeader = { customHeader = {
"user-agent": "DiscoRSS (https://git.frzn.dev/amr/discorss, 0.1)", "User-Agent": "DiscoRSS (https://git.frzn.dev/amr/discorss.git, 0.1)"
"content-type": "application/json",
} }
if published_time > last_check and published_time < now: if published_time > last_check and published_time < now:
print(json.dumps(webhook)) r = requests.post(hook["webhook"], json=webhook, headers=customHeader)
r = requests.post(
hook["webhook"], data=json.dumps(webhook), headers=customHeader
)
print(webhook["embeds"][0]["title"]) print(webhook["embeds"][0]["title"])
print(r.text, r.status_code, r.json()) print(r.text, r.status_code, r.headers)
app_config["lastupdate"] = now app_config["lastupdate"] = now
with open(config_file_path, "w") as config_file: with open(config_file_path, "w") as config_file:
json.dump(app_config, config_file, indent=4) json.dump(app_config, config_file, indent=4)