using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Lyrics; namespace MediaBrowser.Providers.Lyric; /// /// TXT Lyric Provider. /// public class TxtLyricProvider : ILyricProvider { /// public string Name => "TxtLyricProvider"; /// public IEnumerable SupportedMediaTypes { get; } = new[] { "lrc", "txt" }; /// /// Opens lyric file for the requested item, and processes it for API return. /// /// The item to to process. /// If provider can determine lyrics, returns a ; otherwise, null. public LyricResponse? GetLyrics(BaseItem item) { string? lyricFilePath = LyricInfo.GetLyricFilePath(this, item.Path); if (string.IsNullOrEmpty(lyricFilePath)) { return null; } string[] lyricTextLines = System.IO.File.ReadAllLines(lyricFilePath); List lyricList = new List(); if (lyricTextLines.Length == 0) { return null; } foreach (string lyricTextLine in lyricTextLines) { lyricList.Add(new Controller.Lyrics.Lyric(lyricTextLine)); } return new LyricResponse { Lyrics = lyricList }; } }