KBlixt / subcleaner

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

Division By Zero #49

Closed Progeny42 closed 1 year ago

Progeny42 commented 1 year ago

Just been running subcleaner manually on my existing subtitles. Currently on Battlestar Galactica. I've done a first pass using python3 config/subcleaner/subcleaner.py -r "tv/Battlestar Galactica (2003)" and then I was doing a dry run to check the remaining warnings python3 config/subcleaner/subcleaner.py -r "tv/Battlestar Galactica (2003)" -n which when it gets to tv/Battlestar Galactica (2003)/Season 01/Battlestar Galactica (2003) - S01E13 - Kobols Last Gleaming 2 [Bluray-1080p Remux][AAC 2.0][VC1].en.srt crashes with the following Traceback:

    INFO: [---------------------------------------------------------------------------------]
    INFO: loading subtitle: tv/Battlestar Galactica (2003)/Season 01/Battlestar Galactica (2003) - S01E13 - Kobols Last Gleaming 2 [Bluray-1080p Remux][AAC 2.0][VC1].en.srt
    INFO: now cleaning subtitle: tv/Battlestar Galactica (2003)/Season 01/Battlestar Galactica (2003) - S01E13 - Kobols Last Gleaming 2 [Bluray-1080p Remux][AAC 2.0][VC1].en.srt
 WARNING: the language within the file does not match language: 'en'
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 89, in clean_file
    cleaner.fix_overlap(subtitle)
  File "/config/subcleaner/libs/subcleaner/cleaner/cleaner.py", line 92, in fix_overlap
    content_ratio = block.duration_seconds / (block.duration_seconds + previous_block.duration_seconds)
                    ~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ZeroDivisionError: float division by zero

I've attached the file in question, although I've just had a look, and apparently it's in French despite stating it is in English! Battlestar Galactica (2003) - S01E13 - Kobols Last Gleaming 2 [Bluray-1080p Remux][AAC 2.0][VC1].en.srt.txt

KBlixt commented 1 year ago

Ya, takin a look. Would be great if you could send the file. I already know what the issue is but would be good to know what caused the issue.

Also, a bit unrelated but it looks like the subtitle file have the wrong language?

Progeny42 commented 1 year ago

The subtitle file is attached at the end of the first comment :) But yes, for some reason, it contains French despite the filename saying it is in English (file was auto-downloaded by Bazarr)

KBlixt commented 1 year ago

This should be fixed now, try again to let me know it works :)

Progeny42 commented 1 year ago

Seem to run fine now. As a sanity check, I've run it across my entire library (dry run), and all seems to be well. Thanks!