Created
January 2, 2021 03:28
-
-
Save remino/ccf6065825dadbf9ada19a1d0dadb03a to your computer and use it in GitHub Desktop.
ckrhetcrec
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Enregistre l’émission Et cetera sur les ondes de Oui FM CKRH | |
# chaque vendredi soir à 20:00, heure d’Halifax. | |
# | |
# Executer regulièrement via cron : | |
# 59 7 * * 6 ckrhetcget.sh > /dev/null | |
set -e | |
timezone="America/Halifax" | |
formattsms="%s%3N" | |
radioday="` TZ="$timezone" date +'%Y-%m-%d' `" | |
starttimetsms="` TZ="$timezone" date -d "$radioday 20:00:00" +"$formattsms" `" | |
starttimets="` echo "$starttimetsms / 1000" | bc `" | |
now="` date +"$formattsms" `" | |
diff="` echo "$starttimetsms - $now" | bc `" | |
if [ "$diff" -gt 0 ] | |
then | |
starttime="` date -d "@$starttimets" +'%Y-%m-%d %H:%M:%S %Z' `" | |
waittime="` echo "scale=3; $diff / 1000" | bc `" | |
echo "Waiting until $starttime ($waittime s)..." | |
sleep "$waittime" | |
else | |
starttime="` date +'%Y-%m-%d %H:%M:%S %Z' `" | |
fi | |
timestamp="` TZ="$timezone" date +'%Y%m%d-%H%M%S' `" | |
outfile="ckrh-$timestamp.mp4" | |
outdir="$HOME/Music/ckrh" | |
outpath="$outdir/$outfile" | |
length="$1" | |
[ -z "$length" ] && length="02:00:00" | |
[ ! -d "$outdir" ] && mkdir -p "$outdir" | |
echo "RECORDING..." | |
echo "Start time: $starttime" | |
echo "Length: $length" | |
echo "Output: $outpath" | |
ffmpeg \ | |
-loglevel quiet -hide_banner \ | |
-i https://stream2.statsradio.com/8076/stream \ | |
-t "$length" \ | |
"$outpath" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment