#!/bin/bash saveto="/Volumes/Data/NASA" filename="$saveto/NASA-TV-HD.`date +%y%m%d-%s`" httpurl='http://liveips.nasa.gov.edgesuite.net/msfc/Wifi.m3u8' trap "break; echo Finished recording. ; exit 0" SIGINT SIGTERM echo -n Buffering #Get initial set of files for nextfile in $(curl -s $httpurl | grep '.ts'); do echo -n . curl -s "$nextfile" >> $filename.ts lastfile="$nextfile" done echo 100\% echo Starting continuous recording. Press CTRL-C to quit. while true; do nextfile=$(curl -s $httpurl | grep '.ts' | tail -1) if [ "$nextfile" != "$lastfile" ]; then curl -s "$nextfile" >> $filename.ts lastfile="$nextfile" fi #File list updates every 10 seconds, but don't want to sleep too long and miss an update! sleep 7 done