#!/bin/bash

#Example of an archive.com list of a zip file containing ROMS
#You can get the HTML with wget or curl
#https://ia601806.us.archive.org/view_archive.php?archive=/35/items/arcade-0223-merged/Arcade/roms.zip

if [ $# -ne 1 ]; then
  echo ""
  echo "Usage:"
  echo "$0 <file>  : Where file is a HTML archive.com list"
  echo ""
  exit
fi

ROM=$(cat "$1" | grep .zip | sed 's/\%2F/\//g' | cut -d"\"" -f2 | fzf -m --header 'Press TAB for multi-select')
if [ ! -z "${ROM}" ]; then
  clear
  #wget "http:$ROM"
  echo "$ROM" | while read -r item; do
    wget "http:$item"
  done
  echo .
  echo "---------------------------------"
  echo "Check if download was successful."
  read -p "Press a key to continue... " -n1 -s
fi

