Skip to content

Commit

Permalink
Add emulator handling from web scrapging
Browse files Browse the repository at this point in the history
  • Loading branch information
mdeguzis committed Feb 26, 2024
1 parent 77b7a6e commit c89470a
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions utilities/update-emulators.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,42 @@
#bash ${HOME}/.config/EmuDeck/backend/tools/binupdate/binupdate.sh
#!/bin/bash

curlit()
{
name=$1
search_url=$2
exe_match=$3
echo "[INFO] Updating $name (search for ${exe_match} on page"
curl -q -v "${search_url}" &> "/tmp/results.txt"
urls=$(awk -F"[><]" '{for(i=1;i<=NF;i++){if($i ~ /a href=.*\//){print "<" $i ">"}}}' "/tmp/results.txt")
rm -f "/tmp/results.txt"
urls_to_parse=()
for url in $urls;
do
if $(echo "${url}" | grep -q href) && $(echo "${url}" | grep -qE ${exe_match}); then
dl_url=$(echo "${url}" | sed 's/.*http/http/;s/".*//')

# which type?
echo "Found download url: ${dl_url}, processing"
filename=$(basename -- "${dl_url}")
file_type="${filename##*.}"
echo "Fileype: ${file_type}"
case $file_type in
"zip")
echo "Got a ZIP file"
curl -sLo "/tmp/${name}.zip" "${dl_url}"
unzip -o "/tmp/${name}.zip" -d "${HOME}/Applications/${name}"
;;
*)
echo "I don't know how to process ${file_type}, skipping..."
return 0
;;
esac
fi
done

}

update_emu_flatpak ()
{
name=$1;
Expand All @@ -31,6 +67,32 @@ update_windows_exe ()

}

update_steam_emu ()
{
name=$1;
exec_name=$2
app_dir="${HOME}/Applications/${name}"
echo "[INFO] Updating $name"

emu_location=$(find ~/.steam/steam/steamapps/ -name "${exec_name}")
if [[ -z "${emu_location}" ]]; then
echo "[ERROR] Could not find Steam app location for ${name} with exec name ${exec_name} ! Skipping..."
return
fi
mkdir -p "${app_dir}"
cp -v "${emu_location}" "${app_dir}"
}

update_from_curl ()
{
name=$1;
url_match=$2
app_dir="${HOME}/Applications/${name}"
echo "[INFO] Fetching release from ${url_match} for ${name}"

mkdir -p "${app_dir}"
cp -v "${emu_location}" "${app_dir}"
}

echo -e "[INFO] Updating emulators (Flatpaks)\n"
sleep 3
Expand All @@ -50,4 +112,10 @@ echo -e "\n[INFO] Updating Windows EXE's (e.g. xenia))"
update_windows_exe "xenia" "https://github.com/xenia-canary/xenia-canary/releases/download/experimental/xenia_canary.zip"
update_windows_exe "xenia" "https://github.com/xenia-project/release-builds-windows/releases/latest/download/xenia_master.zip"

echo -e "\n[INFO] Symlinking any emulators from Steam"

# https://steamdb.info/app/1147940/
update_steam_emu "3dSen" "3dSen.exe"

echo -e "[INFO] Updating emulators via webscraping\n"
curlit "BigPEmu" "https://www.richwhitehouse.com/jaguar/index.php?content=download" ".*BigPEmu.*[0-9].zip"

0 comments on commit c89470a

Please sign in to comment.