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