Fix WebVttSub not be able to parse string without ms (#473)

This commit is contained in:
fireattack 2024-11-02 15:29:21 +08:00 committed by GitHub
parent 9c49fce4ff
commit dd30bd99f9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 8 additions and 4 deletions

View File

@ -201,10 +201,14 @@ namespace N_m3u8DL_RE.Common.Entity
} }
str = str.Replace(',', '.'); str = str.Replace(',', '.');
var ms = Convert.ToInt32(str.Split('.').Last()); long time = 0;
var o = str.Split('.').First(); string[] parts = str.Split('.');
var t = o.Split(':').Reverse().ToList(); if (parts.Length > 1)
var time = 0L + ms; {
time += Convert.ToInt32(parts.Last());
str = parts.First();
}
var t = str.Split(':').Reverse().ToList();
for (int i = 0; i < t.Count(); i++) for (int i = 0; i < t.Count(); i++)
{ {
time += (long)Math.Pow(60, i) * Convert.ToInt32(t[i]) * 1000; time += (long)Math.Pow(60, i) * Convert.ToInt32(t[i]) * 1000;