Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Patch in ps2/opl support for game scanning #330

Merged
merged 4 commits into from
Aug 8, 2023
Merged

Conversation

gantoine
Copy link
Member

@gantoine gantoine commented Aug 8, 2023

Patches in support for the OPL file naming convention. In the case where the filename start with a value matching the OPL serial regex (XXXX_000.00), use the name from the index to search IGDB. This also has the added benefit of using that name over the filename when the IGDB lookup fails.

Note: I chose to implement the index as an in-memory python dict due to it's relatively small size (1.1MB), and not having to load it in from a fixture file (JSON, YAML). In the future, objects like these can be stored in Redis to offload that memory footprint, while allowing for fast-ish access. Since you can't view it in github, here's the structure of that index:

opl_index = {
  "SLES_556.71": {
    "Name": "Fifa '14",
    "Region": "PAL"
  },
  "SLES_556.72": {
    "Name": "Fifa '14",
    "Region": "PAL"
  },
 ...
}
  • Also fixes a small bug with scan result reporting in client

cc @binarygeek119 if you want to have a look

Closes #324

Screenshot 2023-08-08 at 5 34 17 PM

@gantoine gantoine requested a review from zurdi15 August 8, 2023 21:54
@github-actions
Copy link

github-actions bot commented Aug 8, 2023

Test Results

24 tests  +1   24 ✔️ +1   2s ⏱️ ±0s
  1 suites ±0     0 💤 ±0 
  1 files   ±0     0 ±0 

Results for commit 3e97e9a. ± Comparison against base commit f5c5473.

♻️ This comment has been updated with latest results.

@zurdi15 zurdi15 merged commit c3a2975 into master Aug 8, 2023
3 checks passed
@zurdi15 zurdi15 deleted the ps2-opl-support branch August 11, 2023 07:33
zurdi15 added a commit that referenced this pull request Aug 27, 2023
Patch in ps2/opl support for game scanning
@binarygeek119
Copy link

i just tryed to load a ps2 game and got this error.
my game is named 1 but is 4x4 Evo (USA).iso

INFO:     [RomM][2023-08-31 05:06:34]   Identified as PlayStation 2 🎮
INFO:     [RomM][2023-08-31 05:06:34]    · SLUS_200.91.1.iso
Task exception was never retrieved
future: <Task finished name='Task-117' coro=<AsyncServer._handle_event_internal() done, defined at /usr/local/lib/python3.10/dist-packages/socketio/asyncio_server.py:522> exception=FileNotFoundError(2, 'No such file or directory')>
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/dist-packages/socketio/asyncio_server.py", line 524, in _handle_event_internal
    r = await server._trigger_event(data[0], namespace, sid, *data[1:])
  File "/usr/local/lib/python3.10/dist-packages/socketio/asyncio_server.py", line 558, in _trigger_event
    ret = await handler(*args)
  File "/back/endpoints/scan.py", line 97, in scan_handler
    await scan_platforms(platform_slugs, complete_rescan, selected_roms)
  File "/back/endpoints/scan.py", line 60, in scan_platforms
    scanned_rom = fastapi.scan_rom(scanned_platform, fs_rom)
  File "/back/utils/fastapi.py", line 60, in scan_rom
    file_size, file_size_units = fs.get_rom_size(
  File "/back/utils/fs.py", line 262, in get_rom_size
    total_size += os.stat(file).st_size
FileNotFoundError: [Errno 2] No such file or directory: '/romm/library/roms/ps2/SLUS_200.91.1.iso'

@gantoine
Copy link
Member Author

gantoine commented Aug 31, 2023

I tried it on my local setup and it worked fine:

INFO:     [RomM][2023-08-31 09:44:47] · ps2
INFO:     [RomM][2023-08-31 09:44:48]   Identified as PlayStation 2 🎮
INFO:     [RomM][2023-08-31 09:44:48]    · SLUS_200.91.1.iso
INFO:     [RomM][2023-08-31 09:44:49]      Identified as 4x4 Evolution 👾

SLUS_200.91 is keyed in the list of games as "4x4 Evolution" so it should find it. Maybe it's a permission issue and RomM can't read the filesize of the files? You can try the following and see what works and what doesn't:

cd /romm/library/roms/ps2
python3
>>> import os
>>> os.listdir(os.getcwd())
['SLUS_200.91.1.iso']
>>> os.stat('SLUS_200.91.1.iso')
os.stat_result(st_mode=33188, st_ino=35754805, st_dev=16777232, st_nlink=1, st_uid=501, st_gid=20, st_size=0, st_atime=1693489458, st_mtime=1693489458, st_ctime=1693489458)
>>> os.stat('SLUS_200.91.1.iso').st_size
0

@binarygeek119
Copy link

figured it out seems romm doesnt like symbolic link. is there a way of making it happy with symbolic links i need the files to be in two places at the sametime with out taking up double the space.

@gantoine
Copy link
Member Author

gantoine commented Sep 1, 2023

How are you creating the symlink, ln -s?

@binarygeek119
Copy link

ln -sf source destination
is a batch file to regenerate when new files are added

@gantoine
Copy link
Member Author

gantoine commented Sep 1, 2023

i need the files to be in two places at the same time with out taking up double the space

If this is on the same disk, you should use a hardlink instead so they're all pointing to the same inode: ln source destination. That romm does support as I use them in my setup.

@binarygeek119
Copy link

thats did it thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature] PS2/OPL support
3 participants