aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Providers/MediaInfo/AudioFileProber.cs')
-rw-r--r--MediaBrowser.Providers/MediaInfo/AudioFileProber.cs35
1 files changed, 31 insertions, 4 deletions
diff --git a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
index 4d4b59b8c..67b84681d 100644
--- a/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
+++ b/MediaBrowser.Providers/MediaInfo/AudioFileProber.cs
@@ -228,6 +228,7 @@ namespace MediaBrowser.Providers.MediaInfo
audio.RunTimeTicks = mediaInfo.RunTimeTicks;
audio.Size = mediaInfo.Size;
+ audio.PremiereDate = mediaInfo.PremiereDate;
if (!audio.IsLocked)
{
@@ -348,9 +349,9 @@ namespace MediaBrowser.Providers.MediaInfo
}
}
- if (!audio.LockedFields.Contains(MetadataField.Name))
+ if (!audio.LockedFields.Contains(MetadataField.Name) && !string.IsNullOrEmpty(tags.Title))
{
- audio.Name = options.ReplaceAllMetadata || string.IsNullOrEmpty(audio.Name) ? tags.Title : audio.Name;
+ audio.Name = tags.Title;
}
if (options.ReplaceAllMetadata)
@@ -370,7 +371,11 @@ namespace MediaBrowser.Providers.MediaInfo
{
var year = Convert.ToInt32(tags.Year);
audio.ProductionYear = year;
- audio.PremiereDate = new DateTime(year, 01, 01);
+
+ if (!audio.PremiereDate.HasValue)
+ {
+ audio.PremiereDate = new DateTime(year, 01, 01);
+ }
}
if (!audio.LockedFields.Contains(MetadataField.Genres))
@@ -402,7 +407,14 @@ namespace MediaBrowser.Providers.MediaInfo
if (options.ReplaceAllMetadata || !audio.TryGetProviderId(MetadataProvider.MusicBrainzTrack, out _))
{
- audio.SetProviderId(MetadataProvider.MusicBrainzTrack, tags.MusicBrainzTrackId);
+ // Fallback to ffprobe as TagLib incorrectly provides recording MBID in `tags.MusicBrainzTrackId`.
+ // See https://github.com/mono/taglib-sharp/issues/304
+ var mediaInfo = await GetMediaInfo(audio, CancellationToken.None).ConfigureAwait(false);
+ var trackMbId = mediaInfo.GetProviderId(MetadataProvider.MusicBrainzTrack);
+ if (trackMbId is not null)
+ {
+ audio.SetProviderId(MetadataProvider.MusicBrainzTrack, trackMbId);
+ }
}
// Save extracted lyrics if they exist,
@@ -426,5 +438,20 @@ namespace MediaBrowser.Providers.MediaInfo
audio.LyricFiles = externalLyricFiles.Select(i => i.Path).Distinct().ToArray();
currentStreams.AddRange(externalLyricFiles);
}
+
+ private async Task<Model.MediaInfo.MediaInfo> GetMediaInfo(BaseItem item, CancellationToken cancellationToken)
+ {
+ var request = new MediaInfoRequest
+ {
+ MediaType = DlnaProfileType.Audio,
+ MediaSource = new MediaSourceInfo
+ {
+ Path = item.Path,
+ Protocol = item.PathProtocol ?? MediaProtocol.File
+ }
+ };
+
+ return await _mediaEncoder.GetMediaInfo(request, cancellationToken).ConfigureAwait(false);
+ }
}
}