private void LoadAdditionalVariousArtistsAlbums() { if (File.Exists(AdditionalVariousArtistsAlbumFile)) { Logger.Info("Loading additional album various artist..."); Data.AdditionalVariousArtistsAlbums.AdditionalVariousArtistsAlbums additionalVAAlbums = null; XmlSerializer serializer = new XmlSerializer(typeof(Data.AdditionalVariousArtistsAlbums.AdditionalVariousArtistsAlbums)); using (StreamReader reader = new StreamReader(AdditionalVariousArtistsAlbumFile)) { additionalVAAlbums = (Data.AdditionalVariousArtistsAlbums.AdditionalVariousArtistsAlbums)serializer.Deserialize(reader); } if (additionalVAAlbums.Items != null) { foreach (var folder in additionalVAAlbums.Items) { AdditionalVariousArtistsAlbums.Add(folder.Value); } } } }
private void CheckTagDetails(Data.Tables.MediaFiles mediaFile) { try { bool isSpecialtyAlbum = false; bool isNamedAsVariousArtistAlbum = AdditionalVariousArtistsAlbums.Contains(Path.GetDirectoryName(mediaFile.FilePath)); foreach (var specialtyAlbumFolder in SpecialtyAlbums) { isSpecialtyAlbum = mediaFile.FilePath.Contains(specialtyAlbumFolder); if (isSpecialtyAlbum) { break; } } if (Globals.VerboseLogging) { Logger.Info($"Checking for tag errors in file '{mediaFile.FilePath}'"); } AlbumDetailed album = AlbumDictionary[Path.GetDirectoryName(mediaFile.FilePath) + "\\"]; if (!mediaFile.ValidV1Tag) { LogTagError(mediaFile, $"File has an invalid V1 Tag."); } if (!mediaFile.ValidV2Tag) { LogTagError(mediaFile, $"File has an invalid V2 Tag."); } if ((mediaFile.Year ?? "").Length != 4) { LogTagError(mediaFile, $"Tag has invalid year. Year: {mediaFile.Year}"); } if ((mediaFile.Artist ?? "").Length < 1) { LogTagError(mediaFile, $"Tag has invalid artist. Artist: {mediaFile.Artist}"); } if ((mediaFile.TrackNumber ?? "").Length < 1) { LogTagError(mediaFile, $"Tag has invalid track number. Track Number: {mediaFile.TrackNumber}"); } if ((mediaFile.Album ?? "").Length < 1) { LogTagError(mediaFile, $"Tag has invalid album name. Album Name: {mediaFile.Album}"); } if ((mediaFile.Title ?? "").Length < 1) { LogTagError(mediaFile, $"Tag has invalid title. Title: {mediaFile.Title}"); } else if ((mediaFile.Title ?? "").Contains("\\")) { LogTagError(mediaFile, $"Tag title has invalid character. Title: {mediaFile.Title}"); } if ((mediaFile.Genre ?? "").Length < 1) { LogTagError(mediaFile, $"Tag title has invalid genre. Genre: {mediaFile.Genre}"); } if (mediaFile.ValidV2Tag && (mediaFile.AlbumArtist ?? "").Length < 1) { LogTagError(mediaFile, $"Tag title has invalid album artist. Album Artist: {mediaFile.AlbumArtist}"); } if (mediaFile.ValidV2Tag && !string.IsNullOrEmpty(mediaFile.DiscNumberAndCount)) { var discNumberAndTotal = mediaFile.DiscNumberAndCount.Split('/'); if (discNumberAndTotal.Count() > 1) { if (discNumberAndTotal[1] != album.BaseAlbum.Discs) { LogTagError(mediaFile, $"Disc total tag does not match disc total of folder structure. Track details: {discNumberAndTotal[1]}; Album details: {album.BaseAlbum.Discs}"); } } else if (ReportDiscNumberWithoutTotal) { LogTagError(mediaFile, $"Disc total tag does not exist. Track details: {mediaFile.DiscNumberAndCount}"); } if (discNumberAndTotal[0].StartsWith("0")) { LogTagError(mediaFile, $"Disc number tag is not properly formatted. Details: {discNumberAndTotal[0]}"); } if (!int.TryParse(discNumberAndTotal[0], out int discNumber)) { LogTagError(mediaFile, $"Disc number tag is not a number. Details: {discNumberAndTotal[0]}"); } if (discNumberAndTotal[0] != album.BaseAlbum.Disc) { LogTagError(mediaFile, $"Disc number tag does not match disc number of folder structure. Track details: {discNumberAndTotal[0]}; Album details: {album.BaseAlbum.Disc}"); } } else if (mediaFile.ValidV2Tag && string.IsNullOrEmpty(mediaFile.DiscNumberAndCount) && ReportBlankDiscNumber) { LogTagError(mediaFile, $"Track does not have a disc number and total set."); } if (mediaFile.ContainsOtherTags) { LogTagError(mediaFile, $"File contains other tag data. Other tags: {mediaFile.OtherTags}"); } if (!album.AllAlbumNamesMatch) { LogTagError(mediaFile, $"Other tracks in this folder have different album names. Album path: {Path.GetDirectoryName(mediaFile.FilePath)}"); } if (!album.AllDiscNumbersMatch) { LogTagError(mediaFile, $"Other tracks in this folder have different disc numbers. Album path: {Path.GetDirectoryName(mediaFile.FilePath)}"); } if (!album.AllAlbumArtistsMatch) { LogTagError(mediaFile, $"Other tracks in this folder have different album artists. Album path: {Path.GetDirectoryName(mediaFile.FilePath)}"); } if (!album.AllAlbumGenresMatch) { LogTagError(mediaFile, $"Other tracks in this folder have different genres. Album path: {Path.GetDirectoryName(mediaFile.FilePath)}"); } if (!album.AllAlbumYearsMatch && !AlbumYearExceptions.Contains(Path.GetDirectoryName(mediaFile.FilePath))) { LogTagError(mediaFile, $"Other tracks in this folder have different years. Album path: {Path.GetDirectoryName(mediaFile.FilePath)}"); } if (!album.HasAlbumArt && !AlbumArtExceptions.Contains(Path.GetDirectoryName(mediaFile.FilePath))) { LogTagError(mediaFile, $"Album does not have album art. Album: {album.BaseAlbum.FolderPath}"); } else if (album.HasAlbumArt && !album.ValidAlbumArt) { LogTagError(mediaFile, $"Album does not have a valid JPG file. Album: {album.BaseAlbum.FolderPath}"); } try { if (!isSpecialtyAlbum) { var fileDirectory = new DirectoryInfo(mediaFile.FilePath).Parent; var albumDirectoryName = fileDirectory.Name; if (AlbumSubDirectories.Contains(albumDirectoryName)) { albumDirectoryName = fileDirectory.Parent.Name; } var albumTagName = $"{mediaFile.Year} - {ReplaceInvalidPathCharacters(mediaFile.Album)}"; if (albumDirectoryName != albumTagName) { LogTagError(mediaFile, $"Album tag does not match folder name. Tag: {albumTagName}; Folder: {albumDirectoryName}"); } if (!isNamedAsVariousArtistAlbum) { var mp3FileName = new FileInfo(mediaFile.FilePath).Name.Replace(".MP3", ".mp3"); var tagFileName = $"{mediaFile.TrackNumber.Split('/')[0].PadLeft(2, '0') } - {ReplaceInvalidFileCharacters(mediaFile.Title)}.mp3"; if (mp3FileName != tagFileName) { LogTagError(mediaFile, $"File tag does not match file name. Tag: {tagFileName}; File: {mp3FileName}"); } } } else { if (Globals.VerboseLogging) { Logger.Info($"Skipping album name check for '{mediaFile.FilePath}' (Specialty album)."); } } } catch (Exception specialEx) { LogTagError(mediaFile, $"There was an error checking specialty album information. Error: {specialEx.Message}"); } } catch (Exception ex) { LogTagError(mediaFile, $"Fatal error checking tag data. Error: {ex.Message}"); } FilesChecked++; if (FilesChecked % int.Parse(ConfigurationManager.AppSettings["ProcessUpdateCounter"] ?? "100") == 0) { Logger.Info($"Checked {FilesChecked} tags..."); } }