Skip to content

Commit

Permalink
Remove failure count
Browse files Browse the repository at this point in the history
  • Loading branch information
codeconscious committed Jul 16, 2024
1 parent 2eed469 commit 7830f9f
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions src/AudioTagger.Console/Operations/TagArtworkExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ private static void ProcessDirectory(FilesGroupedByDir fileGroup, IPrinter print
{
printer.Warning("More than one image is most populous, but only one will be extracted.");
}

var filesWithChosenMostCommonArt = filesWithMostCommonArt.First();

ExtractArtwork(filesWithChosenMostCommonArt, printer);
Expand All @@ -92,13 +93,9 @@ private static void ProcessDirectory(FilesGroupedByDir fileGroup, IPrinter print
}
}

private static void ExtractArtwork(
FilesGroupedByCount filesWithChosenMostCommonArt,
IPrinter printer)
private static void ExtractArtwork(FilesGroupedByCount fileGroup, IPrinter printer)
{
int failures = 0;

MediaFile artSourceFile = filesWithChosenMostCommonArt.First();
MediaFile artSourceFile = fileGroup.First();
string directoryName = artSourceFile.FileInfo.DirectoryName!;

var extractResult = artSourceFile.ExtractArtworkToFile(directoryName, _artworkFileName);
Expand All @@ -108,16 +105,8 @@ private static void ExtractArtwork(
}
else
{
failures++;
printer.FirstError(extractResult, "Artwork extraction error:");
}

if (failures != 0)
{
var errorLabel = failures == 1 ? "error" : "errors";
printer.Warning($"There were {failures} extraction {errorLabel}, so will not delete any artwork.");
return;
}
}

private static void RemoveArtworkAndRewriteTags(MediaFile file, IPrinter printer)
Expand Down

0 comments on commit 7830f9f

Please sign in to comment.