Store lyrics in the database as media streams (#9951)

This commit is contained in:
Cody Robibero
2024-02-26 05:09:40 -07:00
committed by GitHub
parent 59f50ae8b2
commit 0bc41c015f
49 changed files with 1481 additions and 262 deletions

View File

@@ -1,6 +1,7 @@
#pragma warning disable CS1591
using System;
using System.ComponentModel;
namespace MediaBrowser.Model.Configuration
{
@@ -20,6 +21,7 @@ namespace MediaBrowser.Model.Configuration
AutomaticallyAddToCollection = false;
EnablePhotos = true;
SaveSubtitlesWithMedia = true;
SaveLyricsWithMedia = true;
PathInfos = Array.Empty<MediaPathInfo>();
EnableAutomaticSeriesGrouping = true;
SeasonZeroDisplayName = "Specials";
@@ -92,6 +94,9 @@ namespace MediaBrowser.Model.Configuration
public bool SaveSubtitlesWithMedia { get; set; }
[DefaultValue(true)]
public bool SaveLyricsWithMedia { get; set; }
public bool AutomaticallyAddToCollection { get; set; }
public EmbeddedSubtitleOptions AllowEmbeddedSubtitles { get; set; }

View File

@@ -13,6 +13,7 @@ namespace MediaBrowser.Model.Configuration
LocalMetadataProvider,
MetadataFetcher,
MetadataSaver,
SubtitleFetcher
SubtitleFetcher,
LyricFetcher
}
}

View File

@@ -7,6 +7,7 @@ namespace MediaBrowser.Model.Dlna
Audio = 0,
Video = 1,
Photo = 2,
Subtitle = 3
Subtitle = 3,
Lyric = 4
}
}

View File

@@ -28,6 +28,11 @@ namespace MediaBrowser.Model.Entities
/// <summary>
/// The data.
/// </summary>
Data
Data,
/// <summary>
/// The lyric.
/// </summary>
Lyric
}
}

View File

@@ -0,0 +1,19 @@
using System.Collections.Generic;
namespace MediaBrowser.Model.Lyrics;
/// <summary>
/// LyricResponse model.
/// </summary>
public class LyricDto
{
/// <summary>
/// Gets or sets Metadata for the lyrics.
/// </summary>
public LyricMetadata Metadata { get; set; } = new();
/// <summary>
/// Gets or sets a collection of individual lyric lines.
/// </summary>
public IReadOnlyList<LyricLine> Lyrics { get; set; } = [];
}

View File

@@ -0,0 +1,28 @@
namespace MediaBrowser.Model.Lyrics;
/// <summary>
/// The information for a raw lyrics file before parsing.
/// </summary>
public class LyricFile
{
/// <summary>
/// Initializes a new instance of the <see cref="LyricFile"/> class.
/// </summary>
/// <param name="name">The name.</param>
/// <param name="content">The content, must not be empty.</param>
public LyricFile(string name, string content)
{
Name = name;
Content = content;
}
/// <summary>
/// Gets or sets the name of the lyrics file. This must include the file extension.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or sets the contents of the file.
/// </summary>
public string Content { get; set; }
}

View File

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

View File

@@ -0,0 +1,57 @@
namespace MediaBrowser.Model.Lyrics;
/// <summary>
/// LyricMetadata model.
/// </summary>
public class LyricMetadata
{
/// <summary>
/// Gets or sets the song artist.
/// </summary>
public string? Artist { get; set; }
/// <summary>
/// Gets or sets the album this song is on.
/// </summary>
public string? Album { get; set; }
/// <summary>
/// Gets or sets the title of the song.
/// </summary>
public string? Title { get; set; }
/// <summary>
/// Gets or sets the author of the lyric data.
/// </summary>
public string? Author { get; set; }
/// <summary>
/// Gets or sets the length of the song in ticks.
/// </summary>
public long? Length { get; set; }
/// <summary>
/// Gets or sets who the LRC file was created by.
/// </summary>
public string? By { get; set; }
/// <summary>
/// Gets or sets the lyric offset compared to audio in ticks.
/// </summary>
public long? Offset { get; set; }
/// <summary>
/// Gets or sets the software used to create the LRC file.
/// </summary>
public string? Creator { get; set; }
/// <summary>
/// Gets or sets the version of the creator used.
/// </summary>
public string? Version { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this lyric is synced.
/// </summary>
public bool? IsSynced { get; set; }
}

View File

@@ -0,0 +1,19 @@
using System.IO;
namespace MediaBrowser.Model.Lyrics;
/// <summary>
/// LyricResponse model.
/// </summary>
public class LyricResponse
{
/// <summary>
/// Gets or sets the lyric stream.
/// </summary>
public required Stream Stream { get; set; }
/// <summary>
/// Gets or sets the lyric format.
/// </summary>
public required string Format { get; set; }
}

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections.Generic;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Model.Lyrics;
/// <summary>
/// Lyric search request.
/// </summary>
public class LyricSearchRequest : IHasProviderIds
{
/// <summary>
/// Gets or sets the media path.
/// </summary>
public string? MediaPath { get; set; }
/// <summary>
/// Gets or sets the artist name.
/// </summary>
public IReadOnlyList<string>? ArtistNames { get; set; }
/// <summary>
/// Gets or sets the album name.
/// </summary>
public string? AlbumName { get; set; }
/// <summary>
/// Gets or sets the song name.
/// </summary>
public string? SongName { get; set; }
/// <summary>
/// Gets or sets the track duration in ticks.
/// </summary>
public long? Duration { get; set; }
/// <inheritdoc />
public Dictionary<string, string> ProviderIds { get; set; } = new(StringComparer.OrdinalIgnoreCase);
/// <summary>
/// Gets or sets a value indicating whether to search all providers.
/// </summary>
public bool SearchAllProviders { get; set; } = true;
/// <summary>
/// Gets or sets the list of disabled lyric fetcher names.
/// </summary>
public IReadOnlyList<string> DisabledLyricFetchers { get; set; } = [];
/// <summary>
/// Gets or sets the order of lyric fetchers.
/// </summary>
public IReadOnlyList<string> LyricFetcherOrder { get; set; } = [];
/// <summary>
/// Gets or sets a value indicating whether this request is automated.
/// </summary>
public bool IsAutomated { get; set; }
}

View File

@@ -0,0 +1,22 @@
namespace MediaBrowser.Model.Lyrics;
/// <summary>
/// The remote lyric info dto.
/// </summary>
public class RemoteLyricInfoDto
{
/// <summary>
/// Gets or sets the id for the lyric.
/// </summary>
public required string Id { get; set; }
/// <summary>
/// Gets the provider name.
/// </summary>
public required string ProviderName { get; init; }
/// <summary>
/// Gets the lyrics.
/// </summary>
public required LyricDto Lyrics { get; init; }
}

View File

@@ -0,0 +1,16 @@
using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Http;
namespace MediaBrowser.Model.Lyrics;
/// <summary>
/// Upload lyric dto.
/// </summary>
public class UploadLyricDto
{
/// <summary>
/// Gets or sets the lyrics file.
/// </summary>
[Required]
public IFormFile Lyrics { get; set; } = null!;
}

View File

@@ -0,0 +1,17 @@
namespace MediaBrowser.Model.Providers;
/// <summary>
/// Lyric provider info.
/// </summary>
public class LyricProviderInfo
{
/// <summary>
/// Gets the provider name.
/// </summary>
public required string Name { get; init; }
/// <summary>
/// Gets the provider id.
/// </summary>
public required string Id { get; init; }
}

View File

@@ -0,0 +1,29 @@
using MediaBrowser.Model.Lyrics;
namespace MediaBrowser.Model.Providers;
/// <summary>
/// The remote lyric info.
/// </summary>
public class RemoteLyricInfo
{
/// <summary>
/// Gets or sets the id for the lyric.
/// </summary>
public required string Id { get; set; }
/// <summary>
/// Gets the provider name.
/// </summary>
public required string ProviderName { get; init; }
/// <summary>
/// Gets the lyric metadata.
/// </summary>
public required LyricMetadata Metadata { get; init; }
/// <summary>
/// Gets the lyrics.
/// </summary>
public required LyricResponse Lyrics { get; init; }
}

View File

@@ -92,6 +92,12 @@ namespace MediaBrowser.Model.Users
[DefaultValue(false)]
public bool EnableSubtitleManagement { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this user can manage lyrics.
/// </summary>
[DefaultValue(false)]
public bool EnableLyricManagement { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is disabled.
/// </summary>