# use Advanced Search on the archive to get a CSV file of last 50 items in collection in "addedate desc" order
# save output as search.csv

wget -nv "https://archive.org/advancedsearch.php?q=collection%3Aaccess_humboldt&fl%5B%5D=identifier&sort%5B%5D=addeddate+desc&sort%5B%5D=&sort%5B%5D=&rows=50&page=1&callback=callback&save=yes&output=csv" -O Downloads/last_50_ah_items.csv

# check to see that the csv file looks ok
head Downloads/last_50_ah_items.csv

# create a one line command that will download only the MPEG2 file and Metadata items for each item to a "destination" directory 
 
awk '{print "wget https://archive.org/compress/" $1 "/formats=MPEG2,METADATA -O Downloads/AH_mpegs/" $1 ".zip"}' Downloads/last_50_ah_items.csv | grep -v identifier | sed 's/"//g' >get_last_50_MPEG2_metadata_ah_items.sh

cat ./get_last_50_MPEG2_metadata_ah_items.sh 

# make sure the destination directory exists
mkdir Downloads/AH_mpegs

# execute the MPEG2 and metadata downloads
sh ./get_last_50_MPEG2_metadata_ah_items.sh 

# check that torrent files exist in the "destination" directory
ls Downloads/AH_mpegs