rdarlington

weathermachine.sh

Aug 14th, 2025 (edited)
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.04 KB | Software | 0 0
  1. #! /bin/bash
  2.  
  3. # Grab the local forecast from NOAA
  4. # Find the first line that matters (TODAY || TONIGHT)
  5. # Figure out what line it is, and pull out just the bit I care about (today and tomorrow)
  6. # Convert to MP3 for a Logitech Squeezebox to play with one button press
  7. # Marvel at how close this looks like my crappy Perl code
  8.  
  9. cd /home/bobd/scripts/weather
  10. rm nmz211.txt*
  11. rm localweather.mp3
  12. rm /home/plex/weather/localweather.mp3
  13.  
  14. declare -i STARTLINE
  15. export CUTOFF=`date  --date="1 days tomorrow" +"%A" |  tr '[:lower:]' '[:upper:]'`
  16.  
  17. wget https://tgftp.nws.noaa.gov/data/forecasts/zone/nm/nmz211.txt
  18.  
  19. export STARTLINE="`sed -n '/\./{=;q;}' nmz211.txt`"
  20.  
  21. tail -n +$STARTLINE nmz211.txt | sed 's/^\.//' | sed -n "/$CUTOFF/q;p" > current.txt
  22.  
  23. espeak -f current.txt --stdout | ffmpeg -i - -ar 44100 -ac 2 -ab 192k -f mp3 localweather.mp3
  24. ffmpeg -i localweather.mp3 -i logo.png -map 0:0 -map 1:0 -c copy -id3v2_version 3 -metadata:s:v title="Album cover" -metadata:s:v comment="Cover (front)" /home/plex/weather/localweather.mp3
  25.  
  26. rm current.txt
  27.  
Advertisement
Add Comment
Please, Sign In to add comment