blob: f475d36ac2e0001aa50f58dfa7dccc3136eafb59 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
#!/bin/bash
if ! command -v ffmpeg &>/dev/null; then
printf "%s\n" "[err] ffmpeg not found"
exit 1
fi
DIR="{{ radio_music_dir }}"
shopt -s nullglob
for mp3file in "${DIR}"/*.mp3; do
oggfile="${mp3file%.mp3}.ogg"
printf "%s\n" "[inf] converting ${mp3file} to ${oggfile} with ${title}"
if ffmpeg -loglevel error -y -i "${mp3file}" -acodec libvorbis -q:a 5 -metadata title="${title}" "${oggfile}"; then
printf "%s\n" "[inf] conversion successful, removing ${mp3file}"
rm -f "${mp3file}"
else
printf "%s\n" "[err] conversion failed for ${mp3file}"
fi
done
for oggfile in "${DIR}"/*.ogg; do
title="$(basename "${oggfile}" .ogg)"
vorbiscomment -w -t "TITLE=${title}" "${oggfile}"
done
ls "${DIR}"/*.ogg > "${DIR}/playlist.txt"
printf "%s\n" "[inf] playlist generated at ${DIR}/playlist.txt"
if id -u icecast2 >/dev/null 2>&1 && getent group icecast >/dev/null 2>&1; then
chown -R icecast2:icecast "$DIR"
printf "%s\n" "[inf] chowned ${DIR} with icecast2:icecast"
else
printf "%s\n" "[err] user or group icecast2:icecast does not exist, skipping chown"
fi
|