132 lines
2.9 KiB
Markdown
132 lines
2.9 KiB
Markdown
---
|
|
date: 2021-11-29T22:45
|
|
tags:
|
|
- timeline
|
|
- software
|
|
- notes
|
|
---
|
|
|
|
# a self-hosted podcast playback station
|
|
|
|
## components
|
|
|
|
### hardware
|
|
|
|
- raspberry pi 3
|
|
- wired speakers
|
|
|
|
### software
|
|
|
|
- [raspberry pi os](https://www.raspberrypi.com/software/)
|
|
- packages:
|
|
- `python-pip`
|
|
- `libglib2.0-dev`
|
|
- `libxml2-dev`
|
|
- `libcurl4-openssl-dev`
|
|
- `libid3-3.8.3-dev`
|
|
- `vim`
|
|
- [`mopidy`](https://mopidy.com/)
|
|
- extensions:
|
|
- [`mopidy-m3u`](https://docs.mopidy.com/en/latest/ext/m3u/)
|
|
- [`mopidy-local`](https://github.com/mopidy/mopidy-local)
|
|
- [`mopidy-musicbox-webclient`](https://github.com/pimusicbox/mopidy-musicbox-webclient)
|
|
- [`mopidy-mpd`](https://github.com/mopidy/mopidy-mpd)
|
|
- [`mopidy-stream`](https://docs.mopidy.com/en/latest/ext/stream/)
|
|
- [`castget`](https://castget.johndal.com/)
|
|
|
|
## general setup
|
|
|
|
1. set up headless raspbian, connect wifi, set up user acct, and podcast dir
|
|
```bash
|
|
sudo raspi-config
|
|
mkdir -p /home/pi/podcasts/{playlists,podcast1,podcast2,podcast3}
|
|
```
|
|
2. [install `mopidy`](https://docs.mopidy.com/en/latest/installation/debian/) +
|
|
extensions (see links above for installation info)
|
|
```bash
|
|
# 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
|
|
```
|
|
3. compile and install `castget` (see link above for installation info)
|
|
```bash
|
|
# 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
|
|
|
|
...
|
|
```
|
|
4. create `sync.sh` script with the following content (ymmv, use at your own
|
|
risk):
|
|
```bash
|
|
#!/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
|
|
```
|
|
5. add cron jobs
|
|
```bash
|
|
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
|
|
```
|
|
6. add any additional internet radio streams into one or more playlist files
|
|
in `/home/pi/podcasts/playlists`.
|
|
7. enjoy!
|