#!/bin/bash # wut-audio-archive # # Usage: # wut-audio-archive [Observation ID Minumum] [Observation ID Maximum] # Example: # wut-audio-archive 1292461 1470525 # # This script only downloads audio files from archive.org, not satnogs.org. # # Download Observation: JSON and audio. Not waterfall or data files. # This will download the observation range on the command line. # # The last observation to start in 2019 was 1470525 # The last observation to start in 2019-11 was 1292461 # NOTE! Observations are not in numerical order by chronology. # It looks like it is ordered by scheduling, so an older observation can have # a higher observation ID. # # So to get mostly all of the observations in December, 2019, run: # wut-audio-archive 1292461 1470525 # Archive.org doesn't have everything from December, 2019 yet. # You can get latest number here: # https://archive.org/details/satnogs?sort=-publicdate # Run: # wut-audio-archive 1292461 1368693 # wut-audio-archive 1348064 1368693 # # XXX Should check input is sane... APIURL="https://network.satnogs.org/api" DOWNDIR="/srv/satnogs/download" OBSIDMIN="$1" OBSIDMAX="$2" OBSID=$OBSIDMIN cd $DOWNDIR || exit # Download JSON while [ $OBSID -lt $OBSIDMAX ] do echo "Audio. ID: $OBSID" mkdir -p $OBSID cd $OBSID # Download if is isn't there already [ ! -f $OBSID.json ] && curl \ --http2 --ipv4 \ --silent \ --output $OBSID.json \ "$APIURL/observations/?id=$OBSID&ground_station=&satellite__norad_cat_id=&transmitter_uuid=&transmitter_mode=&transmitter_type=&vetted_status=&vetted_user=&start=&end=" && sleep `echo $((0 + RANDOM % 1))` # Download audio AUDIOURL=`cat $OBSID.json | jq --compact-output '.[0] | {archive_url}' | grep ogg | cut -f 2- -d : | sed -e 's/}//g' -e 's/http:/https:/g' -e 's/"//g'` if [ "$AUDIOURL" ] ; then AUDIOFILE=`basename "$AUDIOURL"` XMLURL="https://archive.org/download/satnogs-observation-$OBSID/satnogs-observation-$OBSID""_files.xml" XMLFILE=`basename "$XMLURL"` [ ! -f "$AUDIOFILE" -o ! -f "$XMLFILE" ] && \ curl \ --location \ --silent \ --http2 --ipv4 \ --continue-at - \ --remote-time \ --output $AUDIOFILE \ $AUDIOURL \ --output $XMLFILE \ $XMLURL \ && sleep `echo $((0 + RANDOM % 1))` fi cd .. let OBSID=$OBSID+1 done exit 0