date |
tags |
2021-11-29T22:45 |
|
a self-hosted podcast playback station
components
hardware
- raspberry pi 3
- wired speakers
software
general setup
- set up headless raspbian, connect wifi, set up user acct, and podcast dir
sudo raspi-config
mkdir -p /home/pi/podcasts/{playlists,podcast1,podcast2,podcast3}
- install
mopidy
+
extensions (see links above for installation info)
# edit /etc/mopidy/mopidy.conf
[local]
enabled = true
media_dir = /home/pi/podcasts
scan_timeout = 10000
[file]
enabled = false
[http]
enabled = true
hostname = 0.0.0.0
port = 6680
[mpd]
enabled = true
hostname = 0.0.0.0
port = 6600
[logging]
verbosity = 1
[m3u]
enabled = true
playlists_dir = /home/pi/podcasts/playlists
- compile and install
castget
(see link above for installation info)
# edit /home/pi/castgetrc
# note, the keys in this config should correspond with the podcast dirs
# created in step 1 above
[podcast1]
url=http://url.to/podcast1
spool=/home/pi/podcasts/podcast1
filename=%(date) %(title).mp3
[podcast2]
url=http://url.to/podcast2
spool=/home/pi/podcasts/podcast2
filename=%(date) %(title).mp3
...
- create
sync.sh
script with the following content (ymmv, use at your own
risk):
#!/usr/bin/env bash
set -e
# fetch podcasts
/usr/local/bin/castget -C /home/pi/castgetrc -1 "$1"
playlist="/home/pi/podcasts/playlists/$1.m3u"
files=(/home/pi/podcasts/$1/*.mp3)
# remove stale playlist
if [ -f "$playlist" ]
then
rm "$playlist"
fi
# build new playlist with newest entries _first_
for (( i=${#files[@]}-1; i>=0; i-- ))
do
fp="${files[$i]}"
fn=$(basename -- "$fp")
# next, we'll make these all relative fps
quoted=$(python -c "from urllib import parse, sys; print(parse.quote(sys.argv[1]))" "$fn")
echo "local:track:$1/$quoted" >> "$playlist"
done
sudo mopidyctl local scan
- add cron jobs
5 * * * * /home/pi/sync.sh podcast1 >> /path/to/podcast1.log
0,15,30,45 15,16,17 * * * /home/pi/sync.sh podcast2 >> /path/to/podcast2.log
0 0 * * 5 /home/pi/sync.sh podcast3 >> /path/to/podcast3.log
- add any additional internet radio streams into one or more playlist files
in
/home/pi/podcasts/playlists
.
- enjoy!