Getting Patch Files for PS3 Games in RPCS3

I just started playing with RPCS3, the excellent emulator for Sony Playstation 3 games. After extracting a few of my games from disc, I found out that for a number of them, they will not play correctly unless they have been patched to the latest revision (see the section Installing PlayStation 3 Game Updates in the RPCS Quickstart guide).

After some digging around the internet, I found that the patches can be downloaded from Sony via a URL that returns an XML list of all the available patches for a given game serial number. Some of the games have quite a lot of patches (remember the days when games were fully tested before being released, and any missed bugs were “features”?).

Well, rather than clicking on each URL and manually downloading from a browser, I did what any lazy engineer does and wrote a quick script to let the computer do the work. I thought I would share for anyone else what wanted to quickly snag the patches; at least while they are still available from Sony. This works as is on the Mac. You will need to make sure you install the xpath command on Ubuntu or whatever distro you are using. If you are on Windows, well, I’m sorry for you.

#!/bin/bash

# The GAMEID is the serial number (disc ID) of the game.  In RPCS3,
# it is listed as serial number.  That is the only parameter to the script.
#
# by Scott Garrett - www.technomancer.com

if [ ! "$( which xpath )" ]
then
	echo "This script requires the xpath command."
	echo "In Ubuntu, you install it with:"
	echo
	echo "sudo apt install libxml-xpath-perl"
	exit 1
fi

GAMEID=$1

if [ ! "${GAMEID}" ]
then
	echo "Please specify the serial ID of the game you want patches for."
	echo "e.g. BCUS98119"
	exit 1
fi

# This is the URL at Sony to download patches, at least until
# they stop supplying them.

PARENTURL=https://a0.ww.np.dl.playstation.net/tpl/np/

# This will make a directory for the patches based on the
# serial ID.  It will be created even if there are no patches
# to mark that you made the attempt and there were none.
mkdir -p "${GAMEID}"

# Grab the XML of the patch information for the particular GAMEID.
# Extract out just the "url" attributes of the packages, eval them into a variable "url"
# then pull down the files.

curl -s -k -L "${PARENTURL}/${GAMEID}/${GAMEID}-ver.xml" | xpath -q -e "titlepatch/tag/package/@url" 2>/dev/null | while read XML
do
	# Since xpath outputs the attribute @url in 'url="blah"' format, we can
	# just use that as the variable for the curl.
	eval "${XML}"

	# url here is taken from the 'url="blah"' output from the xpath above.
	echo "$( basename ${url} )"
	curl -s -k -L --output-dir "${GAMEID}" -O "${url}"
done

Leave a Comment