aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--board/mpd.sh44
-rw-r--r--configs/config2
-rwxr-xr-xlocal/mpd_playlist.sh16
3 files changed, 54 insertions, 8 deletions
diff --git a/board/mpd.sh b/board/mpd.sh
index b5c41bd..d99161c 100644
--- a/board/mpd.sh
+++ b/board/mpd.sh
@@ -1,10 +1,4 @@
-create_missing_dir "/var/lib/mpd/"
-if ! grep -qE '/var/lib/mpd' "${TARGET_DIR}/etc/fstab"; then
- cat << __EOF__ >> "${TARGET_DIR}/etc/fstab"
-tmpfs /var/lib/mpd tmpfs rw 0 0
-__EOF__
-fi
-
+add_tmpfs '/var/lib/mpd'
add_tmpfs "/home/playlists"
cat << __EOF__ > "${TARGET_DIR}/etc/mpd.conf"
@@ -49,13 +43,15 @@ __EOF__
find "$BR2_EXTERNAL_PIAUDIO_PATH/local/playlists" -name '*.m3u' -type f -print0 | xargs -0 -I '{}' cp {} "${TARGET_DIR}/home/"
+cp $BR2_EXTERNAL_PIAUDIO_PATH/local/mpd_playlist.sh "${TARGET_DIR}/home/"
+
cat << __EOF__ > "${TARGET_DIR}/etc/systemd/system/playlists.service"
[Unit]
Description=Playlists
Before=mpd.target
[Service]
-Type=unit
+Type=simple
ExecStart=find /home/ -name '*.m3u' -exec cp {} /home/playlists \;
[Install]
@@ -64,3 +60,35 @@ __EOF__
# Create the link to the system configuration
ln -sf /etc/systemd/system/playlists.service "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/playlists.service"
+
+cat << __EOF__ > "${TARGET_DIR}/etc/systemd/system/rss_playlists.service"
+[Unit]
+Description=RSS Playlists
+Wants=rss_playlists.timer
+
+[Service]
+Type=simple
+ExecStart=/home/mpd_playlist.sh
+
+[Install]
+WantedBy=multi-user.target
+__EOF__
+
+cat << __EOF__ > "${TARGET_DIR}/etc/systemd/system/rss_playlists.timer"
+[Unit]
+Description=Update the RSS playlists every day
+Requires=rss_playlists.service
+
+[Timer]
+Unit=rss_playlists.service
+OnBootSec=1min
+OnUnitInactiveSec=1d
+RandomizedDelaySec=15m
+
+[Install]
+WantedBy=timers.target
+__EOF__
+
+ln -sf /etc/systemd/system/rss_playlists.service "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/rss_playlists.service"
+
+ln -sf /etc/systemd/system/rss_playlists.timer "${TARGET_DIR}/usr/lib/systemd/system/multi-user.target.wants/rss_playlists.timer"
diff --git a/configs/config b/configs/config
index ff929a5..585b605 100644
--- a/configs/config
+++ b/configs/config
@@ -133,6 +133,8 @@ BR2_PACKAGE_MPD_FAAD2=y
BR2_PACKAGE_MPD_OPUS=y
BR2_PACKAGE_MPD_ZZIP=y
BR2_PACKAGE_MPD_BZIP2=y
+# Enable mpc for cron scripts
+BR2_PACKAGE_MPD_MPC=y
# Required in order to connect stream radio from mpd.
BR2_PACKAGE_MPD_CURL=y
diff --git a/local/mpd_playlist.sh b/local/mpd_playlist.sh
new file mode 100755
index 0000000..96b1df4
--- /dev/null
+++ b/local/mpd_playlist.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+# Update the mpd playlist from RSS fields
+
+playlist_directory="/home/playlists"
+
+update_playlist () {
+ mpc clear
+ mpc load $2
+ echo "#EXTM3U" > "${playlist_directory}/Podcast - $1.m3u"
+ mpc -f "##EXTINF:0,%title%\n%file%" playlist >> "${playlist_directory}/Podcast - $1.m3u"
+ mpc clear
+}
+
+update_playlist "Transe fip Express" "https://radiofrance-podcast.net/podcast09/rss_23649.xml"
+update_playlist "Fip Tape" "https://radiofrance-podcast.net/podcast09/rss_24684.xml"
+update_playlist "Live à Fip" "https://radiofrance-podcast.net/podcast09/rss_13416.xml"