diff --git a/pop-fe-psp.py b/pop-fe-psp.py index 33e3382..735108e 100644 --- a/pop-fe-psp.py +++ b/pop-fe-psp.py @@ -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: @@ -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') @@ -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)