diff options
| author | Niels van Velzen <git@ndat.nl> | 2023-06-29 21:16:29 +0200 |
|---|---|---|
| committer | Niels van Velzen <git@ndat.nl> | 2023-06-29 21:16:29 +0200 |
| commit | 6be45f73bc60d7b4646d7967d29634eea0b7e422 (patch) | |
| tree | 14a7f68d1191eb7877427241a4a921f51576c7f6 /MediaBrowser.Providers/Lyric | |
| parent | 1ed5f0a624abeebef16a960ed7a52942bce47502 (diff) | |
Simplify file extension checks in lyrics parsers and provider
Diffstat (limited to 'MediaBrowser.Providers/Lyric')
| -rw-r--r-- | MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Providers/Lyric/LrcLyricParser.cs | 4 | ||||
| -rw-r--r-- | MediaBrowser.Providers/Lyric/TxtLyricParser.cs | 4 |
3 files changed, 6 insertions, 6 deletions
diff --git a/MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs b/MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs index f828ec26b..ae6350dd7 100644 --- a/MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs +++ b/MediaBrowser.Providers/Lyric/DefaultLyricProvider.cs @@ -10,7 +10,7 @@ namespace MediaBrowser.Providers.Lyric; /// <inheritdoc /> public class DefaultLyricProvider : ILyricProvider { - private static readonly string[] _lyricExtensions = { "lrc", "elrc", "txt", "elrc" }; + private static readonly string[] _lyricExtensions = { ".lrc", ".elrc", ".txt" }; /// <inheritdoc /> public string Name => "DefaultLyricProvider"; @@ -55,7 +55,7 @@ public class DefaultLyricProvider : ILyricProvider foreach (var lyricFilePath in Directory.GetFiles(itemDirectoryPath, $"{Path.GetFileNameWithoutExtension(item.Path)}.*")) { - if (_lyricExtensions.Contains(Path.GetExtension(lyricFilePath.AsSpan())[1..], StringComparison.OrdinalIgnoreCase)) + if (_lyricExtensions.Contains(Path.GetExtension(lyricFilePath.AsSpan()), StringComparison.OrdinalIgnoreCase)) { return lyricFilePath; } diff --git a/MediaBrowser.Providers/Lyric/LrcLyricParser.cs b/MediaBrowser.Providers/Lyric/LrcLyricParser.cs index 01a0dddf1..7f1ecd743 100644 --- a/MediaBrowser.Providers/Lyric/LrcLyricParser.cs +++ b/MediaBrowser.Providers/Lyric/LrcLyricParser.cs @@ -18,7 +18,7 @@ public class LrcLyricParser : ILyricParser { private readonly LyricParser _lrcLyricParser; - private static readonly string[] _supportedMediaTypes = { "lrc", "elrc" }; + private static readonly string[] _supportedMediaTypes = { ".lrc", ".elrc" }; private static readonly string[] _acceptedTimeFormats = { "HH:mm:ss", "H:mm:ss", "mm:ss", "m:ss" }; /// <summary> @@ -41,7 +41,7 @@ public class LrcLyricParser : ILyricParser /// <inheritdoc /> public LyricResponse? ParseLyrics(LyricFile lyrics) { - if (!_supportedMediaTypes.Contains(Path.GetExtension(lyrics.Name.AsSpan())[1..], StringComparison.OrdinalIgnoreCase)) + if (!_supportedMediaTypes.Contains(Path.GetExtension(lyrics.Name.AsSpan()), StringComparison.OrdinalIgnoreCase)) { return null; } diff --git a/MediaBrowser.Providers/Lyric/TxtLyricParser.cs b/MediaBrowser.Providers/Lyric/TxtLyricParser.cs index 7e029ee42..ed4f2cb7a 100644 --- a/MediaBrowser.Providers/Lyric/TxtLyricParser.cs +++ b/MediaBrowser.Providers/Lyric/TxtLyricParser.cs @@ -11,7 +11,7 @@ namespace MediaBrowser.Providers.Lyric; /// </summary> public class TxtLyricParser : ILyricParser { - private static readonly string[] _supportedMediaTypes = { "lrc", "elrc", "txt" }; + private static readonly string[] _supportedMediaTypes = { ".lrc", ".elrc", ".txt" }; private static readonly string[] _lineBreakCharacters = { "\r\n", "\r", "\n" }; /// <inheritdoc /> @@ -26,7 +26,7 @@ public class TxtLyricParser : ILyricParser /// <inheritdoc /> public LyricResponse? ParseLyrics(LyricFile lyrics) { - if (!_supportedMediaTypes.Contains(Path.GetExtension(lyrics.Name.AsSpan())[1..], StringComparison.OrdinalIgnoreCase)) + if (!_supportedMediaTypes.Contains(Path.GetExtension(lyrics.Name.AsSpan()), StringComparison.OrdinalIgnoreCase)) { return null; } |
