Code cleanups. Remove pragma commands

This commit is contained in:
1hitsong
2022-09-17 17:37:38 -04:00
parent 29932466a9
commit c65819221d
9 changed files with 247 additions and 271 deletions

View File

@@ -1,23 +1,23 @@
#pragma warning disable CS1591
using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Lyrics
{
public interface ILyricManager
{
/// <summary>
/// Gets the lyrics.
/// </summary>
/// <param name="item">The media item.</param>
/// <returns>Lyrics for passed item.</returns>
LyricResponse GetLyrics(BaseItem item);
namespace MediaBrowser.Controller.Lyrics;
/// <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 lyric file; otherwise false.</returns>
bool HasLyricFile(BaseItem item);
}
/// <summary>
/// Interface ILyricManager.
/// </summary>
public interface ILyricManager
{
/// <summary>
/// Gets the lyrics.
/// </summary>
/// <param name="item">The media item.</param>
/// <returns>Lyrics for passed item.</returns>
LyricResponse GetLyrics(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 lyric file; otherwise false.</returns>
bool HasLyricFile(BaseItem item);
}

View File

@@ -1,29 +1,28 @@
using System.Collections.Generic;
using MediaBrowser.Controller.Entities;
namespace MediaBrowser.Controller.Lyrics
namespace MediaBrowser.Controller.Lyrics;
/// <summary>
/// Interface ILyricsProvider.
/// </summary>
public interface ILyricProvider
{
/// <summary>
/// Interface ILyricsProvider.
/// Gets a value indicating the provider name.
/// </summary>
public interface ILyricProvider
{
/// <summary>
/// Gets a value indicating the provider name.
/// </summary>
string Name { get; }
string Name { get; }
/// <summary>
/// Gets the supported media types for this provider.
/// </summary>
/// <value>The supported media types.</value>
IEnumerable<string> SupportedMediaTypes { get; }
/// <summary>
/// Gets the supported media types for this provider.
/// </summary>
/// <value>The supported media types.</value>
IEnumerable<string> SupportedMediaTypes { get; }
/// <summary>
/// Gets the lyrics.
/// </summary>
/// <param name="item">The media item.</param>
/// <returns>If found, returns lyrics for passed item; otherwise, null.</returns>
LyricResponse? GetLyrics(BaseItem item);
}
/// <summary>
/// Gets the lyrics.
/// </summary>
/// <param name="item">The media item.</param>
/// <returns>If found, returns lyrics for passed item; otherwise, null.</returns>
LyricResponse? GetLyrics(BaseItem item);
}

View File

@@ -1,18 +1,28 @@
namespace MediaBrowser.Controller.Lyrics
namespace MediaBrowser.Controller.Lyrics;
/// <summary>
/// Lyric model.
/// </summary>
public class Lyric
{
/// <summary>
/// Lyric model.
/// Initializes a new instance of the <see cref="Lyric"/> class.
/// </summary>
public class Lyric
/// <param name="start">The lyric start time in ticks.</param>
/// <param name="text">The lyric text.</param>
public Lyric(string text, long? start = null)
{
/// <summary>
/// Gets or sets the start time in ticks.
/// </summary>
public long? Start { get; set; }
/// <summary>
/// Gets or sets the text.
/// </summary>
public string Text { get; set; } = string.Empty;
Start = start;
Text = text;
}
/// <summary>
/// Gets the start time in ticks.
/// </summary>
public long? Start { get; }
/// <summary>
/// Gets the text.
/// </summary>
public string Text { get; }
}

View File

@@ -1,34 +1,29 @@
using System.IO;
using System.Linq;
namespace MediaBrowser.Controller.Lyrics
namespace MediaBrowser.Controller.Lyrics;
/// <summary>
/// Lyric helper methods.
/// </summary>
public static class LyricInfo
{
/// <summary>
/// Lyric helper methods.
/// Gets matching lyric file for a requested item.
/// </summary>
public static class LyricInfo
/// <param name="lyricProvider">The lyricProvider interface to use.</param>
/// <param name="itemPath">Path of requested item.</param>
/// <returns>Lyric file path if passed lyric provider's supported media type is found; otherwise, null.</returns>
public static string? GetLyricFilePath(ILyricProvider lyricProvider, string itemPath)
{
/// <summary>
/// Gets matching lyric file for a requested item.
/// </summary>
/// <param name="lyricProvider">The lyricProvider interface to use.</param>
/// <param name="itemPath">Path of requested item.</param>
/// <returns>Lyric file path if passed lyric provider's supported media type is found; otherwise, null.</returns>
public static string? GetLyricFilePath(ILyricProvider lyricProvider, string itemPath)
foreach (string lyricFileExtension in lyricProvider.SupportedMediaTypes)
{
if (lyricProvider.SupportedMediaTypes.Any())
var lyricFilePath = Path.ChangeExtension(itemPath, lyricFileExtension);
if (File.Exists(lyricFilePath))
{
foreach (string lyricFileExtension in lyricProvider.SupportedMediaTypes)
{
string lyricFilePath = @Path.ChangeExtension(itemPath, lyricFileExtension);
if (System.IO.File.Exists(lyricFilePath))
{
return lyricFilePath;
}
}
return lyricFilePath;
}
return null;
}
return null;
}
}

View File

@@ -1,22 +1,19 @@
#nullable disable
using System.Collections.Generic;
namespace MediaBrowser.Controller.Lyrics
namespace MediaBrowser.Controller.Lyrics;
/// <summary>
/// LyricResponse model.
/// </summary>
public class LyricResponse
{
/// <summary>
/// LyricResponse model.
/// Gets or sets Metadata.
/// </summary>
public class LyricResponse
{
/// <summary>
/// Gets or sets Metadata.
/// </summary>
public IDictionary<string, string> Metadata { get; set; }
public IDictionary<string, string>? Metadata { get; set; }
/// <summary>
/// Gets or sets Lyrics.
/// </summary>
public IEnumerable<Lyric> Lyrics { get; set; }
}
/// <summary>
/// Gets or sets Lyrics.
/// </summary>
public IEnumerable<Lyric>? Lyrics { get; set; }
}