Skip to content

Commit

Permalink
pop-fe-psp: add support for zip and chd files
Browse files Browse the repository at this point in the history
Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
  • Loading branch information
sahlberg committed Aug 14, 2023
1 parent 2c168a2 commit dfb6885
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion pop-fe-psp.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
import os
import pathlib
import pygubu
import re
import shutil
import subprocess
import tkinter as tk
import tkinter.ttk as ttk
import zipfile

have_pytube = False
try:
Expand Down Expand Up @@ -141,7 +143,7 @@ def init_data(self):
for idx in range(1,6):
self.builder.get_object('discid%d' % (idx), self.master).config(state='disabled')
for idx in range(1,5):
self.builder.get_object('disc' + str(idx), self.master).config(filetypes=[('Image files', ['.cue', '.bin', '.ccd', '.img']), ('All Files', ['*.*', '*'])])
self.builder.get_object('disc' + str(idx), self.master).config(filetypes=[('Image files', ['.cue', '.bin', '.ccd', '.img', '.zip', '.chd']), ('All Files', ['*.*', '*'])])
self.builder.get_variable('disc%d_variable' % (idx)).set('')
self.builder.get_variable('discid%d_variable' % (idx)).set('')
self.builder.get_object('disc' + str(idx), self.master).config(state='disabled')
Expand Down Expand Up @@ -170,6 +172,33 @@ 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 = 'pop-fe-psp-work/CDH%s.cue' % disc
tmpbin = 'pop-fe-psp-work/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', 'pop-fe-psp-work/' + f) if verbose else None
temp_files.append('pop-fe-psp-work/' + f)
zf.extract(f, path='pop-fe-psp-work/')
if re.search('.cue$', f):
print('Found CUE file', f) if verbose else None
cue_file = 'pop-fe-psp-work/' + f
self.cue_file_orig = cue_file
if cue_file[-4:] == '.ccd':
tmpcue = 'pop-fe-psp-work/TMPCUE' + disc + '.cue'
temp_files.append(tmpcue)
Expand Down

0 comments on commit dfb6885

Please sign in to comment.