Updated README with example systemd units and updated config file.

This commit is contained in:
A.M. Rowsell 2025-01-31 16:37:24 -05:00
parent 22e4294469
commit 40156c434f
Signed by: amr
GPG key ID: 0B6E2D8375CF79A9

View file

@ -9,24 +9,26 @@ requests >= 2.4.2
feedparser feedparser
``` ```
The remaining imports should all be part of the standard Python install. To configure the script, create /etc/discorss.conf with the following structure: The remaining imports should all be part of the standard Python install.
## How to setup
To configure the script, create /etc/discorss.conf with the following structure:
``` ```
{ {
"feeds": [ "feeds": [
{ {
"name": "phoronix", "name": "Phoronix",
"siteurl": "https://www.phoronix.com/",
"url": "http://www.phoronix.com/rss.php", "url": "http://www.phoronix.com/rss.php",
"webhook": "webhook url" "webhook": "webhook url",
"offset": -18000
}, },
{ {
"name": "pagetable", "name": "Pagetable",
"siteurl": "https://pagetable.com",
"url": "https://www.pagetable.com/?feed=rss2", "url": "https://www.pagetable.com/?feed=rss2",
"webhook": "webhook url"
},
{
"name": "righto",
"url": "https://www.righto.com/feeds/posts/default",
"webhook": "webhook url", "webhook": "webhook url",
"offset": -18000 "offset": -18000
} }
@ -34,6 +36,42 @@ The remaining imports should all be part of the standard Python install. To conf
} }
``` ```
The offset should only be required if feeds aren't showing up. This is because feedparser, in its infinite wisdom, just ignores the timezone when converting publish dates from feeds. So most feeds end up with an epoch in UTC. The offset should be the number of seconds between your time zone and UTC. This will eventually be fixed in a future update, I just need to sit down and wrangle with feedparser and datetime some more. Create a webhook for each feed (unless you want them all to show as the same webhook for whatever reason) and make sure to add it in to the config. I have it set up with a webhook for each site, each with the site's icon and name set for the webhook which makes the messages look really nice.
To automate feed posting, create a systemd service and timer to execute the script. I will include examples soon. The offset should only be required if feeds aren't showing up. This is because feedparser, in its infinite wisdom, just ignores the timezone when converting publish dates from feeds. So most feeds end up with an epoch in UTC. The offset should be the number of seconds between your time zone and UTC. This will eventually be fixed in a future update, I just need to sit down and wrangle with feedparser and datetime some more. All fields are mandatory, if you want to have no offset for example, set it to 0. The name and siteurl are used to create the "author" field in the Discord embed.
## Automation
To automate feed posting, create a systemd service and timer to execute the script.
Use the command `systemctl --user edit --full --force discorss.service` and then paste in something like this:
```
[Unit]
Description=Discord RSS feeder
Wants=discorss.timer
[Service]
Type=oneshot
ExecStart=/path/to/discorss.py
[Install]
WantedBy=default.target
```
Make sure to edit the ExecStart to point to the correct location. Then we need a systemd timer to automatically fire the script. Run `systemctl --user edit --full --force discorss.timer` and then paste in this:
```
[Unit]
Description=Timer for DiscoRSS
Requires=discorss.service
[Timer]
Unit=discorss.service
OnCalendar=*-*-* *:00,15,30,45:30
AccuracySec=10s
[Install]
WantedBy=timers.target
```
To change how often this fires, edit the OnCalendar parameter. The config above has it firing every 15 minutes at half past the minute. Look at the systemd timer man pages for help if you want to tweak it.