autoradio/README.md
2025-04-06 09:10:32 +10:00

60 lines
2.1 KiB
Markdown

# autoradio
A little Python script to download audio files from RSS feeds and put them
somewhere so that your music server can grab them. Has been tested on two (2)
feeds.
## Installation
Dependencies are managed with [uv](https://docs.astral.sh/uv/getting-started/installation/) so install that if you haven't already.
autoradio uses [pycurl](https://pypi.org/project/pycurl/) to do downloads, because it does a bunch of the fiddly stuff around redirects, but pycurl itself can be fiddly to install. On a Raspberry Pi I had to manually install the following packages first using ```apt```:
libssl-dev
libcurl4-openssl-dev
python3-dev
Then:
> git clone https://git.tilde.town/bombinans/autoradio.git
> cd autoradio
> uv run autoradio.py --help
> uv run autoradio.py
To add feeds, edit the config.json file.
## Config
The config file is JSON as follows:
{
"feeds": {
"Utility Fog": {
"url": "https://www.frogworth.com/utilityfog/feed/",
"dir": "/media/pi/Storage/Music/Utility Fog"
},
"RA Podcast": {
"url": "https://ra.co/xml/podcast.xml",
"dir": "/media/pi/Storage/Music/RA_Podcast"
}
},
"max": 10
}
Each feed has a URL and a directory where the files will be downloaded. If a
file with the same name is already present, it won't be re-downloaded.
The value in "max" is the number of entries to look at from each feed, starting
from the latest. The script parses the RSS feed and looks for links which
seem likely to contain audio and tries to fetch them using pycurl (this handles
things like redirects, hopefully).
## Running automatically
You will probable want to set up a cron job to run the script on a regular
schedule: all you need to change for this is provide full paths to everything,
including uv. Here's an example where the script is installed in the home
directory of the user ```pi``` under ```~/working/autoradio```
1 1 * * * /home/pi/.local/bin/uv /home/pi/working/autoradio.py --config /home/pi/working/autoradio/config.json