Merge pull request #11859 from gnattu/use-ffprobe-audio-metadata-fallback
This commit is contained in:
commit
b8a0cf6a9e
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
@ -150,10 +151,12 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
/// <param name="options">The <see cref="MetadataRefreshOptions"/>.</param>
|
/// <param name="options">The <see cref="MetadataRefreshOptions"/>.</param>
|
||||||
/// <param name="tryExtractEmbeddedLyrics">Whether to extract embedded lyrics to lrc file. </param>
|
/// <param name="tryExtractEmbeddedLyrics">Whether to extract embedded lyrics to lrc file. </param>
|
||||||
private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo mediaInfo, MetadataRefreshOptions options, bool tryExtractEmbeddedLyrics)
|
private async Task FetchDataFromTags(Audio audio, Model.MediaInfo.MediaInfo mediaInfo, MetadataRefreshOptions options, bool tryExtractEmbeddedLyrics)
|
||||||
|
{
|
||||||
|
Tag? tags = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
using var file = TagLib.File.Create(audio.Path);
|
using var file = TagLib.File.Create(audio.Path);
|
||||||
var tagTypes = file.TagTypesOnDisk;
|
var tagTypes = file.TagTypesOnDisk;
|
||||||
Tag? tags = null;
|
|
||||||
|
|
||||||
if (tagTypes.HasFlag(TagTypes.Id3v2))
|
if (tagTypes.HasFlag(TagTypes.Id3v2))
|
||||||
{
|
{
|
||||||
|
@ -183,9 +186,22 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
{
|
{
|
||||||
tags = file.GetTag(TagTypes.Id3v1);
|
tags = file.GetTag(TagTypes.Id3v1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (tags is not null)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
_logger.LogWarning(e, "TagLib-Sharp does not support this audio");
|
||||||
|
}
|
||||||
|
|
||||||
|
tags ??= new TagLib.Id3v2.Tag();
|
||||||
|
tags.AlbumArtists ??= mediaInfo.AlbumArtists;
|
||||||
|
tags.Album ??= mediaInfo.Album;
|
||||||
|
tags.Title ??= mediaInfo.Name;
|
||||||
|
tags.Year = tags.Year == 0U ? Convert.ToUInt32(mediaInfo.ProductionYear, CultureInfo.InvariantCulture) : tags.Year;
|
||||||
|
tags.Performers ??= mediaInfo.Artists;
|
||||||
|
tags.Genres ??= mediaInfo.Genres;
|
||||||
|
tags.Track = tags.Track == 0U ? Convert.ToUInt32(mediaInfo.IndexNumber, CultureInfo.InvariantCulture) : tags.Track;
|
||||||
|
tags.Disc = tags.Disc == 0U ? Convert.ToUInt32(mediaInfo.ParentIndexNumber, CultureInfo.InvariantCulture) : tags.Disc;
|
||||||
|
|
||||||
if (audio.SupportsPeople && !audio.LockedFields.Contains(MetadataField.Cast))
|
if (audio.SupportsPeople && !audio.LockedFields.Contains(MetadataField.Cast))
|
||||||
{
|
{
|
||||||
var people = new List<PersonInfo>();
|
var people = new List<PersonInfo>();
|
||||||
|
@ -287,7 +303,7 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
}
|
}
|
||||||
catch (ArgumentOutOfRangeException ex)
|
catch (ArgumentOutOfRangeException ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Error parsing YEAR tag in {File}. '{TagValue}' is an invalid year.", audio.Path, tags.Year);
|
_logger.LogError(ex, "Error parsing YEAR tag in {File}. '{TagValue}' is an invalid year", audio.Path, tags.Year);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -343,7 +359,6 @@ namespace MediaBrowser.Providers.MediaInfo
|
||||||
await _lyricManager.SaveLyricAsync(audio, "lrc", tags.Lyrics).ConfigureAwait(false);
|
await _lyricManager.SaveLyricAsync(audio, "lrc", tags.Lyrics).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void AddExternalLyrics(
|
private void AddExternalLyrics(
|
||||||
Audio audio,
|
Audio audio,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user