Created
February 17, 2021 18:14
-
-
Save bwestergard/0bbde35168e129063c5266e8c5e91c3d to your computer and use it in GitHub Desktop.
NPR Hourly News Update
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Checks to see if there is a new hourly news update, plays it if there is. | |
# Stores the last played newscast URL in last_newscast_url.txt | |
# Can be invoked with cron or: watch -n 30 ./hourly-news.sh | |
latest_newscast_url=$(curl -s https://feeds.npr.org/500005/podcast.xml | grep enclosure | cut -d \" -f2) | |
last_newscast_url=$(cat last_newscast_url.txt) | |
if [ "$latest_newscast_url" = "$last_newscast_url" ]; then | |
echo "No news." | |
else | |
echo "News!" | |
echo "$latest_newscast_url" > last_newscast_url.txt | |
wget $latest_newscast_url -O newscast.mp3 | |
afplay newscast.mp3 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment