sahlberg / pop-fe

Python script to automate the process of fetching boxart and installing PS1 games (onto your PSP/VITA/PS2/PS3)
160 stars 15 forks source link

TypeError when Creating SND0 AT3s #212

Closed sremp closed 2 weeks ago

sremp commented 1 month ago

I am using pop-fe to create PKGs for a number of PSX backups. Getting a TypeError when pop-fe calls parse_riff() during SND0 AT3 conversion:

Creating SND0.AT3
Traceback (most recent call last):
  File "/home/anvil/pop-fe/./pop-fe.py", line 4584, in <module>
    create_ps3(args.ps3_pkg, disc_ids, game_title, icon0, pic0, pic1, cue_files, cu2_files, img_files, mem_cards, aea_files, magic_word, resolution, snd0=snd0, subdir=subdir, whole_disk=args.whole_disk, subchannels=subchannels, configs=ps3configs)
  File "/home/anvil/pop-fe/./pop-fe.py", line 3041, in create_ps3
    convert_snd0_to_at3(snd0, f + '/SND0.AT3', 299, 2500000, subdir=subdir)
  File "/home/anvil/pop-fe/./pop-fe.py", line 2250, in convert_snd0_to_at3
    s = parse_riff(snd0)
  File "/home/anvil/pop-fe/riff.py", line 51, in parse_riff
    with open(riff, 'rb') as f:
TypeError: expected str, bytes or os.PathLike object, not NoneType

I've tried this with two different .CUEs with the same result. I've also tried to use --snd0=auto with the same error.

FWIW when I don't use the --snd0=auto flag, I see pop-fe-work/SND0.tmp. However when I do use --snd0=auto, I see an MP4 track in pop-fe-work instead.

I have a feeling this might be something with my Python environment, or my atracdenc install. Either way, any help would be appreciated. Thanks!

EDIT: I'm on Ubuntu WSL2 using Python 3.10

sahlberg commented 1 month ago

Do you have ffmpeg installed?

sremp commented 1 month ago

I thought I did, but turns out it was installed on a different Linux box I'm running and not on my WSL Ubuntu. Thank you!

No longer erroring on SND0. However, I'm getting a NameError: name 'AES' is not defined when creating ISO.BIN.EDAT:

Create ISO.BIN.EDAT
Traceback (most recent call last):
  File "/home/anvil/pop-fe/./pop-fe.py", line 4584, in <module>
    create_ps3(args.ps3_pkg, disc_ids, game_title, icon0, pic0, pic1, cue_files, cu2_files, img_files, mem_cards, aea_files, magic_word, resolution, snd0=snd0, subdir=subdir, whole_disk=args.whole_disk, subchannels=subchannels, configs=ps3configs)
  File "/home/anvil/pop-fe/./pop-fe.py", line 3215, in create_ps3
    pack(subdir + '%s/USRDIR/ISO.BIN.DAT' % disc_ids[0],
  File "/home/anvil/pop-fe/make_isoedat.py", line 129, in pack
    npd['title_hash'] = aes_cmac(key, b)
  File "/home/anvil/pop-fe/make_isoedat.py", line 60, in aes_cmac
    K1, K2 = generate_subkeys(K)
  File "/home/anvil/pop-fe/make_isoedat.py", line 50, in generate_subkeys
    obj = AES.new(KEY, AES.MODE_ECB)
NameError: name 'AES' is not defined

One interesting thing here, when I run ./pop-fe.py --install it gives me some output about how Crypto is not installed:

$ ./pop-fe.py --install
Crypto is not installed.
You should install Crypto by running:
pip3 install Crypto
Crypto is not installed.
You should install Crypto by running:
pip3 install Crypto

But checking that dependency I see Crypto is already installed:

$ pip3 install crypto
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: crypto in /home/anvil/.local/lib/python3.10/site-packages (1.4.1)
Requirement already satisfied: Naked in /home/anvil/.local/lib/python3.10/site-packages (from crypto) (0.1.32)
Requirement already satisfied: shellescape in /home/anvil/.local/lib/python3.10/site-packages (from crypto) (3.8.1)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (from Naked->crypto) (2.25.1)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from Naked->crypto) (5.4.1)
sahlberg commented 3 weeks ago

Yeah, the crypto module on linux is a mess between different versions. Try installing cryptodome instead of crypto

sremp commented 2 weeks ago

That did the trick! Cryptodome works on WSL2 Ubuntu 22.04:

$ pip3 install pycryptodome
...
$ ./pop-fe.py --ps3-pkg=Castlevania-SotN.pkg /mnt/c/Users/sremp/ps3/ps1/Castlevania\ -\ Symphony\ of\ the\ Night\ \(USA\).cue
Processing /mnt/c/Users/sremp/ps3/ps1/Castlevania - Symphony of the Night (USA).cue ...
[INFO]  Output directory: /home/anvil/pop-fe/pop-fe-work
[INFO]  Opening cue: /mnt/c/Users/sremp/ps3/ps1/Castlevania - Symphony of the Night (USA).cue
[INFO]  Merging 2 tracks...
[INFO]  Wrote /home/anvil/pop-fe/pop-fe-work/MB0.bin
[INFO]  Wrote new cue: /home/anvil/pop-fe/pop-fe-work/MB0.cue
MD5 fingerprint 683ad4d6ed945e2b589efb3d71596733
Converting pop-fe-work/TRACK_0_02.wav to pop-fe-work/TRACK_0_02.aea
Found cached prebuilt PIC0 https://github.com/sahlberg/pop-fe-assets/raw/master/pic0/689c3e1f2681ba2e4cc043fe24240eef
Found cached prebuilt PIC1 https://github.com/sahlberg/pop-fe-assets/raw/master/pic1/9b69f925a1f42b2310bb7db06d1ce718
Id: SLUS00067
Title: CASTLEVANIA - SYMPHONY OF THE NIGHT
Found cached prebuilt SND0 https://github.com/sahlberg/pop-fe-assets/raw/master/snd0/2bab4ce2eb558ea5ef2161535dc0bb23
GameID pop-fe-work/SLUS00067
Creating SND0.AT3
Creating temporary WAV file clamped to 299 second duration pop-fe-work/SND0.WAV
Create pop-fe-work/SLUS00067/SND0.AT3 from pop-fe-work/SND0.EA3
Create EBOOT.PBP at pop-fe-work/SLUS00067/USRDIR/CONTENT/EBOOT.PBP
Injecting MAGIC WORD 0x00000000 for disc 0
Inject pop-fe-work/TRACK_0_02.aea at 202cde00
Create ISO.BIN.DAT pop-fe-work/SLUS00067/USRDIR/ISO.BIN.DAT
Signing pop-fe-work/SLUS00067/USRDIR/ISO.BIN.DAT
Create ISO.BIN.EDAT
Create PKG
[X] Magic: 7f504b47
[X] Type: 00000001
[X] Offset to package info: 000000c0
[ ] unk1: 00000005
[X] Head Size: 00000080
[X] Item Count: 00000012
[X] Package Size: 0000000020cc62b0
[X] Data Offset: 0000000000000140
[X] Data Size: 0000000020cc6110
[X] ContentID: 'UP9000-SLUS00067_00-0000000000000001'
[X] QA_Digest: 057a16cc4a299ab0e7fa97251dd2fd2a
[X] K Licensee: 00000000000000000000000000000000

Finished. Castlevania-SotN.pkg created

Thanks a ton. Let me know if you wish to include any notes regarding this in the documentation. Would be more than happy to assist.

EDIT: nevermind, I see you already made some updates! All of your hard work is appreciated.