noophq / subtitle

Convert subtitles from one format to another format. Supported formats: STL EBU, TTML SMI, VTT, SRT
GNU Lesser General Public License v3.0
98 stars 39 forks source link

blank line(empty line) parsing error #13

Open younseunghyun opened 5 years ago

younseunghyun commented 5 years ago

Hi. We currently use you're library for parsing srt, vtt format subtitles.

Thank you for sharing the code.

By the way, when you parsing the srt format file, empty line after CUE_TIMECODE CursorStatus is treated as error case.

But there are possible case that text of cue is blank.

Can you modify this algorithm to handle a blank line?

Thanks.

viettranhoang commented 3 years ago

Hi, I fixed it by adding these lines:

            if (cursorStatus == CursorStatus.CUE_TIMECODE && textLine.isEmpty()) {
                srtObject.addCue(cue);
                cue = null;
                cursorStatus = CursorStatus.NONE;
                continue;
            }