Skip to content

Commit

Permalink
#46 修正
Browse files Browse the repository at this point in the history
  • Loading branch information
aiueo-1234 committed May 2, 2024
1 parent 51d161a commit aff960a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
12 changes: 6 additions & 6 deletions Epub/KoeBook.Epub/Services/ScrapingNaroService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};

Expand Down
3 changes: 2 additions & 1 deletion KoeBook.Core/Services/ClaudeStoryGeneratorService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public async ValueTask<string> 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)
Expand Down
2 changes: 1 addition & 1 deletion KoeBook/Services/CreateCoverFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit aff960a

Please sign in to comment.