Skip to content

Commit

Permalink
swithc pop-fe-ps[3p] to use the new processing function
Browse files Browse the repository at this point in the history
Signed-off-by: Ronnie Sahlberg <[email protected]>
  • Loading branch information
sahlberg committed Aug 2, 2024
1 parent 72f44a4 commit a90495d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 132 deletions.
66 changes: 3 additions & 63 deletions pop-fe-ps3.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,70 +325,10 @@ def on_path_changed(self, event):
print('Processing', cue_file) if verbose else None
disc = event.widget.cget('title')
print('Disc', disc) if verbose else None
idx = int(disc[1])

if cue_file[-4:] == '.chd':
print('This is a CHD file. Uncompress the file.') if verbose else None
chd = cue_file
try:
tmpcue = self.subdir + 'CDH%s.cue' % disc
tmpbin = self.subdir + 'CDH%s.bin' % disc
temp_files.append(tmpcue)
temp_files.append(tmpbin)
print('Extracting', tmpcue, 'and', tmpbin, 'chd') if verbose else None
subprocess.run(['chdman', 'extractcd', '-f', '-i', chd, '-ob', tmpbin, '-o', tmpcue], check=True)
except:
print('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nCHDMAN not found.\nCan not convert game\nPlease see README file for how to install chdman\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
os._exit(10)
cue_file = tmpcue
self.cue_file_orig = cue_file
if cue_file[-4:] == '.zip':
print('This is a ZIP file. Uncompress the file.') if verbose else None
zip = cue_file
with zipfile.ZipFile(zip, 'r') as zf:
for f in zf.namelist():
print('Extracting', self.subdir + f) if verbose else None
temp_files.append(self.subdir + f)
zf.extract(f, path=self.subdir)
if re.search('.cue$', f):
print('Found CUE file', f) if verbose else None
cue_file = self.subdir + f
self.cue_file_orig = cue_file

if cue_file[-4:] == '.ccd':
tmpcue = self.subdir + 'TMPCUE' + disc + '.cue'
temp_files.append(tmpcue)
ccd = parse_ccd(cue_file)
cue = ccd2cue(ccd)
write_cue(cue, tmpcue)
cue_file = tmpcue
if cue_file[-4:] == '.bin' or cue_file[-4:] == '.img':
tmpcue = self.subdir + 'TMPCUE' + disc + '.cue'
tmpimg = self.subdir + 'TMPIMG' + disc + '.bin'
print('Need to create a temporary cue/bin', tmpcue, tmpimg)
temp_files.append(tmpcue)
temp_files.append(tmpimg)
popfe.copy_file(cue_file, tmpimg)

with open(tmpcue, "w") as f:
f.write('FILE "%s" BINARY\n' % ('TMPIMG' + disc + '.bin'))
f.write(' TRACK 01 MODE2/2352\n')
f.write(' INDEX 01 00:00:00\n')
img_file = cue_file
cue_file = tmpcue
else:
i = popfe.get_imgs_from_bin(cue_file)
img_file = i[0]
if len(i) > 1:
print('Merging multi-bin disc') if verbose else None
mb = 'MB' + disc
if os.name == 'posix':
subprocess.call(['python3', './binmerge', '-o', 'pop-fe-ps3-work', cue_file, mb])
else:
subprocess.call(['binmerge.exe', '-o', 'pop-fe-ps3-work', cue_file, mb])
cue_file = self.subdir + mb + '.cue'
temp_files.append(cue_file)
img_file = self.subdir + mb + '.bin'
temp_files.append(img_file)
cue_file , real_cue_file, img_file = popfe.process_disk_file(cue_file, idx, temp_files, subdir=self.subdir)
self.cue_file_orig = real_cue_file

print('Scanning for Game ID') if verbose else None
tmp = self.subdir + 'TMP01.iso'
Expand Down
66 changes: 4 additions & 62 deletions pop-fe-psp.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,68 +276,10 @@ def on_path_changed(self, event):
print('Processing', cue_file) if verbose else None
disc = event.widget.cget('title')
print('Disc', disc) if verbose else None
if cue_file[-4:] == '.chd':
print('This is a CHD file. Uncompress the file.') if verbose else None
chd = cue_file
try:
tmpcue = self.subdir + 'CDH%s.cue' % disc
tmpbin = self.subdir + 'CDH%s.bin' % disc
temp_files.append(tmpcue)
temp_files.append(tmpbin)
print('Extracting', tmpcue, 'and', tmpbin, 'chd') if verbose else None
subprocess.run(['chdman', 'extractcd', '-f', '-i', chd, '-ob', tmpbin, '-o', tmpcue], check=True)
except:
print('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\nCHDMAN not found.\nCan not convert game\nPlease see README file for how to install chdman\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
os._exit(10)
cue_file = tmpcue
self.cue_file_orig = cue_file
if cue_file[-4:] == '.zip':
print('This is a ZIP file. Uncompress the file.') if verbose else None
zip = cue_file
with zipfile.ZipFile(zip, 'r') as zf:
for f in zf.namelist():
print('Extracting', self.subdir + f) if verbose else None
temp_files.append(self.subdir + f)
zf.extract(f, path=self.subdir)
if re.search('.cue$', f):
print('Found CUE file', f) if verbose else None
cue_file = self.subdir + f
self.cue_file_orig = cue_file
if cue_file[-4:] == '.ccd':
tmpcue = self.subdir + 'TMPCUE' + disc + '.cue'
temp_files.append(tmpcue)
ccd = parse_ccd(cue_file)
cue = ccd2cue(ccd)
write_cue(cue, tmpcue)
cue_file = tmpcue
if cue_file[-4:] == '.bin' or cue_file[-4:] == '.img':
tmpcue = self.subdir + 'TMPCUE' + disc + '.cue'
tmpimg = self.subdir + 'TMPIMG' + disc + '.bin'
print('Need to create a temporary cue/bin', tmpcue, tmpimg)
temp_files.append(tmpcue)
temp_files.append(tmpimg)
popfe.copy_file(cue_file, tmpimg)

with open(tmpcue, "w") as f:
f.write('FILE "%s" BINARY\n' % ('TMPIMG' + disc + '.bin'))
f.write(' TRACK 01 MODE2/2352\n')
f.write(' INDEX 01 00:00:00\n')
img_file = cue_file
cue_file = tmpcue
else:
i = popfe.get_imgs_from_bin(cue_file)
img_file = i[0]
if len(i) > 1:
print('Merging multi-bin disc') if verbose else None
mb = 'MB' + disc
if os.name == 'posix':
subprocess.call(['python3', './binmerge', '-o', self.subdir, cue_file, mb])
else:
subprocess.call(['binmerge.exe', '-o', self.subdir, cue_file, mb])
cue_file = self.subdir + mb + '.cue'
temp_files.append(cue_file)
img_file = self.subdir + mb + '.bin'
temp_files.append(img_file)
idx = int(disc[1])

cue_file , real_cue_file, img_file = popfe.process_disk_file(cue_file, idx, temp_files, subdir=self.subdir)
self.cue_file_orig = real_cue_file

print('Scanning for Game ID') if verbose else None
tmp = self.subdir + 'TMP01.iso'
Expand Down
14 changes: 7 additions & 7 deletions pop-fe.py
Original file line number Diff line number Diff line change
Expand Up @@ -4067,15 +4067,15 @@ def force_ntsc_config(ps3config):
c = c + bytes([0x20, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00])
return c

def process_disk_file(cue_file, temp_files, subdir='./'):
def process_disk_file(cue_file, idx, temp_files, subdir='./'):
real_cue_file = cue_file

if cue_file[-4:] == '.chd':
print('This is a CHD file. Uncompress the file.') if verbose else None
chd = cue_file
try:
tmpcue = subdir + 'CDH%d.cue' % (0 if not idx else idx[0])
tmpbin = subdir + 'CDH%d.bin' % (0 if not idx else idx[0])
tmpcue = subdir + 'CDH%d.cue' % (idx)
tmpbin = subdir + 'CDH%d.bin' % (idx)
temp_files.append(tmpcue)
temp_files.append(tmpbin)
print('Extracting', tmpcue, 'and', tmpbin, 'chd') if verbose else None
Expand Down Expand Up @@ -4104,7 +4104,7 @@ def process_disk_file(cue_file, temp_files, subdir='./'):
real_cue_file = cue_file

if cue_file[-3:] == 'img' or cue_file[-3:] == 'bin':
tmpcue = subdir + 'TMP%d.cue' % (0 if not idx else idx[0])
tmpcue = subdir + 'TMP%d.cue' % (idx)
print('IMG or BIN file. Create a temporary cue file for it', tmpcue) if verbose else None
temp_files.append(tmpcue)
with open(tmpcue, "w") as f:
Expand All @@ -4118,7 +4118,7 @@ def process_disk_file(cue_file, temp_files, subdir='./'):
real_cue_file = cue_file

if cue_file[-3:] == 'ccd':
tmpcue = subdir + 'TMP%d.cue' % (0 if not idx else idx[0])
tmpcue = subdir + 'TMP%d.cue' % (idx)
print('CCD file. Create a temporary cue file for it', tmpcue) if verbose else None
temp_files.append(tmpcue)
ccd = parse_ccd(cue_file)
Expand All @@ -4144,7 +4144,7 @@ def process_disk_file(cue_file, temp_files, subdir='./'):
os.stat('binmerge.exe')
except:
raise Exception('binmerge is required in order to support multi-bin disks. See README file for instructions on how to install binmerge.')
mb = 'MB%d' % (0 if not idx else idx[0])
mb = 'MB%d' % (idx)
temp_files.append(mb)
if os.name == 'posix':
subprocess.call(['python3', './binmerge', '-o', subdir, cue_file, mb])
Expand Down Expand Up @@ -4306,7 +4306,7 @@ def process_disk_file(cue_file, temp_files, subdir='./'):
zip = None
print('Processing', cue_file, '...')

cue_file , real_cue_file, img_file = process_disk_file(cue_file, temp_files, subdir=subdir)
cue_file , real_cue_file, img_file = process_disk_file(cue_file, 0 if not idx else idx[0], temp_files, subdir=subdir)

if not cue_file:
continue
Expand Down

0 comments on commit a90495d

Please sign in to comment.