Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #HOW TO USE
- #INSTALL PYTHON (TESTED WITH 3.6)
- #NAVIGATE TO PYTHON INSTALLATION'S SCRIPTS FOLDER
- #USE THE COMMAND 'pip install requests' IN THIS FOLDER VIA COMMAND LINE
- #COPY THIS ENTIRE TEXT
- #SAVE IT AS "mydlc.py" ANYWHERE YOU LIKE
- #DOUBLE CLICK "mydlc.py"
- #THE PROGRAM WILL BEGIN RUNNING
- #READ ALL PROMPTS. ADDITIONAL STEPS ARE REQUIRED.
- #INSTALL ALL CREATED PKGS
- #This script contains no content which in any way
- #Infringes on the Intellectual Property of Sony.
- #Package creation is done solely through a third
- #party tool that the user may choose to download.
- #This script seeks to read publicly viewable
- #PSN Storepages and parse the publicly available
- #DLC names and IDs.
- #Absolutely no ownership of this script is claimed by the uploader.
- import os
- import re
- import sys
- import time
- try:
- import requests
- except:
- print("Required library \"requests\" could not be loaded\nPlease perform a 'pip install requests'\nin your Python's \"Scripts\" folder.")
- input("Press enter to close this program")
- sys.exit()
- s = requests.Session() #Global requests session for all future network activity
- waittime = 2
- def download(url, fname):
- r = s.get(url)
- with open(fname, 'wb') as f:
- for chunk in r.iter_content(chunk_size=1024):
- if chunk:
- f.write(chunk)
- print("Download Complete!")
- return 1
- def textReplace(fname, look4, replacement):
- with open(fname, 'r') as file :
- filedata = file.read()
- if look4 in filedata:
- print("Replacing \"", look4, "\" with '", replacement, "' in ", fname)
- filedata = filedata.replace(look4, replacement)
- with open(fname, 'w') as file:
- file.write(filedata)
- return 1
- return 0
- def prerequisite():
- psxhaxurl = "https://www.psxhax.com/threads/fake-pkg-generator-for-ps4-to-generate-fake-packages-for-homebrew.3444/"
- pastebinurl = "https://pastebin.com/raw/amqJduwg"
- if not os.path.exists('ez_dlc.py'):
- print("Downloading \'ez_dlc.py\' from pastebin.\n", pastebinurl)
- try:
- download( pastebinurl, "ez_dlc.py" )
- except:
- print("Downloading ez_dlc.py from ", pastebinurl, " failed")
- input("Press enter to close this program")
- sys.exit()
- if not os.path.exists('orbis-pub-cmd.exe'):
- print("Please read the \"readme.txt\".\norbis-pub-cmd.exe must be in the same folder as this python script\n\nDownload from\n", psxhaxurl)
- input("Press enter to close this program")
- sys.exit()
- textReplace("ez_dlc.py", "return open(path, 'w')", "return open(path, 'w', encoding=\"utf-8\")") #FIX ENCODING ISSUE WITH EZ_DLC.PY
- return 1
- def downloadDLC(inputstorepage):
- fulltitleID = inputstorepage.split('/')[-1]
- region = inputstorepage.split('/')[-3]
- addonpage = "https://store.playstation.com/" + region + "/grid/" + str(fulltitleID) + "/" + str(1) + "?relationship=add-ons?platform=ps4"
- print("TITLE_ID: ", fulltitleID)
- print("ADDON_PAGE: ", addonpage)
- r = s.get(addonpage)
- numofpages = 1
- try:
- numofpages = int(max(re.findall("\w\w-\w\w/grid/\w\w\d+-\wUSA\d+_\d+-.*?/(\d+)", r.text)))
- except:
- numofpages = 1
- print("Found ", numofpages, " pages of content.")
- for i in range(1, numofpages+1):
- print("Handling Page ", i, "\n")
- r = s.get( "https://store.playstation.com/" + region + "/grid/" + fulltitleID + "/" + str(i) + "?relationship=add-ons" )
- DLClist = re.findall("\"Product\",\"name\":\"(.*?)\".*?sku\":\"(.*?)\"", r.text)
- for DLC in DLClist:
- print(DLC[0], DLC[1])
- command = "ez_dlc.py " + DLC[1] + " \"" + DLC[0] + "\""
- print("Running Command: ", command)
- os.system(command)
- print("\n")
- print("Waiting 2 seconds between DLCs.")
- time.sleep(waittime)
- if i < numofpages:
- print("Waiting ", waittime, " seconds between processing pages.")
- time.sleep(waittime)
- try:
- os.rename("fake_dlc_pkg", fulltitleID[7:])
- except:
- pass
- return 1
- def regURL(url, regexp):
- r = s.get(url)
- pattern = re.findall(regexp, r.text)
- return pattern
- def getpkglist(inputdir):
- pkglist = []
- for path, subdirs, files in os.walk(inputdir):
- for name in files:
- if ".pkg" in name:
- pkglist.append(os.path.join(path, name))
- return pkglist
- def determinepkgid(inputfpath): #Tries to read 36 character TITLEID from beginning of PKG #0x40 - 0x64
- mystr = ""
- print(inputfpath)
- with open(inputfpath, "rb") as input:
- data = input.read(128)
- for i in range (64, 100+1):
- mystr+= (str(chr(data[i])))
- return mystr.replace(" ", "")
- prerequisite()
- #USER PASTES A SINGLE PSN STORE PAGE. ALL DLC ON PAGE DOWNLOADED
- userinput = True
- #USER PASTES A DIRECTORY CONTAINING PKG (ALSO SCANS SUBDIRECTORIES). ATTEMPTS TO DOWNLOAD DLC FOR ALL PKGS
- dirscan = False
- #SIMPLE TEST ON SINGLE PRE-DEFINED PSN STORE PAGE
- performtest = False
- if(dirscan):
- inputdir = input("Paste a directory containing pkgs: ")
- mypkglist = getpkglist(inputdir)
- for pkg in mypkglist:
- pkgid = determinepkgid(pkg)
- psnpage = ""
- pkgregion = pkgid[:2]
- if(pkgregion == "UP"):
- psnpage = "https://store.playstation.com/en-us/product/" + pkgid
- elif(pkgregion == "EP"):
- psnpage = "https://store.playstation.com/en-gb/product/" + pkgid
- elif(pkgregion == "HP"):
- psnpage = "https://store.playstation.com/en-hk/product/" + pkgid
- elif(pkgregion == "JP"):
- psnpage = "https://store.playstation.com/ja-jp/product/" + pkgid
- else:
- psnpage = "error!"
- psnpage = psnpage[:-1]
- print(psnpage)
- try:
- print(" ")
- downloadDLC(psnpage)
- except:
- pass
- if(performtest):
- storepage = "https://store.playstation.com/en-gb/product/UP9000-CUSA03694_00-GRAVITYRUSH20000" #WORKS
- downloadDLC(storepage)
- if(userinput):
- print("Please paste a link to a PSN game store page which contains \"add-on\" content.\nExample: https://store.playstation.com/en-us/product/UP8802-CUSA02084_00-RBEXPANSIONPACK1\n")
- storepage = input("PASTE HERE: ")
- downloadDLC(storepage)
- print("Program Completed.")
- input("Press enter to close this program")
- sys.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement