Skip to content

Instantly share code, notes, and snippets.

@Sanaki
Last active January 17, 2021 22:55
Show Gist options
  • Save Sanaki/b6a65a5c91f9b7f09a0cda54292b87ef to your computer and use it in GitHub Desktop.
Save Sanaki/b6a65a5c91f9b7f09a0cda54292b87ef to your computer and use it in GitHub Desktop.
Generate RetroAchievements hash lists for FBNeo sets
#!/usr/bin/env bash
function getfbninfo {
path=$HOME"/.local/share/fbneo/dats/"
[[ $2 = "bare" ]] && file=${1##*/} || file=${1#./}
file=${file%.7z}
case "${file%%/*}" in
"coleco")
dat="FBNeo_-_ColecoVision.dat"
;;
"msx")
dat="FBNeo_-_MSX.dat"
;;
"pce")
dat="FBNeo_-_PC_ENGINE.dat"
;;
"sgx")
dat="FBNeo_-_PC_Engine_SuperGrafx.dat"
;;
"tg16")
dat="FBNeo_-_TurboGrafx-16.dat"
;;
"nes")
dat="FBNeo_-_Nintendo_Entertainment_System.dat"
;;
"fds")
dat="FBNeo_-_Nintendo_Famicom_Disk_System.dat"
;;
"gamegear")
dat="FBNeo_-_Sega_Game_Gear.dat"
;;
"sms")
dat="FBNeo_-_Sega_Master_System.dat"
;;
"megadriv")
dat="FBNeo_-_MegaDrive.dat"
;;
"sg1000")
dat="FBNeo_-_Sega_SG-1000.dat"
;;
"spectrum")
dat="FBNeo_-_Sinclair_ZX_Spectrum.dat"
;;
"ngp")
dat="FBNeo_-_Neo_Geo_Pocket.dat"
;;
*)
dat="FBNeo_-_Arcade.dat"
;;
esac
desc=$(grep -P -A 1 "name=\"${file##*/}\"" "$path$dat" | grep -Po '(?<=description>).+(?=<)')
echo $file".7z <"$desc">"
}
export -f getfbninfo
hashdir=$HOME"/Documents/RA/Hashes/FBNeo/"
cd ~/ROMs/FBNeo
awk '{printf("%s%s",$0,(NR%2)?"\t":"\n")}' <(find . -iname "*.7z" -exec bash -c 'getfbninfo "{}" bare' \; -exec RAHasher 27 {} \;)|sort|tr '\t' '\n' > ${hashdir}arcade.txt
cd "../SNK - Neo Geo"
for i in *.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}neogeo.txt
cd "../FBNeo Consoles"
for i in coleco/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}coleco.txt
for i in msx/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}msx.txt
for i in pce/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}pce.txt
for i in sg1000/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}sg1000.txt
for i in sgx/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}sgx.txt
for i in tg16/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}tg16.txt
for i in nes/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}nes.txt
for i in fds/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}fds.txt
for i in gamegear/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}gamegear.txt
for i in sms/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}sms.txt
for i in megadriv/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}megadriv.txt
for i in spectrum/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}spectrum.txt
for i in ngp/*.7z; do getfbninfo "$i"; RAHasher 27 "$i"; done > ${hashdir}ngp.txt
rsync -avhP --stats --delete ~/Documents/RA/Hashes/FBNeo/ /keybase/public/kickmeelmo/Hashes/FBNeo/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment