@ -1,5 +1,6 @@
using System ;
using System.Collections.Generic ;
using System.Globalization ;
using System.Linq ;
using System.Threading ;
using System.Threading.Tasks ;
@ -150,10 +151,12 @@ namespace MediaBrowser.Providers.MediaInfo
/// <param name="options">The <see cref="MetadataRefreshOptions"/>.</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 )
{
Tag ? tags = null ;
try
{
using var file = TagLib . File . Create ( audio . Path ) ;
var tagTypes = file . TagTypesOnDisk ;
Tag ? tags = null ;
if ( tagTypes . HasFlag ( TagTypes . Id3v2 ) )
{
@ -183,9 +186,22 @@ namespace MediaBrowser.Providers.MediaInfo
{
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 = = 0 U ? Convert . ToUInt32 ( mediaInfo . ProductionYear , CultureInfo . InvariantCulture ) : tags . Year ;
tags . Performers ? ? = mediaInfo . Artists ;
tags . Genres ? ? = mediaInfo . Genres ;
tags . Track = tags . Track = = 0 U ? Convert . ToUInt32 ( mediaInfo . IndexNumber , CultureInfo . InvariantCulture ) : tags . Track ;
tags . Disc = tags . Disc = = 0 U ? Convert . ToUInt32 ( mediaInfo . ParentIndexNumber , CultureInfo . InvariantCulture ) : tags . Disc ;
if ( audio . SupportsPeople & & ! audio . LockedFields . Contains ( MetadataField . Cast ) )
{
var people = new List < PersonInfo > ( ) ;
@ -287,7 +303,7 @@ namespace MediaBrowser.Providers.MediaInfo
}
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 ) ;
}
}
}
private void AddExternalLyrics (
Audio audio ,