lav-outils/wgetauto/wgetauto

55 lines
1.0 KiB
Plaintext
Raw Normal View History

2019-01-29 15:22:20 +01:00
#!/bin/bash
help()
{
echo "Usage: wgetauto [ -h | duration targetdirectory ]"
}
capture()
{
local duration="$1"
local targetDirectory="$2"
duration="$1"
targetDirectory="$2"
currentDate="$(date '+%Y-%m-%d-%Hh%M')"
echo "============ $(date) ============"
2019-01-29 15:22:20 +01:00
echo "Capture launching…"
2019-06-18 15:33:31 +02:00
wget https://icecast.libre-a-toi.org:8444/voixdulat_ogg -o log -O "$targetDirectory/output-$currentDate.ogg" &
2019-01-29 15:22:20 +01:00
echo "Capture launched."
wgetpid="$!"
echo "wget PID=$wgetpid"
2019-01-29 15:38:13 +01:00
echo "$(ps auxwww|grep " $wgetpid " | grep -v grep)"
2019-01-29 15:22:20 +01:00
sleep "$duration"
echo "Kill attempting…"
kill -9 "$wgetpid"
echo "Kill done."
2020-11-12 10:08:49 +01:00
ffmpeg -i "$targetDirectory/output-$currentDate.ogg" "$targetDirectory/output-$currentDate.mp3"
2019-01-29 15:22:20 +01:00
}
#
case $# in
1)
if [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
help
else
capture "$1" "."
fi
;;
2) capture "$1" "$2"
;;
*) echo "Invalid parameter count."
help
;;
esac