aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author1hitsong <3330318+1hitsong@users.noreply.github.com>2022-09-19 16:59:16 -0400
committer1hitsong <3330318+1hitsong@users.noreply.github.com>2022-09-19 16:59:16 -0400
commit5d2364f0646ba4f4b6866115ad82fd8fac0733de (patch)
tree2864afa8b3a8bd7f24d364ecf6c7ea9436bf22b4
parentd7fedf35128a4400dfd4c4e72bbfee3f362d565d (diff)
Move AcceptedTimeFormats to class level variable
-rw-r--r--MediaBrowser.Controller/Lyrics/LyricResponse.cs3
-rw-r--r--MediaBrowser.Providers/Lyric/LrcLyricProvider.cs8
2 files changed, 7 insertions, 4 deletions
diff --git a/MediaBrowser.Controller/Lyrics/LyricResponse.cs b/MediaBrowser.Controller/Lyrics/LyricResponse.cs
index 64c3b3c28..56a569645 100644
--- a/MediaBrowser.Controller/Lyrics/LyricResponse.cs
+++ b/MediaBrowser.Controller/Lyrics/LyricResponse.cs
@@ -1,3 +1,4 @@
+using System;
using System.Collections.Generic;
namespace MediaBrowser.Controller.Lyrics;
@@ -15,5 +16,5 @@ public class LyricResponse
/// <summary>
/// Gets or sets Lyrics.
/// </summary>
- public IReadOnlyList<LyricLine> Lyrics { get; set; } = new List<LyricLine>();
+ public IReadOnlyList<LyricLine> Lyrics { get; set; } = Array.Empty<LyricLine>();
}
diff --git a/MediaBrowser.Providers/Lyric/LrcLyricProvider.cs b/MediaBrowser.Providers/Lyric/LrcLyricProvider.cs
index ea10749b9..b67b8c5d3 100644
--- a/MediaBrowser.Providers/Lyric/LrcLyricProvider.cs
+++ b/MediaBrowser.Providers/Lyric/LrcLyricProvider.cs
@@ -39,6 +39,8 @@ public class LrcLyricProvider : ILyricProvider
/// <inheritdoc />
public IReadOnlyCollection<string> SupportedMediaTypes { get; } = new[] { "lrc", "elrc" };
+ private static string[] AcceptedTimeFormats => new[] { "HH:mm:ss", "H:mm:ss", "mm:ss", "m:ss" };
+
/// <summary>
/// Opens lyric file for the requested item, and processes it for API return.
/// </summary>
@@ -88,8 +90,8 @@ public class LrcLyricProvider : ILyricProvider
}
string[] metaDataField = metaDataRow.Split(':', 2, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
- string metaDataFieldName = metaDataField[0][1..].Trim();
- string metaDataFieldValue = metaDataField[1][..^1].Trim();
+ string metaDataFieldName = metaDataField[0][1..];
+ string metaDataFieldValue = metaDataField[1][..^1];
fileMetaData.Add(metaDataFieldName, metaDataFieldValue);
}
@@ -155,7 +157,7 @@ public class LrcLyricProvider : ILyricProvider
if (metaData.TryGetValue("length", out var length) && !string.IsNullOrEmpty(length))
{
- if (DateTime.TryParseExact(length, new string[] { "HH:mm:ss", "H:mm:ss", "mm:ss", "m:ss" }, null, DateTimeStyles.None, out var value))
+ if (DateTime.TryParseExact(length, AcceptedTimeFormats, null, DateTimeStyles.None, out var value))
{
lyricMetadata.Length = value.TimeOfDay.Ticks;
}