aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Model
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2024-02-26 05:09:40 -0700
committerGitHub <noreply@github.com>2024-02-26 05:09:40 -0700
commit0bc41c015f4ec907de75fe215589b7e30a819b54 (patch)
treeaade0ceab41e63b2f4833032dc380471166fc343 /MediaBrowser.Model
parent59f50ae8b2555b8caa19e743c3ba612e999f75bf (diff)
Store lyrics in the database as media streams (#9951)
Diffstat (limited to 'MediaBrowser.Model')
-rw-r--r--MediaBrowser.Model/Configuration/LibraryOptions.cs5
-rw-r--r--MediaBrowser.Model/Configuration/MetadataPluginType.cs3
-rw-r--r--MediaBrowser.Model/Dlna/DlnaProfileType.cs3
-rw-r--r--MediaBrowser.Model/Entities/MediaStreamType.cs7
-rw-r--r--MediaBrowser.Model/Lyrics/LyricDto.cs19
-rw-r--r--MediaBrowser.Model/Lyrics/LyricFile.cs28
-rw-r--r--MediaBrowser.Model/Lyrics/LyricLine.cs28
-rw-r--r--MediaBrowser.Model/Lyrics/LyricMetadata.cs57
-rw-r--r--MediaBrowser.Model/Lyrics/LyricResponse.cs19
-rw-r--r--MediaBrowser.Model/Lyrics/LyricSearchRequest.cs59
-rw-r--r--MediaBrowser.Model/Lyrics/RemoteLyricInfoDto.cs22
-rw-r--r--MediaBrowser.Model/Lyrics/UploadLyricDto.cs16
-rw-r--r--MediaBrowser.Model/Providers/LyricProviderInfo.cs17
-rw-r--r--MediaBrowser.Model/Providers/RemoteLyricInfo.cs29
-rw-r--r--MediaBrowser.Model/Users/UserPolicy.cs6
15 files changed, 315 insertions, 3 deletions
diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs
index 1c071067d..42148a276 100644
--- a/MediaBrowser.Model/Configuration/LibraryOptions.cs
+++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs
@@ -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; }
diff --git a/MediaBrowser.Model/Configuration/MetadataPluginType.cs b/MediaBrowser.Model/Configuration/MetadataPluginType.cs
index 4c5e95266..ef303726d 100644
--- a/MediaBrowser.Model/Configuration/MetadataPluginType.cs
+++ b/MediaBrowser.Model/Configuration/MetadataPluginType.cs
@@ -13,6 +13,7 @@ namespace MediaBrowser.Model.Configuration
LocalMetadataProvider,
MetadataFetcher,
MetadataSaver,
- SubtitleFetcher
+ SubtitleFetcher,
+ LyricFetcher
}
}
diff --git a/MediaBrowser.Model/Dlna/DlnaProfileType.cs b/MediaBrowser.Model/Dlna/DlnaProfileType.cs
index c1a663bf1..1bb885c44 100644
--- a/MediaBrowser.Model/Dlna/DlnaProfileType.cs
+++ b/MediaBrowser.Model/Dlna/DlnaProfileType.cs
@@ -7,6 +7,7 @@ namespace MediaBrowser.Model.Dlna
Audio = 0,
Video = 1,
Photo = 2,
- Subtitle = 3
+ Subtitle = 3,
+ Lyric = 4
}
}
diff --git a/MediaBrowser.Model/Entities/MediaStreamType.cs b/MediaBrowser.Model/Entities/MediaStreamType.cs
index 83751a6a7..0964bb769 100644
--- a/MediaBrowser.Model/Entities/MediaStreamType.cs
+++ b/MediaBrowser.Model/Entities/MediaStreamType.cs
@@ -28,6 +28,11 @@ namespace MediaBrowser.Model.Entities
/// <summary>
/// The data.
/// </summary>
- Data
+ Data,
+
+ /// <summary>
+ /// The lyric.
+ /// </summary>
+ Lyric
}
}
diff --git a/MediaBrowser.Model/Lyrics/LyricDto.cs b/MediaBrowser.Model/Lyrics/LyricDto.cs
new file mode 100644
index 000000000..7a9bffc99
--- /dev/null
+++ b/MediaBrowser.Model/Lyrics/LyricDto.cs
@@ -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; } = [];
+}
diff --git a/MediaBrowser.Model/Lyrics/LyricFile.cs b/MediaBrowser.Model/Lyrics/LyricFile.cs
new file mode 100644
index 000000000..3912b037e
--- /dev/null
+++ b/MediaBrowser.Model/Lyrics/LyricFile.cs
@@ -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; }
+}
diff --git a/MediaBrowser.Model/Lyrics/LyricLine.cs b/MediaBrowser.Model/Lyrics/LyricLine.cs
new file mode 100644
index 000000000..64d1f64c2
--- /dev/null
+++ b/MediaBrowser.Model/Lyrics/LyricLine.cs
@@ -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; }
+}
diff --git a/MediaBrowser.Model/Lyrics/LyricMetadata.cs b/MediaBrowser.Model/Lyrics/LyricMetadata.cs
new file mode 100644
index 000000000..4f819d6c9
--- /dev/null
+++ b/MediaBrowser.Model/Lyrics/LyricMetadata.cs
@@ -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; }
+}
diff --git a/MediaBrowser.Model/Lyrics/LyricResponse.cs b/MediaBrowser.Model/Lyrics/LyricResponse.cs
new file mode 100644
index 000000000..b04adeb7b
--- /dev/null
+++ b/MediaBrowser.Model/Lyrics/LyricResponse.cs
@@ -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; }
+}
diff --git a/MediaBrowser.Model/Lyrics/LyricSearchRequest.cs b/MediaBrowser.Model/Lyrics/LyricSearchRequest.cs
new file mode 100644
index 000000000..48c442a55
--- /dev/null
+++ b/MediaBrowser.Model/Lyrics/LyricSearchRequest.cs
@@ -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; }
+}
diff --git a/MediaBrowser.Model/Lyrics/RemoteLyricInfoDto.cs b/MediaBrowser.Model/Lyrics/RemoteLyricInfoDto.cs
new file mode 100644
index 000000000..dda56d198
--- /dev/null
+++ b/MediaBrowser.Model/Lyrics/RemoteLyricInfoDto.cs
@@ -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; }
+}
diff --git a/MediaBrowser.Model/Lyrics/UploadLyricDto.cs b/MediaBrowser.Model/Lyrics/UploadLyricDto.cs
new file mode 100644
index 000000000..0ea8a4c63
--- /dev/null
+++ b/MediaBrowser.Model/Lyrics/UploadLyricDto.cs
@@ -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!;
+}
diff --git a/MediaBrowser.Model/Providers/LyricProviderInfo.cs b/MediaBrowser.Model/Providers/LyricProviderInfo.cs
new file mode 100644
index 000000000..ea9c94185
--- /dev/null
+++ b/MediaBrowser.Model/Providers/LyricProviderInfo.cs
@@ -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; }
+}
diff --git a/MediaBrowser.Model/Providers/RemoteLyricInfo.cs b/MediaBrowser.Model/Providers/RemoteLyricInfo.cs
new file mode 100644
index 000000000..9fb340a58
--- /dev/null
+++ b/MediaBrowser.Model/Providers/RemoteLyricInfo.cs
@@ -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; }
+}
diff --git a/MediaBrowser.Model/Users/UserPolicy.cs b/MediaBrowser.Model/Users/UserPolicy.cs
index 219ed5d5f..951e05763 100644
--- a/MediaBrowser.Model/Users/UserPolicy.cs
+++ b/MediaBrowser.Model/Users/UserPolicy.cs
@@ -93,6 +93,12 @@ namespace MediaBrowser.Model.Users
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>
/// <value><c>true</c> if this instance is disabled; otherwise, <c>false</c>.</value>