-
Notifications
You must be signed in to change notification settings - Fork 4
Script to generate table
xorpad edited this page Apr 15, 2016
·
5 revisions
#!/usr/bin/env bash
shopt -s nullglob
# Use RomCenter numbered dats
get_dat_files() {
useragent='Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)'
baseurl='http://datomatic.no-intro.org/?page=download'
for x in "Nintendo - New Nintendo 3DS" "Nintendo - New Nintendo 3DS (DLC)" "Nintendo - Nintendo 3DS" "Nintendo - Nintendo 3DS (DLC)"; do
secret=$(curl -A "$useragent" -c cookie.dat -b cookie.dat -s "$baseurl" | sed -n 's/.* name="\(Download[0-9]*\)" value="\([0-9]*\)"\/>[[:space:]]*$/\1=\2/p' | head -n 1)
[ -z "$secret" ] && break
curl -A "$useragent" -c cookie.dat -b cookie.dat -s --data "sel_s=$x" "$baseurl&fun=dat" >/dev/null
curl -A "$useragent" -c cookie.dat -b cookie.dat -s --data "numbered=1&inc_xroms=1&format=romcenter&special_filter=all_specials&language_filter=all_languages®ion_filter=all_regions&dbutton=Download&$secret" "$baseurl&fun=dat" > "$x.zip"
unzip "$x.zip" >/dev/null && rm "$x.zip"
done
}
print_table() {
entries=()
missing=()
while IFS="$(printf '\xac')" read -r _ title _ _ _ filename crc _; do
[ -n "$crc" ] || continue
[[ "${filename,,}" == *.3ds ]] || continue
xorpad=$(echo *.${crc,,}.Main.exheader.xorpad)
read -r number _ title <<< "$title"
entries+=("$number | $title | $crc | ${xorpad:+"[${xorpad:0:16}](../raw/master/$xorpad)"}")
if [ -z "$xorpad" ]; then
missing+=("$number | $title | $crc")
fi
done
if [ "$1" = missing -a ${#missing[@]} -gt 0 ]; then
echo
echo "Number | Title | CRC32"
echo "-------|-------|------"
printf '%s\n' "${missing[@]}"
fi
if [ "$1" != missing ]; then
echo
echo "Number | Title | CRC32 | Exheader Xorpad"
echo "-------|-------|-------|----------------"
printf '%s\n' "${entries[@]}"
fi
echo
}
rm -f *.dat
get_dat_files
echo "### Navigate this page:"
echo "1. [Missing Nintendo - New Nintendo 3DS](#missing-nintendo---new-nintendo-3ds)"
echo "1. [Missing Nintendo - New Nintendo 3DS (DLC)](#missing-nintendo---new-nintendo-3ds-dlc)"
echo "1. [Missing Nintendo - Nintendo 3DS](#missing-nintendo---nintendo-3ds)"
echo "1. [Missing Nintendo - Nintendo 3DS (DLC)](#missing-nintendo---nintendo-3ds-dlc)"
echo "1. [Nintendo - New Nintendo 3DS](#nintendo---new-nintendo-3ds)"
echo "1. [Nintendo - New Nintendo 3DS (DLC)](#nintendo---new-nintendo-3ds-dlc)"
echo "1. [Nintendo - Nintendo 3DS](#nintendo---nintendo-3ds)"
echo "1. [Nintendo - Nintendo 3DS (DLC)](#nintendo---nintendo-3ds-dlc)"
echo
echo "## Missing Nintendo - New Nintendo 3DS"
print_table missing < "./Nintendo - New Nintendo 3DS ("[0-9]*.dat
echo "## Missing Nintendo - New Nintendo 3DS (DLC)"
print_table missing < "./Nintendo - New Nintendo 3DS (DLC) "*.dat
echo "## Missing Nintendo - Nintendo 3DS"
print_table missing < "./Nintendo - Nintendo 3DS ("[0-9]*.dat
echo "## Missing Nintendo - Nintendo 3DS (DLC)"
print_table missing < "./Nintendo - Nintendo 3DS (DLC) "*.dat
echo "## Nintendo - New Nintendo 3DS"
print_table < "./Nintendo - New Nintendo 3DS ("[0-9]*.dat
echo "## Nintendo - New Nintendo 3DS (DLC)"
print_table < "./Nintendo - New Nintendo 3DS (DLC) "*.dat
echo "## Nintendo - Nintendo 3DS"
print_table < "./Nintendo - Nintendo 3DS ("[0-9]*.dat
echo "## Nintendo - Nintendo 3DS (DLC)"
print_table < "./Nintendo - Nintendo 3DS (DLC) "*.dat