dotfiles/.local/bin/ytdl_live

29 lines
538 B
Bash
Executable file

#!/bin/bash
list="$@ "
_PID=
#echo -e "\n\n-- $(date "+%Y-%m-%d %H:%M:%S") ------------------------\n" >> ytdl.log
if [ -n "$list" ]
then
youtube-dl $list #2>>ytdl.err >>ytdl.log &
_PID=$(jobs -p)
fi
while true
do
read -p "URL: " url
kill $_PID || (sleep 2; kill -9 $_PID)
if [ $url = "." ]
then
kill $_PID || (sleep 2; kill -9 $_PID)
exit 0
fi
list="${list}${url} "
#echo -e "\n\n-- $(date "+%Y-%m-%d %H:%M:%S") ------------------------\n" >> ytdl.log
youtube-dl $list #2>>ytdl.err >>ytdl.log &
_PID=$(jobs -p)
done