mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-06-02 13:15:25 -04:00
Add support for reading and storing Recording MBIDs from file metadata (#12173)
* Add recording metadata provider * Add recording MBID * Save recording MBID during probing * Set recording ID in probe result normalizer * Add recording external media type * Reimplement after changes in upstream * Rename variable * Rename variable * Revert "Set recording ID in probe result normalizer" This reverts commit 9dd18c8aba3f970a5816a13a33acf3d58b0e440f. * Fix setting provider ID * Simplify code * Fix comment * Add missing using
This commit is contained in:
parent
f6603018d6
commit
93dd5551df
@ -84,6 +84,11 @@ namespace MediaBrowser.Model.Entities
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The TvMaze provider.
|
/// The TvMaze provider.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
TvMaze = 19
|
TvMaze = 19,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The MusicBrainz recording provider.
|
||||||
|
/// </summary>
|
||||||
|
MusicBrainzRecording = 20,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,6 +71,11 @@ namespace MediaBrowser.Model.Providers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// A book.
|
/// A book.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Book = 13
|
Book = 13,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A music recording.
|
||||||
|
/// </summary>
|
||||||
|
Recording = 14
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ using MediaBrowser.Model.Entities;
|
|||||||
using MediaBrowser.Model.Extensions;
|
using MediaBrowser.Model.Extensions;
|
||||||
using MediaBrowser.Model.MediaInfo;
|
using MediaBrowser.Model.MediaInfo;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using static Jellyfin.Extensions.StringExtensions;
|
||||||
|
|
||||||
namespace MediaBrowser.Providers.MediaInfo
|
namespace MediaBrowser.Providers.MediaInfo
|
||||||
{
|
{
|
||||||
@ -400,6 +401,24 @@ namespace MediaBrowser.Providers.MediaInfo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.ReplaceAllMetadata || !audio.TryGetProviderId(MetadataProvider.MusicBrainzRecording, out _))
|
||||||
|
{
|
||||||
|
if ((track.AdditionalFields.TryGetValue("MUSICBRAINZ_TRACKID", out var recordingMbId)
|
||||||
|
|| track.AdditionalFields.TryGetValue("MusicBrainz Track Id", out recordingMbId))
|
||||||
|
&& !string.IsNullOrEmpty(recordingMbId))
|
||||||
|
{
|
||||||
|
audio.TrySetProviderId(MetadataProvider.MusicBrainzRecording, recordingMbId);
|
||||||
|
}
|
||||||
|
else if (track.AdditionalFields.TryGetValue("UFID", out var ufIdValue) && !string.IsNullOrEmpty(ufIdValue))
|
||||||
|
{
|
||||||
|
// If tagged with MB Picard, the format is 'http://musicbrainz.org\0<recording MBID>'
|
||||||
|
if (ufIdValue.Contains("musicbrainz.org", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
audio.TrySetProviderId(MetadataProvider.MusicBrainzRecording, ufIdValue.AsSpan().RightPart('\0').ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Save extracted lyrics if they exist,
|
// Save extracted lyrics if they exist,
|
||||||
// and if the audio doesn't yet have lyrics.
|
// and if the audio doesn't yet have lyrics.
|
||||||
var lyrics = track.Lyrics.SynchronizedLyrics.Count > 0 ? track.Lyrics.FormatSynchToLRC() : track.Lyrics.UnsynchronizedLyrics;
|
var lyrics = track.Lyrics.SynchronizedLyrics.Count > 0 ? track.Lyrics.FormatSynchToLRC() : track.Lyrics.UnsynchronizedLyrics;
|
||||||
|
@ -0,0 +1,27 @@
|
|||||||
|
using MediaBrowser.Controller.Entities.Audio;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
|
using MediaBrowser.Model.Providers;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Providers.Plugins.MusicBrainz;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// MusicBrainz recording id.
|
||||||
|
/// </summary>
|
||||||
|
public class MusicBrainzRecordingId : IExternalId
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string ProviderName => "MusicBrainz";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string Key => MetadataProvider.MusicBrainzRecording.ToString();
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public ExternalIdMediaType? Type => ExternalIdMediaType.Recording;
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public string UrlFormatString => Plugin.Instance!.Configuration.Server + "/recording/{0}";
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public bool Supports(IHasProviderIds item) => item is Audio;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user