Misc Fixes and Changes (#927)

* Cleaned up a ton of warnings/suggestions from the IDE.

* Fixed a bug when clearing the filters some presets could be undone.

* Renamed a class in the OPDS spec

* Simplified logic for when Fit To Screen rendering logic occurs. It now works always rather than only on cover images.

* Give some additional info to the user on what the differences between Library Types are

* Don't scan .qpkg folders (QNAP devices)

* Refactored some code to enable ability to test CoverImage Test. This is a broken test, test.zip is waiting on an issue in NetVips.

* Fixed an issue where Extra might get flagged as special too early, if in a word like Extraordinary

* Cleaned up the regex for the extra issue to be more flexible
This commit is contained in:
Joseph Milazzo 2022-01-12 15:00:00 -08:00 committed by GitHub
parent 6afc17e93e
commit fb71d54fe6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 162 additions and 361 deletions

View file

@ -476,7 +476,7 @@ namespace API.Parser
{
// All Keywords, does not account for checking if contains volume/chapter identification. Parser.Parse() will handle.
new Regex(
@"(?<Special>Specials?|OneShot|One\-Shot|Omake|Extra( Chapter)?|Art Collection|Side( |_)Stories|Bonus)",
@"(?<Special>Specials?|OneShot|One\-Shot|Omake|Extra(?:(\sChapter)?[^\S])|Art Collection|Side( |_)Stories|Bonus)",
MatchOptions, RegexTimeout),
};
@ -484,7 +484,7 @@ namespace API.Parser
{
// All Keywords, does not account for checking if contains volume/chapter identification. Parser.Parse() will handle.
new Regex(
@"(?<Special>Specials?|OneShot|One\-Shot|Extra( Chapter)?|Book \d.+?|Compendium \d.+?|Omnibus \d.+?|[_\s\-]TPB[_\s\-]|FCBD \d.+?|Absolute \d.+?|Preview \d.+?|Art Collection|Side(\s|_)Stories|Bonus|Hors Série|(\W|_|-)HS(\W|_|-)|(\W|_|-)THS(\W|_|-))",
@"(?<Special>Specials?|OneShot|One\-Shot|Extra(?:(\sChapter)?[^\S])|Book \d.+?|Compendium \d.+?|Omnibus \d.+?|[_\s\-]TPB[_\s\-]|FCBD \d.+?|Absolute \d.+?|Preview \d.+?|Art Collection|Side(\s|_)Stories|Bonus|Hors Série|(\W|_|-)HS(\W|_|-)|(\W|_|-)THS(\W|_|-))",
MatchOptions, RegexTimeout),
};
@ -502,148 +502,6 @@ namespace API.Parser
MatchOptions, RegexTimeout
);
// /// <summary>
// /// Parses information out of a file path. Will fallback to using directory name if Series couldn't be parsed
// /// from filename.
// /// </summary>
// /// <param name="filePath"></param>
// /// <param name="rootPath">Root folder</param>
// /// <param name="type">Defaults to Manga. Allows different Regex to be used for parsing.</param>
// /// <returns><see cref="ParserInfo"/> or null if Series was empty</returns>
// public static ParserInfo Parse(string filePath, string rootPath, IDirectoryService directoryService, LibraryType type = LibraryType.Manga)
// {
// var fileName = directoryService.FileSystem.Path.GetFileNameWithoutExtension(filePath);
// ParserInfo ret;
//
// if (IsEpub(filePath))
// {
// ret = new ParserInfo()
// {
// Chapters = ParseChapter(fileName) ?? ParseComicChapter(fileName),
// Series = ParseSeries(fileName) ?? ParseComicSeries(fileName),
// Volumes = ParseVolume(fileName) ?? ParseComicVolume(fileName),
// Filename = Path.GetFileName(filePath),
// Format = ParseFormat(filePath),
// FullFilePath = filePath
// };
// }
// else
// {
// ret = new ParserInfo()
// {
// Chapters = type == LibraryType.Manga ? ParseChapter(fileName) : ParseComicChapter(fileName),
// Series = type == LibraryType.Manga ? ParseSeries(fileName) : ParseComicSeries(fileName),
// Volumes = type == LibraryType.Manga ? ParseVolume(fileName) : ParseComicVolume(fileName),
// Filename = Path.GetFileName(filePath),
// Format = ParseFormat(filePath),
// Title = Path.GetFileNameWithoutExtension(fileName),
// FullFilePath = filePath
// };
// }
//
// if (IsImage(filePath) && IsCoverImage(filePath)) return null;
//
// if (IsImage(filePath))
// {
// // Reset Chapters, Volumes, and Series as images are not good to parse information out of. Better to use folders.
// ret.Volumes = DefaultVolume;
// ret.Chapters = DefaultChapter;
// ret.Series = string.Empty;
// }
//
// if (ret.Series == string.Empty || IsImage(filePath))
// {
// // Try to parse information out of each folder all the way to rootPath
// ParseFromFallbackFolders(filePath, rootPath, type, directoryService, ref ret);
// }
//
// var edition = ParseEdition(fileName);
// if (!string.IsNullOrEmpty(edition))
// {
// ret.Series = CleanTitle(ret.Series.Replace(edition, ""), type is LibraryType.Comic);
// ret.Edition = edition;
// }
//
// var isSpecial = type == LibraryType.Comic ? ParseComicSpecial(fileName) : ParseMangaSpecial(fileName);
// // We must ensure that we can only parse a special out. As some files will have v20 c171-180+Omake and that
// // could cause a problem as Omake is a special term, but there is valid volume/chapter information.
// if (ret.Chapters == DefaultChapter && ret.Volumes == DefaultVolume && !string.IsNullOrEmpty(isSpecial))
// {
// ret.IsSpecial = true;
// ParseFromFallbackFolders(filePath, rootPath, type, directoryService, ref ret);
// }
//
// // If we are a special with marker, we need to ensure we use the correct series name. we can do this by falling back to Folder name
// if (HasSpecialMarker(fileName))
// {
// ret.IsSpecial = true;
// ret.Chapters = DefaultChapter;
// ret.Volumes = DefaultVolume;
//
// ParseFromFallbackFolders(filePath, rootPath, type, directoryService, ref ret);
// }
//
// if (string.IsNullOrEmpty(ret.Series))
// {
// ret.Series = CleanTitle(fileName, type is LibraryType.Comic);
// }
//
// // Pdfs may have .pdf in the series name, remove that
// if (IsPdf(filePath) && ret.Series.ToLower().EndsWith(".pdf"))
// {
// ret.Series = ret.Series.Substring(0, ret.Series.Length - ".pdf".Length);
// }
//
// return ret.Series == string.Empty ? null : ret;
// }
//
// /// <summary>
// ///
// /// </summary>
// /// <param name="filePath"></param>
// /// <param name="rootPath"></param>
// /// <param name="type"></param>
// /// <param name="ret">Expects a non-null ParserInfo which this method will populate</param>
// public static void ParseFromFallbackFolders(string filePath, string rootPath, LibraryType type, IDirectoryService directoryService, ref ParserInfo ret)
// {
// var fallbackFolders = directoryService.GetFoldersTillRoot(rootPath, filePath).ToList();
// for (var i = 0; i < fallbackFolders.Count; i++)
// {
// var folder = fallbackFolders[i];
// if (!string.IsNullOrEmpty(ParseMangaSpecial(folder))) continue;
//
// var parsedVolume = type is LibraryType.Manga ? ParseVolume(folder) : ParseComicVolume(folder);
// var parsedChapter = type is LibraryType.Manga ? ParseChapter(folder) : ParseComicChapter(folder);
//
// if (!parsedVolume.Equals(DefaultVolume) || !parsedChapter.Equals(DefaultChapter))
// {
// if ((ret.Volumes.Equals(DefaultVolume) || string.IsNullOrEmpty(ret.Volumes)) && !parsedVolume.Equals(DefaultVolume))
// {
// ret.Volumes = parsedVolume;
// }
// if ((ret.Chapters.Equals(DefaultChapter) || string.IsNullOrEmpty(ret.Chapters)) && !parsedChapter.Equals(DefaultChapter))
// {
// ret.Chapters = parsedChapter;
// }
// }
//
// var series = ParseSeries(folder);
//
// if ((string.IsNullOrEmpty(series) && i == fallbackFolders.Count - 1))
// {
// ret.Series = CleanTitle(folder, type is LibraryType.Comic);
// break;
// }
//
// if (!string.IsNullOrEmpty(series))
// {
// ret.Series = series;
// break;
// }
// }
// }
public static MangaFormat ParseFormat(string filePath)
{
if (IsArchive(filePath)) return MangaFormat.Archive;

View file

@ -90,7 +90,6 @@ namespace API.Parser
Title = string.IsNullOrEmpty(Title) ? info2.Title : Title;
Series = string.IsNullOrEmpty(Series) ? info2.Series : Series;
IsSpecial = IsSpecial || info2.IsSpecial;
// TODO: Merge ComicInfos?
}
}
}