KBlixt / subcleaner

removes ads from subtitle files cleanly.
288 stars 13 forks source link

List index out of range #50

Closed Progeny42 closed 1 year ago

Progeny42 commented 1 year ago

When performing a dry run on Scrubs (2001) python3 config/subcleaner/subcleaner.py -r "tv/Scrubs (2001)"/ -n episode tv/Scrubs (2001)/Season 04/Scrubs (2001) - S04E16 - My Quarantine [SDTV][AC3 2.0][MPEG2].en.srt causes a crash, with the resulting Traceback:

    INFO: [---------------------------------------------------------------------------------]
    INFO: loading subtitle: tv/Scrubs (2001)/Season 04/Scrubs (2001) - S04E16 - My Quarantine [SDTV][AC3 2.0][MPEG2].en.srt
    INFO: now cleaning subtitle: tv/Scrubs (2001)/Season 04/Scrubs (2001) - S04E16 - My Quarantine [SDTV][AC3 2.0][MPEG2].en.srt
Traceback (most recent call last):
  File "//config/subcleaner/subcleaner.py", line 11, in <module>
    main.main()
  File "/config/subcleaner/libs/subcleaner/main.py", line 24, in main
    clean_directory(library)
  File "/config/subcleaner/libs/subcleaner/main.py", line 125, in clean_directory
    clean_directory(file)
  File "/config/subcleaner/libs/subcleaner/main.py", line 132, in clean_directory
    clean_file(file)
  File "/config/subcleaner/libs/subcleaner/main.py", line 86, in clean_file
    cleaner.find_ads(subtitle)
  File "/config/subcleaner/libs/subcleaner/cleaner/cleaner.py", line 24, in find_ads
    punishers.punish_quick_first_block(subtitle)
  File "/config/subcleaner/libs/subcleaner/cleaner/punishers/time.py", line 8, in punish_quick_first_block
    block = subtitle.blocks[0]
            ~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Subtitles are attached Scrubs (2001) - S04E16 - My Quarantine [SDTV][AC3 2.0][MPEG2].en.srt.txt

After checking the file, it appears that all the blocks are at 00:00:00,000 --> 00:00:00,000, and it's actually empty of any content. Obviously a bad file.

KBlixt commented 1 year ago

Ok, seems like you found the issue, but I'll make sure to fix the issue so the exception gets handled. Thank you 🙂

Progeny42 commented 1 year ago

Always the weird edge cases! Thanks for the effort!

KBlixt commented 1 year ago

OK, this was actually an issue with how I parsed the file. if the last block was empty it failed to parse it correctly.

this should be fixed now. thank you for letting me know :)

Progeny42 commented 1 year ago

Yes, that's all working now. Now I get Errors that many of the files are empty. Will have to do some manual tidy up to resolve that, but the crash is resolved. Thanks!