Pl4tform_website/scripts/total-minutes-of-music-in-music.sh
2025-02-03 19:29:59 +01:00

29 lines
893 B
Bash

#!/bin/bash
join() {
local IFS="$1"
shift
echo "$*"
}
#### ARCHIVE
readarray -t durations < <(
find /var/www/nextcloud/data/radio_admin/files/radio_music_and_jingles/music/. -type f \( -iname '*.mp3' -o -iname '*.wav' -o -iname '*.m3u' -o \
-iname '*.m4[ab]' -o -iname '*.mpga' -o -iname '*.opus' \) \
-exec ffprobe {} -show_format -loglevel -8 \; |
sed -nE 's/^duration=([0-9\.]+)$/\1/p')
# add + between all durations:
expression=$(join + ${durations[@]})
# calculate the total, including subseconds, round to whole minutes:
totM=$(bc -q <<< "scale=0;($expression)/60")
totH=$(bc -q <<< "scale=0;($totM)/60")
totJ=$(bc -q <<< "scale=0;($totH)/24")
timestamp=$(date)
echo "$timestamp : Total duration of Pl4tform-Music: $totM minutes / $totH Hours / $totJ Days" >> ./MUSIC_music_duration_output.txt
echo "$timestamp was done"