Skip to content

Instantly share code, notes, and snippets.

@bradymholt
Last active May 19, 2020 19:41
Show Gist options
  • Save bradymholt/a9a4a8f95db285f00c90 to your computer and use it in GitHub Desktop.
Save bradymholt/a9a4a8f95db285f00c90 to your computer and use it in GitHub Desktop.
HFBC Podcast Upload
#!/bin/bash
FILENAME=$1
cd ~/veritas-podcast
#change ownership to bholt
sudo chown bholt ./record/${FILENAME}.wav
[ $? -eq 0 ] || exit $?
#download latest header audio
#s3cmd get --force s3://hfbctheoaks/podcast/podcast-header.wav ./static/podcast-header.wav
#add podcast header
sox ./static/podcast-header.wav ./record/${FILENAME}.wav ./process/${FILENAME}.wav
[ $? -eq 0 ] || exit $?
#stereo > mono
sox ./process/${FILENAME}.wav -c 1 ./process/${FILENAME}-mono.wav
#convert to mp3 (64Kpbs)
lame -b 64 ./process/${FILENAME}-mono.wav ./upload/${FILENAME}.mp3
[ $? -eq 0 ] || exit $?
#remove files
rm ./record/${FILENAME}.wav
rm ./process/${FILENAME}.wav
rm ./process/${FILENAME}-mono.wav
./upload.sh
#!/bin/bash
FILENAME=$(date +"%Y%m%d_%H%M")
cd ~/veritas-podcast
#record
sudo arecord -f dat -d $1 ./record/${FILENAME}.wav
[ $? -eq 0 ] || exit $?
#./process.sh "${FILENAME}"
#!/bin/bash
NOTIFY_EMAIL="[email protected]"
FACEBOOK_POST_EMAIL="[email protected]"
#sudo systemctl restart network
cd ~/veritas-podcast/upload
for CURFILE in `find . -type f -name "*.mp3"`
do
MODTIME=$(stat -c %y ${CURFILE})
DB_DATE=$(date --date="${MODTIME}" +%Y-%m-%d)
DATE=$(date --date="${MODTIME}" +%m.%d.%Y)
CURFILENAME=${CURFILE#"./"}
FILENAME="HFBC_The_Oaks-${DATE}_Podcast.mp3"
#upload to s3
s3cmd put --reduced-redundancy --acl-public ./${CURFILE} s3://SOMETHING_HERE/podcast/${FILENAME}
[ $? -eq 0 ] || continue
#write db record
mysql -h www.SOMETHING_HERE.com -D theoaks -u theoaks -pSUPER_SECURE --execute "INSERT INTO podcasts (created_at, updated_at, date, title, speaker, audio) VALUES ('${DB_DATE}','${DB_DATE}','${DB_DATE}','TBD','TBD','${FILENAME}')"
[ $? -eq 0 ] || continue
mv ${CURFILE} ../complete/
#delete completed older than 30 days
find ../complete/ -type f -mtime +30 -delete
#send notify/update email
echo "Title and Speaker need to be set: http://www.SOMETHING_HERE.com/podcasts/last/edit" | mail -s "HFBC The Oaks Podcast ${DATE} - Upload Complete" $NOTIFY_EMAIL
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment