AlexPoint / SubtitlesParser

Multi formats subtitles parser in C#
MIT License
134 stars 40 forks source link

WebVTT timestamps after 24 hours will parse as -1 #30

Closed ElectiveRob closed 3 years ago

ElectiveRob commented 3 years ago

Web VTT spec allows to have subtitles after 24 hours. see: https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API#Cue_timings

b-rad15 commented 3 years ago

This code here https://github.com/AlexPoint/SubtitlesParser/blob/febe41daae152e0e8eccfc3bbadf55e3511185ea/SubtitlesParser/Classes/Parsers/VttParser.cs#L171 should parse hour numbers greater than 24 fine. What was the timecode that gave you the -1 error?

ElectiveRob commented 3 years ago

file i used to test

WEBVTT

00:01.000 --> 00:04.000
Never drink liquid nitrogen.

00:05.000 --> 00:09.000
— It will perforate your stomach.
— You could die.

23:00:05.000 --> 23:59:59.999
— It will perforate your stomach.
— You could die.

24:00:00.000 --> 55:00:00.000
— It will perforate your stomach.
— You could die.

See that 23:59:59.999 wil be parsed correctly but 24:00:00.000 wil be -1

image

TimeSpan.TryParse doesn't seem to support the notation https://github.com/AlexPoint/SubtitlesParser/blob/febe41daae152e0e8eccfc3bbadf55e3511185ea/SubtitlesParser/Classes/Parsers/VttParser.cs#L192

AlexPoint commented 3 years ago

This is a good point! I just fixed this behavior and published a new package (1.4.9) to nuget with this fix. That must be one hell of a movie with subtitle items at more than 24 hours though! ;) image