diff --git a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs index 9b2610ee74..9f37d8b549 100644 --- a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs +++ b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs @@ -122,14 +122,16 @@ namespace MediaBrowser.Providers.MediaInfo audio.Size = mediaInfo.Size; audio.PremiereDate = mediaInfo.PremiereDate; + // Add external lyrics first to prevent the lrc file get overwritten on first scan + var mediaStreams = new List(mediaInfo.MediaStreams); + AddExternalLyrics(audio, mediaStreams, options); + var tryExtractEmbeddedLyrics = mediaStreams.All(s => s.Type != MediaStreamType.Lyric); + if (!audio.IsLocked) { - await FetchDataFromTags(audio, mediaInfo, options).ConfigureAwait(false); + await FetchDataFromTags(audio, mediaInfo, options, tryExtractEmbeddedLyrics).ConfigureAwait(false); } - var mediaStreams = new List(mediaInfo.MediaStreams); - AddExternalLyrics(audio, mediaStreams, options); - audio.HasLyrics = mediaStreams.Any(s => s.Type == MediaStreamType.Lyric); _itemRepo.SaveMediaStreams(audio.Id, mediaStreams, cancellationToken); @@ -141,7 +143,8 @@ namespace MediaBrowser.Providers.MediaInfo /// The . /// The . /// The . - private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo mediaInfo, MetadataRefreshOptions options) + /// Whether to extract embedded lyrics to lrc file. + private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo mediaInfo, MetadataRefreshOptions options, bool tryExtractEmbeddedLyrics) { using var file = TagLib.File.Create(audio.Path); var tagTypes = file.TagTypesOnDisk; @@ -321,9 +324,9 @@ namespace MediaBrowser.Providers.MediaInfo } // Save extracted lyrics if they exist, - // and if we are replacing all metadata or the audio doesn't yet have lyrics. + // and if the audio doesn't yet have lyrics. if (!string.IsNullOrWhiteSpace(tags.Lyrics) - && (options.ReplaceAllMetadata || audio.GetMediaStreams().All(s => s.Type != MediaStreamType.Lyric))) + && tryExtractEmbeddedLyrics) { await _lyricManager.SaveLyricAsync(audio, "lrc", tags.Lyrics).ConfigureAwait(false); }