public static File ConvertMusicFileTagToTag(MusicFileTag musicTag) { File tagInfo = TagLib.File.Create(musicTag.FilePath); //tagInfo.Tag.Clear(); tagInfo.Tag.Performers = new string[] { musicTag.Artist ?? "" }; // Sets the FirstPerformer tagInfo.Tag.AlbumArtists = new string[] { musicTag.Artist ?? "" }; // Sets the FirstArtist tagInfo.Tag.Genres = new string[] { musicTag.Genre ?? "" }; // Sets the FirstGenre tagInfo.Tag.Album = musicTag.Album; tagInfo.Tag.Title = musicTag.Title; tagInfo.Tag.Comment = musicTag.Comment; tagInfo.Tag.Year = musicTag.Year; tagInfo.Tag.Track = musicTag.Track; return(tagInfo); }
/// <summary> /// Convert a ID3 Tag to an object of MusicFileTag /// </summary> /// <param name="tag">The ID3 Tag, which has to be converted</param> /// <param name="filePath">The path to the location on the drive to the current file</param> /// <returns>The converted MusicFileTag object</returns> public static MusicFileTag ConvertTagToMusicFileTag(Tag tag, string filePath) { var tmp = new MusicFileTag(); tmp.Artist = tag.FirstPerformer; tmp.Album = tag.Album; tmp.Genre = tag.FirstGenre; tmp.Year = tag.Year; tmp.Title = tag.Title; tmp.Comment = tag.Comment; if (tag.Pictures.Length >= 1) { tmp.AlbumCover = tag.Pictures?.First().Data.Data; } tmp.Track = tag.Track; tmp.FilePath = filePath; tmp.FileName = System.IO.Path.GetFileNameWithoutExtension(filePath); return(tmp); }