private void MergeConfigurationAndFiles(MovieConfiguration mlastSelectedMovie, FileInfo file1, FileInfo file2, UI ui) { FileHelper.VideoComparison result = FileHelper.BetterQualityFile(file1, file2); FileHelper.VideoComparison newResult = result; switch (newResult) { case FileHelper.VideoComparison.secondFileBetter: //remove first file and combine locations UpgradeFile("System had identified to", file2, mlastSelectedMovie, file1); break; case FileHelper.VideoComparison.cantTell: case FileHelper.VideoComparison.similar: { AskUserAboutFileReplacement(file1, file2, mlastSelectedMovie, ui); return; } //the other cases of the files being the same or the existing file being better are not enough to save the file case FileHelper.VideoComparison.firstFileBetter: case FileHelper.VideoComparison.same: //remove second file and combine locations UpgradeFile("System had identified to", file1, mlastSelectedMovie, file2); return; default: throw new ArgumentOutOfRangeException(); } }
private bool?ReviewFile(bool unattended, [NotNull] FileInfo newFile, [NotNull] List <ShowItem> matchingShows, [NotNull] FileInfo existingFile, [NotNull] ProcessedEpisode pep) { FileHelper.VideoComparison result = FileHelper.BetterQualityFile(existingFile, newFile); switch (result) { case FileHelper.VideoComparison.secondFileBetter: if (TVSettings.Instance.ReplaceWithBetterQuality) { if (matchingShows.Count > 1) { LOGGER.Warn( $"Keeping {newFile.FullName}. Although it is better quality than {existingFile.FullName}, there are other shows ({string.Join(", ", matchingShows.Select(item => item.ShowName))}) that match."); } else { UpgradeFile(newFile, pep, existingFile); } } else { LOGGER.Warn( $"Keeping {newFile.FullName} as it is better quality than some of the current files for that show (Auto Replace with better quality files is turned off)"); } return(false); case FileHelper.VideoComparison.cantTell: case FileHelper.VideoComparison.similar: if (unattended) { LOGGER.Info( $"Keeping {newFile.FullName} as it might be better quality than {existingFile.FullName}"); return(false); } else { if (matchingShows.Count <= 1) { return(AskUserAboutFileReplacement(newFile, existingFile, pep)); } LOGGER.Warn( $"Keeping {newFile.FullName}. Although it is better quality than {existingFile.FullName}, there are other shows ({string.Join(", ", matchingShows.Select(item => item.ShowName))}) that match."); return(false); } //the other cases of the files being the same or the existing file being better are not enough to save the file case FileHelper.VideoComparison.firstFileBetter: break; case FileHelper.VideoComparison.same: break; default: throw new ArgumentOutOfRangeException(); } return(null); }
private static bool IsNotClearCut(FileHelper.VideoComparison result) { return(result switch { FileHelper.VideoComparison.cantTell => true, FileHelper.VideoComparison.same => true, FileHelper.VideoComparison.similar => true, FileHelper.VideoComparison.firstFileBetter => false, FileHelper.VideoComparison.secondFileBetter => false, _ => throw new ArgumentOutOfRangeException(nameof(result), result, null) });
private bool IsNotClearCut(FileHelper.VideoComparison result) { switch (result) { case FileHelper.VideoComparison.cantTell: return(true); case FileHelper.VideoComparison.same: return(true); case FileHelper.VideoComparison.similar: return(true); case FileHelper.VideoComparison.firstFileBetter: return(false); case FileHelper.VideoComparison.secondFileBetter: return(false); default: throw new ArgumentOutOfRangeException(nameof(result), result, null); } }
private bool?ReviewFile(bool unattended, [NotNull] FileInfo newFile, [NotNull] IReadOnlyCollection <ShowConfiguration> matchingShows, [NotNull] FileInfo existingFile, [NotNull] ProcessedEpisode pep, IDialogParent owner) { FileHelper.VideoComparison result = FileHelper.BetterQualityFile(existingFile, newFile); FileHelper.VideoComparison newResult = result; if (TVSettings.Instance.ReplaceWithBetterQuality && TVSettings.Instance.ForceSystemToDecideOnUpgradedFiles && IsNotClearCut(result)) { //User has asked us to make a call newResult = existingFile.Length >= newFile.Length ? FileHelper.VideoComparison.firstFileBetter : FileHelper.VideoComparison.secondFileBetter; } switch (newResult) { case FileHelper.VideoComparison.secondFileBetter: if (TVSettings.Instance.ReplaceWithBetterQuality) { if (matchingShows.Count > 1) { LOGGER.Warn( $"Keeping {newFile.FullName}. Although it is better quality than {existingFile.FullName}, there are other shows ({matchingShows.Select(item => item.ShowName).ToCsv()}) that match."); } else { UpgradeFile(newFile, pep, existingFile); } } else { LOGGER.Warn( $"Keeping {newFile.FullName} as it is better quality than some of the current files for that show (Auto Replace with better quality files is turned off)"); } return(false); case FileHelper.VideoComparison.cantTell: case FileHelper.VideoComparison.similar: if (unattended) { LOGGER.Info( $"Keeping {newFile.FullName} as it might be better quality than {existingFile.FullName}"); return(false); } else { if (matchingShows.Count <= 1) { return(AskUserAboutFileReplacement(newFile, existingFile, pep, owner)); } LOGGER.Warn( $"Keeping {newFile.FullName}. Although it is better quality than {existingFile.FullName}, there are other shows ({matchingShows.Select(item => item.ShowName).ToCsv()}) that match."); return(false); } //the other cases of the files being the same or the existing file being better are not enough to save the file case FileHelper.VideoComparison.firstFileBetter: break; case FileHelper.VideoComparison.same: break; default: throw new ArgumentOutOfRangeException(); } return(null); }