download-pods.sh (782B)
1 #!/bin/sh 2 3 LOC="${HOME}/Videos/Podcasts" 4 queueFile="${LOC}/toDownload.txt" 5 6 cp "$queueFile" /tmp/toDownload.txt 7 8 [ $(cat "$queueFile" | wc -l) = "0" ] && echo "No podcasts queued" && exit 9 10 while read -r podcast_file; do 11 echo "$podcast_file" 12 curl -L "$podcast_file" > /tmp/out.mp3 13 if ! [ "$?" = "0" ]; then 14 mv /tmp/toDownload.txt "$queueFile" 15 echo "Error" 16 exit 17 fi 18 19 filename="$(mediainfo /tmp/out.mp3 | grep -e "Track name" -e "Album" | sed 's/Track name/Trackname/g' | tr -s " " | cut -d " " -f 3- | tr "\n" "+" | sed 's/[+]/ - /g' | sed 's/ - $//g').mp3" 20 mv /tmp/out.mp3 "${LOC}/${filename}" 21 grep -v "$podcast_file" /tmp/toDownload.txt > /tmp/toDownload.txt.tmp 22 mv /tmp/toDownload.txt.tmp /tmp/toDownload.txt 23 done < "$queueFile" 24 25 mv /tmp/toDownload.txt "$queueFile"