morpheus65535 / bazarr

Bazarr is a companion application to Sonarr and Radarr. It manages and downloads subtitles based on your requirements. You define your preferences by TV show or movie and Bazarr takes care of everything for you.
https://www.bazarr.media
GNU General Public License v3.0
2.79k stars 217 forks source link

ASS subtitles with comments are rejected by embedded provider #1871

Closed RouNNdeL closed 2 years ago

RouNNdeL commented 2 years ago

Describe the bug When a movie with embedded subtitles contains an ASS file with a Comment: format it is incorrectly rejected with an error (I had to patch the embeddedsubtitles.py to see the error, as normally it just silently adds the file to a blacklist):

Traceback (most recent call last):
  File "/app/bin/bazarr/../libs/subliminal_patch/providers/embeddedsubtitles.py", line 204, in _get_subtitle_path
    check_integrity(subtitle.stream, subtitle_path)
  File "/app/bin/bazarr/../libs/fese/__init__.py", line 349, in check_integrity
    raise InvalidFile(
fese.InvalidFile: The last subtitle timestamp (0.0 sec) is 1456.77 sec ahead from the subtitle stream total duration (1456.77 sec)

To Reproduce Steps to reproduce the behavior:

  1. Use ASS subtitles with 2 subtitle track (I have to idea what the term is for this kind of file)
  2. Add the embeddedsubtitles provider with include_ass=True
  3. Start the search
  4. See error

Expected behavior The ASS parser should ignore the commentary when assessing the length of the subtitles file to avoid the error with last timestamp.

Screenshots If applicable, add screenshots to help explain your problem.

Software (please complete the following information):

Additional context Extracted ASS:

Dialogue: 0,0:24:00.41,0:24:02.24,Default,Nar,0,0,0,,The shells that explode in the air...
Dialogue: 0,0:24:02.49,0:24:06.75,Default,Nar,0,0,0,,{\fscx90}The battle against the Homunculus threatening the North defense.
Dialogue: 0,0:24:06.75,0:24:11.09,Default,Nar,0,0,0,,Will it be us who will win the battle? Or perhaps...
Dialogue: 0,0:24:11.92,0:24:15.88,Default,Nar,0,0,0,,Next time, Fullmetal Alchemist:
Dialogue: 0,0:24:15.88,0:24:19.88,Default,Nar,0,0,0,,Episode 35, The Shape of This Country.
Dialogue: 0,0:24:20.51,0:24:22.47,Default,Nar,0,0,0,,All that stands in our way shall be annihilated.
Dialogue: 0,0:24:23.10,0:24:25.27,Default,Nar,0,0,0,,That is the law of the North.
Comment: 0,0:00:00.00,0:00:00.00,Default,Fullmetal Alchemist,0,0,0,,Brotherhood
Comment: 0,0:00:00.00,0:00:00.00,Default,Fullmetal Alchemist,0,0,0,,Episode 34
Comment: 0,0:00:00.00,0:00:00.02,Default,,0,0,0,,OPENING START
Comment: 0,0:00:00.00,0:00:00.02,Default,,0,0,0,,
Comment: 0,0:00:00.00,0:00:00.02,Default,,0,0,0,,
Comment: 0,0:00:00.00,0:00:00.00,OP03 Roma,,0,0,0,,END OF OPENING
Comment: 0,0:22:27.15,0:22:27.19,Default,,0,0,0,,ENDING START
Comment: 0,0:22:27.28,0:22:27.32,Default,,0,0,0,,
Comment: 0,0:22:27.28,0:22:27.32,Default,,0,0,0,,
Comment: 0,0:00:00.10,0:00:00.14,Default,,0,0,0,,END OF ENDING
Comment: 0,0:00:00.00,0:00:00.00,Default,Fullmetal Alchemist,0,0,0,,===============================================================
morpheus65535 commented 2 years ago

@vitiko98 could you take a look?

vitiko98 commented 2 years ago

Thanks for the report!

I'm currently refactoring fese (the core of the provider). I hope this issue is solved once I finish it.

RouNNdeL commented 2 years ago

Great news, thanks for your efforts :). It also seems like sometimes ASS subtitles are not sorted by timestamp, which then translates to the converted SRT. This causes some players (Plex) to not work, while others seem to cope with it. Could we get a 'Sort SRT by timestamp' option? I poked around ffmpeg source and there seems to be an enum to allow for sorting: enum sub_sort in subtitles.h. I could find any documentation on it though.

vitiko98 commented 2 years ago

Should be fixed in upcoming beta. Thanks for the report!

vitiko98 commented 2 years ago

It also seems like sometimes ASS subtitles are not sorted by timestamp, which then translates to the converted SRT. This causes some players (Plex) to not work, while others seem to cope with it. Could we get a 'Sort SRT by timestamp' option? I poked around ffmpeg source and there seems to be an enum to allow for sorting: enum sub_sort in subtitles.h. I could find any documentation on it though.

Please open a new issue about it. And elaborate more if possible.