Skip to content

Instantly share code, notes, and snippets.

@p4block
Last active May 13, 2024 23:09
Show Gist options
  • Save p4block/7ced3239b3283a5739cf58e175758e81 to your computer and use it in GitHub Desktop.
Save p4block/7ced3239b3283a5739cf58e175758e81 to your computer and use it in GitHub Desktop.
Script to download all patches available in PSN for a given game serial
import requests
from bs4 import BeautifulSoup
import sys
def download_patches(game_id):
# Construct the URL to download the XML file
xml_url = f"https://a0.ww.np.dl.playstation.net/tpl/np/{game_id}/{game_id}-ver.xml"
# Make a request to download the XML, ignoring SSL errors
response = requests.get(xml_url, verify=False)
if response.status_code!= 200:
print("Failed to download XML")
return
# Parse the XML to find all patch URLs
soup = BeautifulSoup(response.text, 'xml')
patch_urls = [item['url'] for item in soup.find_all('package')]
# Download each patch, ignoring SSL errors
for url in patch_urls:
patch_name = url.split('/')[-1]
print(f"Downloading {patch_name}...")
patch_response = requests.get(url, verify=False)
if patch_response.status_code == 200:
with open(patch_name, 'wb') as file:
file.write(patch_response.content)
print(f"Downloaded {patch_name} successfully.")
else:
print(f"Failed to download {patch_name}.")
if __name__ == "__main__":
if len(sys.argv)!= 2:
print("Usage: python dl.py <PS3_GAME_ID>")
else:
game_id = sys.argv[1]
download_patches(game_id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment