From 8dda9220e68782531e74cfbb9bbd94e4c643fe2b Mon Sep 17 00:00:00 2001 From: Robbie Davis Date: Sat, 21 Aug 2021 14:44:35 -0400 Subject: [PATCH] Parsing out cover images (#513) - Fixing workflow - Adding test case --- .github/workflows/sonar-scan.yml | 1 + API.Tests/Parser/MangaParserTests.cs | 6 +++++- API/Parser/Parser.cs | 5 ++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index fa42c9b5b..c548c7334 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -136,6 +136,7 @@ jobs: id: parse-body run: | body='${{ steps.findPr.outputs.body }}' + body=${body//\'/} body="${body//'%'/'%25'}" body="${body//$'\n'/'%0A'}" body="${body//$'\r'/'%0D'}" diff --git a/API.Tests/Parser/MangaParserTests.cs b/API.Tests/Parser/MangaParserTests.cs index d5c0a23ad..348902f84 100644 --- a/API.Tests/Parser/MangaParserTests.cs +++ b/API.Tests/Parser/MangaParserTests.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using API.Entities.Enums; using API.Parser; using Xunit; @@ -407,6 +407,10 @@ namespace API.Tests.Parser FullFilePath = filepath, IsSpecial = false }); + // If an image is cover exclusively, ignore it + filepath = @"E:\Manga\Seraph of the End\cover.png"; + expected.Add(filepath, null); + foreach (var file in expected.Keys) { diff --git a/API/Parser/Parser.cs b/API/Parser/Parser.cs index 6b5a79b4b..6814c9bf8 100644 --- a/API/Parser/Parser.cs +++ b/API/Parser/Parser.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.IO; using System.Linq; using System.Text.RegularExpressions; @@ -552,6 +552,8 @@ namespace API.Parser }; } + if (IsImage(filePath) && IsCoverImage(fileName)) return null; + if (IsImage(filePath)) { // Reset Chapters, Volumes, and Series as images are not good to parse information out of. Better to use folders. @@ -1027,6 +1029,7 @@ namespace API.Parser return Regex.Replace(name.ToLower(), "[^a-zA-Z0-9]", string.Empty); } + /// /// Tests whether the file is a cover image such that: contains "cover", is named "folder", and is an image ///