From dd30bd99f9d7d9318a504f2599e4b0f80f58cfd6 Mon Sep 17 00:00:00 2001 From: fireattack Date: Sat, 2 Nov 2024 15:29:21 +0800 Subject: [PATCH] Fix WebVttSub not be able to parse string without ms (#473) --- src/N_m3u8DL-RE.Common/Entity/WebVttSub.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/N_m3u8DL-RE.Common/Entity/WebVttSub.cs b/src/N_m3u8DL-RE.Common/Entity/WebVttSub.cs index a0f4979..5f49a68 100644 --- a/src/N_m3u8DL-RE.Common/Entity/WebVttSub.cs +++ b/src/N_m3u8DL-RE.Common/Entity/WebVttSub.cs @@ -201,10 +201,14 @@ namespace N_m3u8DL_RE.Common.Entity } str = str.Replace(',', '.'); - var ms = Convert.ToInt32(str.Split('.').Last()); - var o = str.Split('.').First(); - var t = o.Split(':').Reverse().ToList(); - var time = 0L + ms; + long time = 0; + string[] parts = str.Split('.'); + if (parts.Length > 1) + { + time += Convert.ToInt32(parts.Last()); + str = parts.First(); + } + var t = str.Split(':').Reverse().ToList(); for (int i = 0; i < t.Count(); i++) { time += (long)Math.Pow(60, i) * Convert.ToInt32(t[i]) * 1000;