#! /bin/sh
feeds='Brainpain|https://w8gez1.podcaster.de/Brainpain.rss'
feed=$(printf "$feeds" | column -t -s"|" | dmenu | awk '{print $NF}')
echo "Fetching feed: $feed"
download=$(wget -qO- $feed | grep "
\| /\/>\n/g" | sed -e "s///g" | sed -e "s/<\/title>//g" | sed -e "s/ $//g" | column -t -s"´" | dmenu)
link=$(echo $download | awk '{print $NF}' | sed -e "s/\"//g")
name=$(echo $download | sed -e "s/ \".*\"//g")
filename=$(echo $name | tr ' ' '_')$(echo $link | sed -e "s/.*\././g")
echo "Link: $link"
echo "Filename: $filename"
notify-send "Downloading Podcast" "$name"
wget -O "/mnt/data/Podcasts/$filename" "$link" && notify-send "Finished Downloading Podcast" "$name" || notify-send "Download Failed" "$name"