Updates podcasts, downloads new episodes, then normalizes them using a normalization script and podfox.
#!/bin/bash | |
# Updates podcasts, downloads new episodes, then normalizes them. | |
if [ "$1" = "-h" ]; then | |
echo "Updates podcasts, downloads new episodes, then normalizes them." | |
echo "podcast.sh" | |
exit 0 | |
fi | |
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") | |
declare -a arr=("CAST1" "CAST2") | |
username=[your username here] | |
source=/home/$username/podcasts | |
target=/var/www/html/podcasts | |
tempdir=$(mktemp -d) | |
#Set the working directory to the temporary directory. | |
cd $tempdir | |
#Update the podcasts. | |
sudo -u $username podfox update | |
#Download new episodes for each podcast. | |
for podcast in "${arr[@]}"; do | |
echo "Checking for updates in $podcast..." | |
tempfile=$(mktemp) | |
sudo -u $username podfox episodes $podcast > $tempfile | |
undownloaded=$(head -3 $tempfile | grep "Not Downloaded" | wc -l) | |
sudo -u $username podfox download $podcast --how-many=$undownloaded | |
for file in $(find $source/$podcast -iname "*.mp3"); do | |
filename=$(basename -- "$file") | |
extension="${filename##*.}" | |
filename="${filename%.*}" | |
normalized="$filename.normalized.mp3" | |
foundfile=$(find $target/$podcast -iname "$normalized") | |
if [ "$foundfile" != "" ]; then | |
echo "$foundfile already exists." | |
else | |
echo "No file found for $filename. Normalizing" | |
/home/$username/normalize.sh "$file" "$tempdir/$normalized" | |
echo "Moving $normalized from $tempdir to $target/$podcast" | |
mv * "$target/$podcast" | |
fi | |
done | |
done | |
#Clean up and reset IFS | |
echo "Cleaning up..." | |
IFS=$SAVEIFS | |
#Done! | |
echo "Done!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment