File size: 1,468 Bytes
8cc0fc3
 
 
 
 
 
c79e04f
 
 
8cc0fc3
 
 
 
 
 
 
 
 
 
 
 
 
15a724a
8cc0fc3
15a724a
8cc0fc3
 
 
15a724a
8cc0fc3
 
 
dc4d927
8cc0fc3
15a724a
40e82af
dc4d927
8cc0fc3
dcd0764
8cc0fc3
114bbc1
15a724a
 
8cc0fc3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import hmac
import hashlib
import binascii
import requests
import xml.etree.ElementTree as ET
from tqdm import tqdm
import urllib3

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

def generate_url(GameID):
    byte_key = binascii.unhexlify("AD62E37F905E06BC19593142281C112CEC0E7EC3E97EFDCAEFCDBAAFA6378D84")
    hash = hmac.new(byte_key, ("np_" + GameID).encode('utf-8'), digestmod=hashlib.sha256)
    hash = hash.hexdigest()
    url = f"https://gs-sec.ww.np.dl.playstation.net/plo/np/{GameID}/{hash}/{GameID}-ver.xml"
    return url

for number in tqdm(range(1, 45000)):
    GameID = f"CUSA{number:05}"
    url = generate_url(GameID)

    try:
        
        response = requests.get(url,verify=False)
        response.raise_for_status()  
        xml_content = response.content

        root = ET.fromstring(xml_content)
        
        title_id = root.attrib["titleid"]
        title = root.find(".//title").text
        version = root.find(".//package").attrib["version"]
        #content_id = root.find(".//package").attrib["content_id"]

        
        with open("extracted_info.txt", "w", encoding="utf-8") as info_file:
            info_file.write(f"{title_id},{title},{version}\n")

        print(f"\r{GameID}:{title} - COMPLETE", end="")
    except (requests.exceptions.RequestException, ET.ParseError) as e:
        print(f"\r{GameID} - Game not exist", end="")
        continue  
        
print("Extraction and writing completed!")