Last active
October 2, 2024 13:26
-
-
Save pxdl/ace6325154fac10c9211ac1cf3cfab85 to your computer and use it in GitHub Desktop.
Converts the NoPayStation TSV for PS3 Games to pkgi-ps3 format
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import csv | |
import urllib.request | |
url = "http://nopaystation.com/tsv/PS3_GAMES.tsv" | |
print('Downloading PS3_GAMES.tsv...') | |
urllib.request.urlretrieve(url, 'PS3_GAMES.tsv') | |
newlist = [] | |
with open('PS3_GAMES.tsv', newline='', encoding="utf8") as csvfile: | |
listreader = csv.reader(csvfile, delimiter=' ', quotechar='"') | |
csvfile.readline() # Skip first line | |
print("Rearranging list...") | |
for row in listreader: | |
newrow = [] | |
newrow.append(row[5]) # Content ID | |
newrow.append('0') # Flags (unused) | |
newrow.append(row[2]) # Name | |
newrow.append('') # Description (unused) | |
newrow.append('') # RAP file in HEX (16 bytes) | |
newrow.append(row[3]) # PKG Download Link | |
newrow.append(row[8]) # Filesize | |
newrow.append(row[9]) # Checksum | |
newlist.append(newrow) | |
with open('pkgi.txt', 'w', newline='', encoding="utf8") as csvfile: | |
listwriter = csv.writer(csvfile, delimiter=',', | |
quotechar='"', quoting=csv.QUOTE_MINIMAL) | |
print('Saving pkgi.txt...') | |
for newrow in newlist: | |
listwriter.writerow(newrow) |
Heres a Ruby version of this script:
#!/bin/ruby
require 'csv'
require 'open-uri'
def convert_file(url:, output_filename:, content_type_id: 0)
tmp_filename = url.split("/").last
File.write(
tmp_filename,
URI.open(url).read.gsub('"', '') # read file from URL and remove any double quotes
)
File.open(output_filename, 'wb') do |f|
CSV.foreach(tmp_filename, headers: false, col_sep: "\t") do |row|
f.write [
row[5], # Content ID
content_type_id, # Content Type ID, https://pkgi.psdev.tk/#content-types
row[2], # Name
'', # Description
'', # RAP HEX String, actually contained in row[4]
row[3], # PKG Download Link
row[8], # Filesize
row[9], # Checksum
].join(",")
f.write "\n"
end
end
end
convert_file(url: "https://nopaystation.com/tsv/PS3_GAMES.tsv", output_filename: "pkgi_games.txt", content_type_id: 1)
convert_file(url: "https://nopaystation.com/tsv/PS3_DLCS.tsv", output_filename: "pkgi_dlcs.txt", content_type_id: 2)
wdmycloud only has python 2, and 3(or most anything) is a pita to install on it.
could someone try to convert this to python 2.7?
i tried to use 3to2 from here
https://pypi.org/project/3to2/
but i had to build it in 2.7, and i'm not sure if it worked.
i got a lot of command not found errors.
Here's the version of the script with @ChronosWasTaken's suggested edit:
import csv
import urllib.request
url = "http://nopaystation.com/tsv/PS3_GAMES.tsv"
print('Downloading PS3_GAMES.tsv...')
req = urllib.request.Request(url, data=None, headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36'})
with open('PS3_GAMES.tsv', 'wb') as file:
file.write(urllib.request.urlopen(req).read())
newlist = []
with open('PS3_GAMES.tsv', newline='', encoding="utf8") as csvfile:
listreader = csv.reader(csvfile, delimiter=' ', quotechar='"')
csvfile.readline() # Skip first line
print("Rearranging list...")
for row in listreader:
newrow = []
newrow.append(row[5]) # Content ID
newrow.append('0') # Flags (unused)
newrow.append(row[2]) # Name
newrow.append('') # Description (unused)
newrow.append('') # RAP file in HEX (16 bytes)
newrow.append(row[3]) # PKG Download Link
newrow.append(row[8]) # Filesize
newrow.append(row[9]) # Checksum
newlist.append(newrow)
with open('pkgi.txt', 'w', newline='', encoding="utf8") as csvfile:
listwriter = csv.writer(csvfile, delimiter=',',
quotechar='"', quoting=csv.QUOTE_MINIMAL)
print('Saving pkgi.txt...')
for newrow in newlist:
listwriter.writerow(newrow)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NPS doesn't let you touch their files without an User Agent, try