1
0
dwelling-radio/tools/radioctl

66 lines
2.0 KiB
Plaintext
Raw Permalink Normal View History

2023-02-19 20:21:05 +04:00
#!/usr/bin/sh
radio_dir=/mnt/data/appdata/radio
2023-02-19 20:21:05 +04:00
case $1 in
f | filelist)
tree -H '' -T "Arav's dwelling / Radio / List" \
-P '*.ogg' --charset=utf-8 --prune --du -hnl \
--nolinks -o $radio_dir/filelist.html $radio_dir/music
2023-02-19 20:21:05 +04:00
break
;;
p | playlist)
find -L $radio_dir/music/* -type f -iname '*.ogg' |
cut -c 31- | sort -d > $radio_dir/playlists/all
2023-02-19 20:21:05 +04:00
break
;;
ep | ez-playlist)
find -L $radio_dir/music/* -type f -iname '*.ogg' |
sort -d > $radio_dir/playlists/all
break
;;
2023-02-19 20:21:05 +04:00
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
if [ -f "${file%.*}.ogg" ]; then
continue;
fi
2023-02-19 20:21:05 +04:00
ffmpeg -hide_banner -i "$file" -y -vn -c:a libvorbis -b:a 128k "${file%.*}.ogg";
2023-05-02 17:47:36 +04:00
if [ $? -eq 0 ] && [ $3 = "del" ]; then
2023-02-19 20:21:05 +04:00
rm "$file";
fi
done
break
;;
2023-06-25 22:07:32 +04:00
d | duration)
find $radio_dir/music -iname '*.ogg' -exec ffprobe -i "{}" \
-show_entries format=duration -v quiet -of csv="p=0" \; |
paste -s -d+ - | bc
2023-06-25 22:10:44 +04:00
break
;;
er | ez-reload)
pkill -HUP ezstream
break
;;
dr | dw-reload)
pkill -HUP dwelling-radio
break
;;
2023-02-19 20:21:05 +04:00
*)
echo "f|ilelist - to generate a filelist.html"
echo "p|laylist - to generate a playlist 'all'"
echo "ep|ez-playlist- - to generate a playlist 'all' with full paths"
2023-02-19 20:21:05 +04:00
echo "s|huffle - to shuffle a playlist and store as all-rand"
echo "c|onvert DIR - convert all files in DIR to ogg"
2023-06-25 22:07:32 +04:00
echo "d|uration - get total songs' duration"
echo "er|ez-reload - send SIGHUP to ezstream to reload a playlist"
echo "dr|dw-reload - send SIGHUP to dwelling-radio to reload a playlist"
2023-02-19 20:21:05 +04:00
exit
;;
esac