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

Improve to process lots of roms #2

Open
ronilaukkarinen opened this issue Jul 12, 2019 · 3 comments
Open

Improve to process lots of roms #2

ronilaukkarinen opened this issue Jul 12, 2019 · 3 comments

Comments

@ronilaukkarinen
Copy link

Hello! I love your tool. However in a ROM folder that has over 5000 roms the script crashes:

rolle@retropc:~/RetroPie/roms/c64$ clean_roms --rom_dir .
using cached list from: roms.txt
Traceback (most recent call last):
  File "/usr/local/bin/clean_roms", line 159, in <module>
    all_roms.add_rom(Rom(full_path_filename))
  File "/usr/local/bin/clean_roms", line 63, in __init__
    self.base_filename = self.describe_rom(full_path_filename)
  File "/usr/local/bin/clean_roms", line 84, in describe_rom
    ret_tokens.append(ret_base_filename[s_p[i]:e_p[i] + 1])
IndexError: list index out of range

Can you update the script so that it handles larger amount of roms?

@artifexor
Copy link

artifexor commented Oct 1, 2019

i think this error is related to an unbalanced square brackets or parentheses in filename, for example in filename
ZZZ-UNK-NEEDS LOADER-WACKY WAITERS - SYS 7296 (Y)(-)[b [B][B].zip
there is more opening square brackets than closing and therefore the closing indexes are out of range (3 opening vs 2 closing). in your example because the error is happening with _p variable is most likely related to an unbalanced parentheses.

@jhartshorn
Copy link

I'm rubbish at programming, but for anyone else experiencing this issue here's a quick hack that helped me: add the line below just above the line that throws the error so you can identify the filename causing the problem.

print(ret_base_filename)

@gpapp
Copy link

gpapp commented Nov 20, 2023

To balance the brackets, this crude code may help. It will not work with more than one open brackets/parantheses, but fixes those cases, where the filename is truncated.

...
        e_b = self.find(ret_base_filename, ']')

        d_p = ret_base_filename.rfind('.')
        if (len(s_p)>len(e_p)):
            e_p.append(d_p)
        if (len(s_b)>len(e_b)):
            e_b.append(d_p)

        for i in range(len(s_p)):
...

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

No branches or pull requests

4 participants