From aff960aa8ff58bd824390dac7a1d33aa1a06fef0 Mon Sep 17 00:00:00 2001 From: aiueo-1234 <130837816+aiueo-1234@users.noreply.github.com> Date: Thu, 2 May 2024 11:13:18 +0900 Subject: [PATCH 1/2] =?UTF-8?q?#46=20=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Epub/KoeBook.Epub/Services/ScrapingNaroService.cs | 12 ++++++------ KoeBook.Core/Services/ClaudeStoryGeneratorService.cs | 3 ++- KoeBook/Services/CreateCoverFileService.cs | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs b/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs index 6741549..8daa51c 100644 --- a/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs +++ b/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs @@ -213,12 +213,12 @@ internal static string GetNcode(string url) return uri.Segments switch { - // https://ncode.syosetu.com/n0000a/ のとき - ["/", var ncode] when IsAscii(ncode) => ncode.TrimEnd('/'), - // https://ncode.syosetu.com/n0000a/12 のとき - ["/", var ncode, var num] when IsAscii(ncode) && num.TrimEnd('/').All(char.IsAsciiDigit) => ncode.TrimEnd('/'), - // https://ncode.syosetu.com/novelview/infotop/ncode/n0000a/ のとき - ["/", "novelview/", "infotop/", "ncode/", var ncode] when IsAscii(ncode) => ncode.TrimEnd('/'), + // https://ncode.syosetu.com/n0000a/ のとき + ["/", var ncode] when IsAscii(ncode) => ncode.TrimEnd('/'), + // https://ncode.syosetu.com/n0000a/12 のとき + ["/", var ncode, var num] when IsAscii(ncode) && num.TrimEnd('/').All(char.IsAsciiDigit) => ncode.TrimEnd('/'), + // https://ncode.syosetu.com/novelview/infotop/ncode/n0000a/ のとき + ["/", "novelview/", "infotop/", "ncode/", var ncode] when IsAscii(ncode) => ncode.TrimEnd('/'), _ => throw new EbookException(ExceptionType.InvalidUrl), }; diff --git a/KoeBook.Core/Services/ClaudeStoryGeneratorService.cs b/KoeBook.Core/Services/ClaudeStoryGeneratorService.cs index 3abf6de..e9e7c43 100644 --- a/KoeBook.Core/Services/ClaudeStoryGeneratorService.cs +++ b/KoeBook.Core/Services/ClaudeStoryGeneratorService.cs @@ -28,7 +28,8 @@ public async ValueTask CreateStoryAsync(StoryGenre storyGenre, string pr }, cancellationToken: cancellationToken ); - return storyXml.ToString(); + var xml = storyXml.ToString(); + return xml[xml.IndexOf('<')..(xml.LastIndexOf('>') + 1)]; } catch (OperationCanceledException) { throw; } catch (Exception e) diff --git a/KoeBook/Services/CreateCoverFileService.cs b/KoeBook/Services/CreateCoverFileService.cs index 6552e63..e873c8f 100644 --- a/KoeBook/Services/CreateCoverFileService.cs +++ b/KoeBook/Services/CreateCoverFileService.cs @@ -39,7 +39,7 @@ public void Create(string title, string author, string coverFilePath) graphics.DrawString($"著者: {author}", authorFont, brush, new Rectangle(0, 1920, 1600, 640), stringFormat); // png として出力 - bitmap.Save(Path.Combine(coverFilePath, "Cover.png"), ImageFormat.Png); + bitmap.Save(coverFilePath, ImageFormat.Png); } catch (Exception ex) { From 04264b418674edf612267f4b63befe5325ff09a4 Mon Sep 17 00:00:00 2001 From: miyaji255 <84168445+miyaji255@users.noreply.github.com> Date: Thu, 2 May 2024 11:21:48 +0900 Subject: [PATCH 2/2] fmt --- Epub/KoeBook.Epub/Services/ScrapingNaroService.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs b/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs index 8daa51c..6741549 100644 --- a/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs +++ b/Epub/KoeBook.Epub/Services/ScrapingNaroService.cs @@ -213,12 +213,12 @@ internal static string GetNcode(string url) return uri.Segments switch { - // https://ncode.syosetu.com/n0000a/ のとき - ["/", var ncode] when IsAscii(ncode) => ncode.TrimEnd('/'), - // https://ncode.syosetu.com/n0000a/12 のとき - ["/", var ncode, var num] when IsAscii(ncode) && num.TrimEnd('/').All(char.IsAsciiDigit) => ncode.TrimEnd('/'), - // https://ncode.syosetu.com/novelview/infotop/ncode/n0000a/ のとき - ["/", "novelview/", "infotop/", "ncode/", var ncode] when IsAscii(ncode) => ncode.TrimEnd('/'), + // https://ncode.syosetu.com/n0000a/ のとき + ["/", var ncode] when IsAscii(ncode) => ncode.TrimEnd('/'), + // https://ncode.syosetu.com/n0000a/12 のとき + ["/", var ncode, var num] when IsAscii(ncode) && num.TrimEnd('/').All(char.IsAsciiDigit) => ncode.TrimEnd('/'), + // https://ncode.syosetu.com/novelview/infotop/ncode/n0000a/ のとき + ["/", "novelview/", "infotop/", "ncode/", var ncode] when IsAscii(ncode) => ncode.TrimEnd('/'), _ => throw new EbookException(ExceptionType.InvalidUrl), };