aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Controller/Lyrics
diff options
context:
space:
mode:
author1hitsong <3330318+1hitsong@users.noreply.github.com>2022-09-15 20:49:25 -0400
committer1hitsong <3330318+1hitsong@users.noreply.github.com>2022-09-15 20:49:25 -0400
commitf4fd908f8d7ffcdea6acaf75928f6c2960ed6338 (patch)
tree25d932b8f5734491380b5305ae2f7810e3c5a165 /MediaBrowser.Controller/Lyrics
parentd9be3874ba3842d5888c5cbbe583614ed990849e (diff)
Create ILyricManager
Diffstat (limited to 'MediaBrowser.Controller/Lyrics')
-rw-r--r--MediaBrowser.Controller/Lyrics/ILyricManager.cs37
-rw-r--r--MediaBrowser.Controller/Lyrics/ILyricProvider.cs (renamed from MediaBrowser.Controller/Lyrics/ILyricsProvider.cs)7
-rw-r--r--MediaBrowser.Controller/Lyrics/LyricInfo.cs50
3 files changed, 45 insertions, 49 deletions
diff --git a/MediaBrowser.Controller/Lyrics/ILyricManager.cs b/MediaBrowser.Controller/Lyrics/ILyricManager.cs
new file mode 100644
index 000000000..4fd11b9e0
--- /dev/null
+++ b/MediaBrowser.Controller/Lyrics/ILyricManager.cs
@@ -0,0 +1,37 @@
+#nullable disable
+
+#pragma warning disable CS1591
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using System.Threading.Tasks;
+using MediaBrowser.Controller.Entities;
+using MediaBrowser.Model.Configuration;
+using MediaBrowser.Model.Providers;
+
+namespace MediaBrowser.Controller.Lyrics
+{
+ public interface ILyricManager
+ {
+ /// <summary>
+ /// Adds the parts.
+ /// </summary>
+ /// <param name="lyricProviders">The lyric providers.</param>
+ void AddParts(IEnumerable<ILyricProvider> lyricProviders);
+
+ /// <summary>
+ /// Gets the lyrics.
+ /// </summary>
+ /// <param name="item">The media item.</param>
+ /// <returns>Lyrics for passed item.</returns>
+ LyricResponse GetLyric(BaseItem item);
+
+ /// <summary>
+ /// Checks if requested item has a matching local lyric file.
+ /// </summary>
+ /// <param name="item">The media item.</param>
+ /// <returns>True if item has a matching lyrics file; otherwise false.</returns>
+ bool HasLyricFile(BaseItem item);
+ }
+}
diff --git a/MediaBrowser.Controller/Lyrics/ILyricsProvider.cs b/MediaBrowser.Controller/Lyrics/ILyricProvider.cs
index bac32a398..691fed1fd 100644
--- a/MediaBrowser.Controller/Lyrics/ILyricsProvider.cs
+++ b/MediaBrowser.Controller/Lyrics/ILyricProvider.cs
@@ -6,9 +6,14 @@ namespace MediaBrowser.Controller.Lyrics
/// <summary>
/// Interface ILyricsProvider.
/// </summary>
- public interface ILyricsProvider
+ public interface ILyricProvider
{
/// <summary>
+ /// Gets a value indicating the provider name.
+ /// </summary>
+ string Name { get; }
+
+ /// <summary>
/// Gets the supported media types for this provider.
/// </summary>
/// <value>The supported media types.</value>
diff --git a/MediaBrowser.Controller/Lyrics/LyricInfo.cs b/MediaBrowser.Controller/Lyrics/LyricInfo.cs
index 83a10701a..d44e14237 100644
--- a/MediaBrowser.Controller/Lyrics/LyricInfo.cs
+++ b/MediaBrowser.Controller/Lyrics/LyricInfo.cs
@@ -13,42 +13,15 @@ namespace MediaBrowser.Controller.Lyrics
/// <summary>
/// Item helper.
/// </summary>
- public class LyricInfo
+ public static class LyricInfo
{
/// <summary>
- /// Opens lyrics file, converts to a List of Lyrics, and returns it.
- /// </summary>
- /// <param name="lyricProviders">Collection of all registered <see cref="ILyricsProvider"/> interfaces.</param>
- /// <param name="item">Requested Item.</param>
- /// <returns>Collection of Lyrics.</returns>
- public static LyricResponse? GetLyricData(IEnumerable<ILyricsProvider> lyricProviders, BaseItem item)
- {
-
- foreach (var provider in lyricProviders)
- {
- var result = provider.GetLyrics(item);
- if (result is not null)
- {
- return result;
- }
- }
-
- return new LyricResponse
- {
- Lyrics = new List<Lyric>
- {
- new Lyric { Start = 0, Text = "Test" }
- }
- };
- }
-
- /// <summary>
/// Checks if requested item has a matching lyric file.
/// </summary>
/// <param name="lyricProvider">The current lyricProvider interface.</param>
/// <param name="itemPath">Path of requested item.</param>
/// <returns>True if item has a matching lyrics file.</returns>
- public static string? GetLyricFilePath(ILyricsProvider lyricProvider, string itemPath)
+ public static string? GetLyricFilePath(ILyricProvider lyricProvider, string itemPath)
{
if (lyricProvider.SupportedMediaTypes.Any())
{
@@ -64,24 +37,5 @@ namespace MediaBrowser.Controller.Lyrics
return null;
}
-
- /// <summary>
- /// Checks if requested item has a matching local lyric file.
- /// </summary>
- /// <param name="lyricProviders">Collection of all registered <see cref="ILyricsProvider"/> interfaces.</param>
- /// <param name="itemPath">Path of requested item.</param>
- /// <returns>True if item has a matching lyrics file; otherwise false.</returns>
- public static bool HasLyricFile(IEnumerable<ILyricsProvider> lyricProviders, string itemPath)
- {
- foreach (var provider in lyricProviders)
- {
- if (GetLyricFilePath(provider, itemPath) is not null)
- {
- return true;
- }
- }
-
- return false;
- }
}
}