Fixed: Ensure Quality is always initialised in AudioTag.Read (#694)

* Fixed: Ensure Quality is always initialised in AudioTag.Read

* Fixed: Log quality message on fallback quality detection
This commit is contained in:
ta264 2019-03-23 08:36:49 +00:00 committed by GitHub
commit b557f620d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -200,16 +200,20 @@ namespace NzbDrone.Core.MediaFiles
// Log as error so it goes to sentry with correct fingerprint
Logger.Error(ex, "Tag reading failed for {0}", path);
}
// make sure these are initialized to avoid errors later on
Quality = QualityParser.ParseQuality(path, null, EstimateBitrate(file, path));
Logger.Debug($"Quality parsed: {Quality}, Source: {Quality.QualityDetectionSource}");
MediaInfo = new MediaInfoModel();
}
finally
{
file?.Dispose();
}
// make sure these are initialized to avoid errors later on
if (Quality == null)
{
Quality = QualityParser.ParseQuality(path, null, EstimateBitrate(file, path));
Logger.Debug($"Unable to parse qulity from tag, Quality parsed from file path: {Quality}, Source: {Quality.QualityDetectionSource}");
}
MediaInfo = MediaInfo ?? new MediaInfoModel();
}
private int EstimateBitrate(TagLib.File file, string path)