Compare commits
7 Commits
feature-re
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
35ed7c776a | ||
|
e9c07abaa8 | ||
|
e1026e83fb | ||
|
3984261168 | ||
|
477514c2ba | ||
f4a2b4f88e | |||
f716954ad6 |
40
README.md
40
README.md
@ -1,24 +1,31 @@
|
|||||||
# autoradio
|
# autoradio
|
||||||
|
|
||||||
A little Python script to download audio files from RSS feeds. Installation
|
A little Python script to download audio files from RSS feeds and put them
|
||||||
is messy and I have tested this on exactly two feeds, so it's by no means
|
somewhere so that your music server can grab them. Has been tested on two (2)
|
||||||
finished software.
|
feeds.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
I packaged this project with poetry and then discovered that poetry can't
|
Dependencies are managed with [uv](https://docs.astral.sh/uv/getting-started/installation/) so install that if you haven't already.
|
||||||
install pycurl properly, as the latter requires command-line options to compile
|
|
||||||
it with the correct SSL backend. Here's the manual workaround:
|
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
|
> git clone https://git.tilde.town/bombinans/autoradio.git
|
||||||
> cd autoradio
|
> cd autoradio
|
||||||
> poetry install
|
> uv run autoradio.py --help
|
||||||
> poetry shell
|
> uv run autoradio.py
|
||||||
> pip uninstall pycurl
|
|
||||||
> pip install --compile --install-option="--with-openssl" pycurl
|
|
||||||
> poetry run autoradio --config config.json
|
|
||||||
|
|
||||||
The config file looks like this.
|
To add feeds, edit the config.json file.
|
||||||
|
|
||||||
|
## Config
|
||||||
|
|
||||||
|
The config file is JSON as follows:
|
||||||
|
|
||||||
{
|
{
|
||||||
"feeds": {
|
"feeds": {
|
||||||
@ -41,3 +48,12 @@ 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
|
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
|
seem likely to contain audio and tries to fetch them using pycurl (this handles
|
||||||
things like redirects, hopefully).
|
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
|
||||||
|
@ -67,6 +67,7 @@ def main():
|
|||||||
help="Config file",
|
help="Config file",
|
||||||
)
|
)
|
||||||
args = ap.parse_args()
|
args = ap.parse_args()
|
||||||
|
print(f"Config from {args.config}")
|
||||||
with open(args.config, 'r') as cfh:
|
with open(args.config, 'r') as cfh:
|
||||||
cf = json.load(cfh)
|
cf = json.load(cfh)
|
||||||
m = int(cf.get("max", "5"))
|
m = int(cf.get("max", "5"))
|
||||||
@ -77,3 +78,5 @@ def main():
|
|||||||
print(f"content = {url}")
|
print(f"content = {url}")
|
||||||
download_audio(url, config['dir'])
|
download_audio(url, config['dir'])
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -8,3 +8,6 @@ dependencies = [
|
|||||||
"feedparser>=6.0.11",
|
"feedparser>=6.0.11",
|
||||||
"pycurl>=7.45.6",
|
"pycurl>=7.45.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[project.scripts]
|
||||||
|
autoradio = "autoradio.autoradio:main"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user