scripts/downloadhelper.sh

33 lines
943 B
Bash
Executable File

#!/bin/bash
echo "enter the dldir to download - dont forget trailing '/'!, leave empty for default."
read out
dldir="/home/${USER}/Downloads/"
if [ "$out" != "" ]; then
dldir=$(out)
fi
#todo: check that dldir ends with /
echo "Downloading to: ${dldir}"
mkdir -p ${dldir}
while : ; do
read -p "enter ytid or link, noting to exit: " ytid
if [ "${ytid}" == "" ]; then
break
fi
youtube-dl -F ${ytid}
echo "please chose format: (by number or mp3/mp4/aac/...)"
read form
youtube-dl --restrict-filenames -o "${dldir}%(title)s.%(ext)s" -f ${form} --exec 'touch {}' ${ytid}
file="$(ls /home/yannis/Downloads/ -ot | sed -n 2p | perl -lane 'print $F[7]')"
echo "DOWNLOADED FILE: $file"
#todo check if its already mp3
read -p "convert to other format? (mp3/mp4/...): " mp
if [ "${mp}" != "" ]; then
ffmpeg -hide_banner -i "${dldir}${file}" "${dldir}${file%%.*}.${mp}"
#delete original?
rm -i ${dldir}${file}
fi
done
echo "exit."