1
0

Added a helper bash script for radio.

This commit is contained in:
Alexander Andreev 2023-02-19 20:21:05 +04:00
parent fb6ab57a29
commit 44080a8a66
Signed by: Arav
GPG Key ID: 0388CC8FAA51063F

44
tools/radioctl Normal file
View File

@ -0,0 +1,44 @@
#!/usr/bin/sh
radio_dir=/srv/radio
out=$radio_dir/filelist.html
case $1 in
f | filelist)
if [[ -n "$2" ]]; then
out=$2
fi
tree -H '' -T "Arav's dwelling / Radio / List" \
-P '*.ogg' --charset=utf-8 --prune --du -hnl \
--nolinks -o $out $radio_dir/music
break
;;
p | playlist)
find -L $radio_dir/music/* -type f -iname '*.ogg' |
cut -c 18- | sort -d > $radio_dir/playlists/all
break
;;
s | shuffle)
shuf $radio_dir/playlists/all > $radio_dir/playlists/all-rand
break
;;
c | convert)
for file in "$2"/*; do
if [[ "$file" == *.ogg ]]; then
continue;
fi
ffmpeg -hide_banner -i "$file" -y -vn -c:a libvorbis -b:a 128k "${file%.*}.ogg";
if [ $? -eq 0 ] && [ $2 = "del" ]; then
rm "$file";
fi
done
break
;;
*)
echo "f|ilelist - to generate a filelist.html"
echo "p|laylist - to generate a playlist 'all'"
echo "s|huffle - to shuffle a playlist and store as all-rand"
echo "c|onvert DIR - convert all files in DIR to ogg"
exit
;;
esac