Elements { get; set; } = [];
- public string CreateSectionXhtml()
- {
- var builder = new StringBuilder($"""
-
-
-
-
- {Title}
-
-
- """);
-
- for (var i = 0; i < Elements.Count; i++)
- {
- if (Elements[i] is Paragraph para)
- {
- builder.AppendLine($"""
-
- {para.Text}
-
- """);
- }
- else if (Elements[i] is Picture pic && File.Exists(pic.PictureFilePath))
- {
- builder.AppendLine($"""
-
-
- """);
- }
- }
-
- builder.AppendLine("""
-
-
- """);
- return builder.ToString();
- }
-
- public string CreateSectionSmil()
- {
- var builder = new StringBuilder($"""
-
-
-
- """);
-
- for (var i = 0; i < Elements.Count; i++)
- {
- if (Elements[i] is Paragraph para && para.Audio != null)
- {
- builder.AppendLine($"""
-
-
-
-
- """);
- }
- }
-
- builder.AppendLine("""
-
-
- """);
- return builder.ToString();
- }
-
public TimeSpan GetTotalTime()
{
var time = TimeSpan.Zero;
diff --git a/Epub/KoeBook.Epub/Services/EpubCreateService.cs b/Epub/KoeBook.Epub/Services/EpubCreateService.cs
index 02e4054..d47c018 100644
--- a/Epub/KoeBook.Epub/Services/EpubCreateService.cs
+++ b/Epub/KoeBook.Epub/Services/EpubCreateService.cs
@@ -63,13 +63,13 @@ public async ValueTask TryCreateEpubAsync(EpubDocument epubDocument, strin
var sectionXhtmlEntry = archive.CreateEntry($"OEBPS/{epubDocument.Chapters[i].Sections[j].Id}.xhtml");
using (var sectionXhtmlStream = new StreamWriter(sectionXhtmlEntry.Open()))
{
- await sectionXhtmlStream.WriteLineAsync(epubDocument.Chapters[i].Sections[j].CreateSectionXhtml()).ConfigureAwait(false);
+ await sectionXhtmlStream.WriteLineAsync(CreateSectionXhtml(epubDocument.Chapters[i].Sections[j])).ConfigureAwait(false);
await sectionXhtmlStream.FlushAsync(ct).ConfigureAwait(false);
}
var sectionSmilEntry = archive.CreateEntry($"OEBPS/{epubDocument.Chapters[i].Sections[j].Id}_audio.smil");
using (var sectionSmilStream = new StreamWriter(sectionSmilEntry.Open()))
{
- await sectionSmilStream.WriteLineAsync(epubDocument.Chapters[i].Sections[j].CreateSectionSmil()).ConfigureAwait(false);
+ await sectionSmilStream.WriteLineAsync(CreateSectionSmil(epubDocument.Chapters[i].Sections[j])).ConfigureAwait(false);
await sectionSmilStream.FlushAsync(ct).ConfigureAwait(false);
}
for (var k = 0; k < epubDocument.Chapters[i].Sections[j].Elements.Count; k++)
@@ -260,4 +260,71 @@ internal static string CreateContainerXml() => """
""";
+
+ internal static string CreateSectionXhtml(Section section)
+ {
+ var builder = new StringBuilder($"""
+
+
+
+
+ {section.Title}
+
+
+ """);
+
+ for (var i = 0; i < section.Elements.Count; i++)
+ {
+ if (section.Elements[i] is Paragraph para)
+ {
+ builder.AppendLine($"""
+
+ {para.Text}
+
+ """);
+ }
+ else if (section.Elements[i] is Picture pic && File.Exists(pic.PictureFilePath))
+ {
+ builder.AppendLine($"""
+
+
+ """);
+ }
+ }
+
+ builder.AppendLine("""
+
+
+ """);
+ return builder.ToString();
+ }
+
+ internal static string CreateSectionSmil(Section section)
+ {
+ var builder = new StringBuilder($"""
+
+
+
+ """);
+
+ for (var i = 0; i < section.Elements.Count; i++)
+ {
+ if (section.Elements[i] is Paragraph para && para.Audio != null)
+ {
+ builder.AppendLine($"""
+
+
+
+
+ """);
+ }
+ }
+
+ builder.AppendLine("""
+
+
+ """);
+ return builder.ToString();
+ }
}
From 4a7ea0f7ae6b1bcff5404cb04e1c2e4153be835b Mon Sep 17 00:00:00 2001
From: aiueo-1234 <130837816+aiueo-1234@users.noreply.github.com>
Date: Sun, 10 Mar 2024 18:27:14 +0900
Subject: [PATCH 29/45] =?UTF-8?q?StringBuilder=E3=81=AE=E4=B8=80=E6=9C=AC?=
=?UTF-8?q?=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/EpubCreateService.cs | 75 ++++++++++---------
1 file changed, 40 insertions(+), 35 deletions(-)
diff --git a/Epub/KoeBook.Epub/Services/EpubCreateService.cs b/Epub/KoeBook.Epub/Services/EpubCreateService.cs
index d47c018..53b5998 100644
--- a/Epub/KoeBook.Epub/Services/EpubCreateService.cs
+++ b/Epub/KoeBook.Epub/Services/EpubCreateService.cs
@@ -8,6 +8,8 @@ namespace KoeBook.Epub.Services;
public class EpubCreateService(IFileExtensionService fileExtensionService) : IEpubCreateService
{
private readonly IFileExtensionService _fileExtensionService = fileExtensionService;
+ private readonly StringBuilder _builder = new();
+
public async ValueTask TryCreateEpubAsync(EpubDocument epubDocument, string tmpDirectory, CancellationToken ct)
{
if (!File.Exists(epubDocument.CoverFilePath))
@@ -102,9 +104,10 @@ public async ValueTask TryCreateEpubAsync(EpubDocument epubDocument, strin
}
}
- internal static string CreateNavXhtml(EpubDocument epubDocument)
+ internal string CreateNavXhtml(EpubDocument epubDocument)
{
- var builder = new StringBuilder($"""
+ _builder.Clear();
+ _builder.AppendLine($"""
@@ -114,13 +117,13 @@ internal static string CreateNavXhtml(EpubDocument epubDocument)
-
""");
+
if (epubDocument.Chapters.Count == 1 && epubDocument.Chapters[0].Title == null)
{
for (var i = 0; i < epubDocument.Chapters[0].Sections.Count; i++)
{
- builder.AppendLine($"""
+ _builder.AppendLine($"""
{epubDocument.Chapters[0].Sections[i].Title}
@@ -131,47 +134,48 @@ internal static string CreateNavXhtml(EpubDocument epubDocument)
{
for (var i = 0; i < epubDocument.Chapters.Count; i++)
{
- builder.AppendLine($"""
+ _builder.AppendLine($"""
{epubDocument.Chapters[i].Title}
""");
for (var j = 0; j < epubDocument.Chapters[i].Sections.Count; j++)
{
- builder.AppendLine($"""
+ _builder.AppendLine($"""
{epubDocument.Chapters[i].Sections[j].Title}
""");
}
- builder.AppendLine($"""
+ _builder.AppendLine($"""
""");
}
}
- builder.AppendLine($"""
+ _builder.AppendLine($"""
""");
- return builder.ToString();
+ return _builder.ToString();
}
- internal static string CreateCssText(EpubDocument epubDocument)
+ internal string CreateCssText(EpubDocument epubDocument)
{
- var builder = new StringBuilder();
+ _builder.Clear();
foreach (var cssClass in epubDocument.CssClasses)
{
- builder.AppendLine(cssClass.Text);
+ _builder.AppendLine(cssClass.Text);
}
- return builder.ToString();
+ return _builder.ToString();
}
internal string CreateOpf(EpubDocument epubDocument)
{
- var builder = new StringBuilder($"""
+ _builder.Clear();
+ _builder.AppendLine($"""
{epubDocument.Title}
@@ -183,7 +187,6 @@ internal string CreateOpf(EpubDocument epubDocument)
{DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture)}
-epub-media-overlay-active
-epub-media-overlay-unactive
-
""");
var totalTime = TimeSpan.Zero;
@@ -193,12 +196,12 @@ internal string CreateOpf(EpubDocument epubDocument)
{
var time = epubDocument.Chapters[i].Sections[j].GetTotalTime();
totalTime += time;
- builder.AppendLine($"""
+ _builder.AppendLine($"""
{time}
""");
}
}
- builder.AppendLine($"""
+ _builder.AppendLine($"""
{totalTime}
@@ -211,7 +214,7 @@ internal string CreateOpf(EpubDocument epubDocument)
{
for (var j = 0; j < epubDocument.Chapters[i].Sections.Count; j++)
{
- builder.AppendLine($"""
+ _builder.AppendLine($"""
""");
@@ -220,17 +223,17 @@ internal string CreateOpf(EpubDocument epubDocument)
var element = epubDocument.Chapters[i].Sections[j].Elements[k];
if (element is Paragraph para && para.Audio != null)
{
- builder.AppendLine(@$" ");
+ _builder.AppendLine(@$" ");
}
else if (element is Picture pic && File.Exists(pic.PictureFilePath))
{
- builder.AppendLine(@$" ");
+ _builder.AppendLine(@$" ");
}
}
}
}
- builder.AppendLine($"""
+ _builder.AppendLine($"""
""");
@@ -239,17 +242,17 @@ internal string CreateOpf(EpubDocument epubDocument)
{
for (var j = 0; j < epubDocument.Chapters[i].Sections.Count; j++)
{
- builder.AppendLine($"""
+ _builder.AppendLine($"""
""");
}
}
- builder.AppendLine($"""
+ _builder.AppendLine($"""
""");
- return builder.ToString();
+ return _builder.ToString();
}
internal static string CreateContainerXml() => """
@@ -261,9 +264,10 @@ internal static string CreateContainerXml() => """
""";
- internal static string CreateSectionXhtml(Section section)
+ internal string CreateSectionXhtml(Section section)
{
- var builder = new StringBuilder($"""
+ _builder.Clear();
+ _builder.AppendLine($"""
@@ -277,7 +281,7 @@ internal static string CreateSectionXhtml(Section section)
{
if (section.Elements[i] is Paragraph para)
{
- builder.AppendLine($"""
+ _builder.AppendLine($"""
{para.Text}
@@ -285,7 +289,7 @@ internal static string CreateSectionXhtml(Section section)
}
else if (section.Elements[i] is Picture pic && File.Exists(pic.PictureFilePath))
{
- builder.AppendLine($"""
+ _builder.AppendLine($"""
@@ -293,16 +297,17 @@ internal static string CreateSectionXhtml(Section section)
}
}
- builder.AppendLine("""
+ _builder.AppendLine("""
""");
- return builder.ToString();
+ return _builder.ToString();
}
- internal static string CreateSectionSmil(Section section)
+ internal string CreateSectionSmil(Section section)
{
- var builder = new StringBuilder($"""
+ _builder.Clear();
+ _builder.AppendLine($"""
@@ -312,7 +317,7 @@ internal static string CreateSectionSmil(Section section)
{
if (section.Elements[i] is Paragraph para && para.Audio != null)
{
- builder.AppendLine($"""
+ _builder.AppendLine($"""
@@ -321,10 +326,10 @@ internal static string CreateSectionSmil(Section section)
}
}
- builder.AppendLine("""
+ _builder.AppendLine("""
""");
- return builder.ToString();
+ return _builder.ToString();
}
}
From 409d868fc7ed96bc60bae16c0f0e454cce5b1a20 Mon Sep 17 00:00:00 2001
From: aiueo-1234 <130837816+aiueo-1234@users.noreply.github.com>
Date: Sun, 10 Mar 2024 19:36:19 +0900
Subject: [PATCH 30/45] =?UTF-8?q?CreateContainerXml=E3=81=AE=E5=A4=89?=
=?UTF-8?q?=E6=9B=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/EpubCreateService.cs | 20 +++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/Epub/KoeBook.Epub/Services/EpubCreateService.cs b/Epub/KoeBook.Epub/Services/EpubCreateService.cs
index 53b5998..f96cac2 100644
--- a/Epub/KoeBook.Epub/Services/EpubCreateService.cs
+++ b/Epub/KoeBook.Epub/Services/EpubCreateService.cs
@@ -10,6 +10,15 @@ public class EpubCreateService(IFileExtensionService fileExtensionService) : IEp
private readonly IFileExtensionService _fileExtensionService = fileExtensionService;
private readonly StringBuilder _builder = new();
+ internal const string ContainerXml = """
+
+
+
+
+
+
+ """;
+
public async ValueTask TryCreateEpubAsync(EpubDocument epubDocument, string tmpDirectory, CancellationToken ct)
{
if (!File.Exists(epubDocument.CoverFilePath))
@@ -31,7 +40,7 @@ public async ValueTask TryCreateEpubAsync(EpubDocument epubDocument, strin
var containerEntry = archive.CreateEntry("META-INF/container.xml");
using (var containerStream = new StreamWriter(containerEntry.Open()))
{
- await containerStream.WriteLineAsync(CreateContainerXml()).ConfigureAwait(false);
+ await containerStream.WriteLineAsync(ContainerXml).ConfigureAwait(false);
await containerStream.FlushAsync(ct).ConfigureAwait(false);
}
@@ -255,15 +264,6 @@ internal string CreateOpf(EpubDocument epubDocument)
return _builder.ToString();
}
- internal static string CreateContainerXml() => """
-
-
-
-
-
-
- """;
-
internal string CreateSectionXhtml(Section section)
{
_builder.Clear();
From abd0a66946325b78878d64044f0bb0f1e582986d Mon Sep 17 00:00:00 2001
From: aiueo-1234 <130837816+aiueo-1234@users.noreply.github.com>
Date: Sun, 10 Mar 2024 19:52:27 +0900
Subject: [PATCH 31/45] =?UTF-8?q?revert=20StringBuilder=E3=81=AE=E4=B8=80?=
=?UTF-8?q?=E6=9C=AC=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Services/EpubCreateService.cs | 75 +++++++++----------
1 file changed, 36 insertions(+), 39 deletions(-)
diff --git a/Epub/KoeBook.Epub/Services/EpubCreateService.cs b/Epub/KoeBook.Epub/Services/EpubCreateService.cs
index f96cac2..b34d590 100644
--- a/Epub/KoeBook.Epub/Services/EpubCreateService.cs
+++ b/Epub/KoeBook.Epub/Services/EpubCreateService.cs
@@ -8,7 +8,6 @@ namespace KoeBook.Epub.Services;
public class EpubCreateService(IFileExtensionService fileExtensionService) : IEpubCreateService
{
private readonly IFileExtensionService _fileExtensionService = fileExtensionService;
- private readonly StringBuilder _builder = new();
internal const string ContainerXml = """
@@ -113,10 +112,9 @@ public async ValueTask TryCreateEpubAsync(EpubDocument epubDocument, strin
}
}
- internal string CreateNavXhtml(EpubDocument epubDocument)
+ internal static string CreateNavXhtml(EpubDocument epubDocument)
{
- _builder.Clear();
- _builder.AppendLine($"""
+ var builder = new StringBuilder($"""
@@ -126,13 +124,13 @@ internal string CreateNavXhtml(EpubDocument epubDocument)
- """);
+ """);
if (epubDocument.Chapters.Count == 1 && epubDocument.Chapters[0].Title == null)
{
for (var i = 0; i < epubDocument.Chapters[0].Sections.Count; i++)
{
- _builder.AppendLine($"""
+ builder.AppendLine($"""
{epubDocument.Chapters[0].Sections[i].Title}
@@ -143,48 +141,47 @@ internal string CreateNavXhtml(EpubDocument epubDocument)
{
for (var i = 0; i < epubDocument.Chapters.Count; i++)
{
- _builder.AppendLine($"""
+ builder.AppendLine($"""
{epubDocument.Chapters[i].Title}
""");
for (var j = 0; j < epubDocument.Chapters[i].Sections.Count; j++)
{
- _builder.AppendLine($"""
+ builder.AppendLine($"""
{epubDocument.Chapters[i].Sections[j].Title}
""");
}
- _builder.AppendLine($"""
+ builder.AppendLine($"""
""");
}
}
- _builder.AppendLine($"""
+ builder.AppendLine($"""
""");
- return _builder.ToString();
+ return builder.ToString();
}
- internal string CreateCssText(EpubDocument epubDocument)
+ internal static string CreateCssText(EpubDocument epubDocument)
{
- _builder.Clear();
+ var builder = new StringBuilder();
foreach (var cssClass in epubDocument.CssClasses)
{
- _builder.AppendLine(cssClass.Text);
+ builder.AppendLine(cssClass.Text);
}
- return _builder.ToString();
+ return builder.ToString();
}
internal string CreateOpf(EpubDocument epubDocument)
{
- _builder.Clear();
- _builder.AppendLine($"""
+ var builder = new StringBuilder($"""
{epubDocument.Title}
@@ -196,6 +193,7 @@ internal string CreateOpf(EpubDocument epubDocument)
{DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ", CultureInfo.InvariantCulture)}
-epub-media-overlay-active
-epub-media-overlay-unactive
+
""");
var totalTime = TimeSpan.Zero;
@@ -205,12 +203,12 @@ internal string CreateOpf(EpubDocument epubDocument)
{
var time = epubDocument.Chapters[i].Sections[j].GetTotalTime();
totalTime += time;
- _builder.AppendLine($"""
+ builder.AppendLine($"""
{time}
""");
}
}
- _builder.AppendLine($"""
+ builder.AppendLine($"""
{totalTime}
@@ -223,7 +221,7 @@ internal string CreateOpf(EpubDocument epubDocument)
{
for (var j = 0; j < epubDocument.Chapters[i].Sections.Count; j++)
{
- _builder.AppendLine($"""
+ builder.AppendLine($"""
""");
@@ -232,17 +230,17 @@ internal string CreateOpf(EpubDocument epubDocument)
var element = epubDocument.Chapters[i].Sections[j].Elements[k];
if (element is Paragraph para && para.Audio != null)
{
- _builder.AppendLine(@$" ");
+ builder.AppendLine(@$" ");
}
else if (element is Picture pic && File.Exists(pic.PictureFilePath))
{
- _builder.AppendLine(@$" ");
+ builder.AppendLine(@$" ");
}
}
}
}
- _builder.AppendLine($"""
+ builder.AppendLine($"""
""");
@@ -251,23 +249,23 @@ internal string CreateOpf(EpubDocument epubDocument)
{
for (var j = 0; j < epubDocument.Chapters[i].Sections.Count; j++)
{
- _builder.AppendLine($"""
+ builder.AppendLine($"""
""");
}
}
- _builder.AppendLine($"""
+ builder.AppendLine($"""
""");
- return _builder.ToString();
+ return builder.ToString();
}
- internal string CreateSectionXhtml(Section section)
+
+ internal static string CreateSectionXhtml(Section section)
{
- _builder.Clear();
- _builder.AppendLine($"""
+ var builder = new StringBuilder($"""
@@ -281,7 +279,7 @@ internal string CreateSectionXhtml(Section section)
{
if (section.Elements[i] is Paragraph para)
{
- _builder.AppendLine($"""
+ builder.AppendLine($"""
{para.Text}
@@ -289,7 +287,7 @@ internal string CreateSectionXhtml(Section section)
}
else if (section.Elements[i] is Picture pic && File.Exists(pic.PictureFilePath))
{
- _builder.AppendLine($"""
+ builder.AppendLine($"""
@@ -297,17 +295,16 @@ internal string CreateSectionXhtml(Section section)
}
}
- _builder.AppendLine("""
+ builder.AppendLine("""
""");
- return _builder.ToString();
+ return builder.ToString();
}
- internal string CreateSectionSmil(Section section)
+ internal static string CreateSectionSmil(Section section)
{
- _builder.Clear();
- _builder.AppendLine($"""
+ var builder = new StringBuilder($"""
@@ -317,7 +314,7 @@ internal string CreateSectionSmil(Section section)
{
if (section.Elements[i] is Paragraph para && para.Audio != null)
{
- _builder.AppendLine($"""
+ builder.AppendLine($"""
@@ -326,10 +323,10 @@ internal string CreateSectionSmil(Section section)
}
}
- _builder.AppendLine("""
+ builder.AppendLine("""
""");
- return _builder.ToString();
+ return builder.ToString();
}
}
From a56c8bbcf2140c041ae3529f883f432c644204a6 Mon Sep 17 00:00:00 2001
From: miyaji255 <84168445+miyaji255@users.noreply.github.com>
Date: Mon, 11 Mar 2024 22:05:55 +0900
Subject: [PATCH 32/45] =?UTF-8?q?#15=20=E3=83=97=E3=83=AD=E3=82=B8?=
=?UTF-8?q?=E3=82=A7=E3=82=AF=E3=83=88=E3=81=AE=E4=BE=9D=E5=AD=98=E9=96=A2?=
=?UTF-8?q?=E4=BF=82=E3=82=92=E5=A4=89=E6=9B=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Contracts/Services/IEpubDocumentStoreService.cs | 2 +-
Epub/KoeBook.Epub/KoeBook.Epub.csproj | 6 +++++-
Epub/KoeBook.Epub/Models/Paragraph.cs | 7 +++++--
.../Services/AnalyzerService _CoverFileBytes.cs | 2 +-
.../KoeBook.Epub}/Services/AnalyzerService.cs | 7 +++++--
.../Services/EpubDocumentStoreService.cs | 4 ++--
.../KoeBook.Epub}/Services/EpubGenerateService.cs | 7 ++++---
KoeBook.Core/KoeBook.Core.csproj | 7 ++-----
{Epub/KoeBook.Epub => KoeBook.Core}/Models/Audio.cs | 0
KoeBook.Core/Models/ScriptLine.cs | 13 ++++++++-----
KoeBook/Services/CoreMocks/AnalyzerServiceMock.cs | 6 +++---
11 files changed, 36 insertions(+), 25 deletions(-)
rename {KoeBook.Core => Epub/KoeBook.Epub}/Contracts/Services/IEpubDocumentStoreService.cs (84%)
rename {KoeBook.Core => Epub/KoeBook.Epub}/Services/AnalyzerService _CoverFileBytes.cs (99%)
rename {KoeBook.Core => Epub/KoeBook.Epub}/Services/AnalyzerService.cs (94%)
rename {KoeBook.Core => Epub/KoeBook.Epub}/Services/EpubDocumentStoreService.cs (93%)
rename {KoeBook.Core => Epub/KoeBook.Epub}/Services/EpubGenerateService.cs (85%)
rename {Epub/KoeBook.Epub => KoeBook.Core}/Models/Audio.cs (100%)
diff --git a/KoeBook.Core/Contracts/Services/IEpubDocumentStoreService.cs b/Epub/KoeBook.Epub/Contracts/Services/IEpubDocumentStoreService.cs
similarity index 84%
rename from KoeBook.Core/Contracts/Services/IEpubDocumentStoreService.cs
rename to Epub/KoeBook.Epub/Contracts/Services/IEpubDocumentStoreService.cs
index 8ba00b9..187e9a4 100644
--- a/KoeBook.Core/Contracts/Services/IEpubDocumentStoreService.cs
+++ b/Epub/KoeBook.Epub/Contracts/Services/IEpubDocumentStoreService.cs
@@ -1,6 +1,6 @@
using KoeBook.Epub.Models;
-namespace KoeBook.Core.Contracts.Services;
+namespace KoeBook.Epub.Contracts.Services;
public interface IEpubDocumentStoreService
{
diff --git a/Epub/KoeBook.Epub/KoeBook.Epub.csproj b/Epub/KoeBook.Epub/KoeBook.Epub.csproj
index 8f3071f..2241bce 100644
--- a/Epub/KoeBook.Epub/KoeBook.Epub.csproj
+++ b/Epub/KoeBook.Epub/KoeBook.Epub.csproj
@@ -1,4 +1,4 @@
-
+
net8.0
@@ -11,5 +11,9 @@
+
+
+
+
diff --git a/Epub/KoeBook.Epub/Models/Paragraph.cs b/Epub/KoeBook.Epub/Models/Paragraph.cs
index ea1956c..9faffe9 100644
--- a/Epub/KoeBook.Epub/Models/Paragraph.cs
+++ b/Epub/KoeBook.Epub/Models/Paragraph.cs
@@ -1,7 +1,10 @@
-namespace KoeBook.Epub.Models;
+using KoeBook.Core.Models;
+
+namespace KoeBook.Epub.Models;
public sealed class Paragraph : Element
{
- public Audio? Audio { get; set; }
+ public ScriptLine? ScriptLine { get; set; }
+ public Audio? Audio => ScriptLine?.Audio;
public string? Text { get; set; }
}
diff --git a/KoeBook.Core/Services/AnalyzerService _CoverFileBytes.cs b/Epub/KoeBook.Epub/Services/AnalyzerService _CoverFileBytes.cs
similarity index 99%
rename from KoeBook.Core/Services/AnalyzerService _CoverFileBytes.cs
rename to Epub/KoeBook.Epub/Services/AnalyzerService _CoverFileBytes.cs
index 97c30e8..6e0673c 100644
--- a/KoeBook.Core/Services/AnalyzerService _CoverFileBytes.cs
+++ b/Epub/KoeBook.Epub/Services/AnalyzerService _CoverFileBytes.cs
@@ -5,7 +5,7 @@
using KoeBook.Epub;
using KoeBook.Epub.Services;
-namespace KoeBook.Core.Services;
+namespace KoeBook.Epub.Services;
public partial class AnalyzerService
{
diff --git a/KoeBook.Core/Services/AnalyzerService.cs b/Epub/KoeBook.Epub/Services/AnalyzerService.cs
similarity index 94%
rename from KoeBook.Core/Services/AnalyzerService.cs
rename to Epub/KoeBook.Epub/Services/AnalyzerService.cs
index 59b72a6..b8fa5cb 100644
--- a/KoeBook.Core/Services/AnalyzerService.cs
+++ b/Epub/KoeBook.Epub/Services/AnalyzerService.cs
@@ -1,11 +1,12 @@
using System.Text;
using System.Text.RegularExpressions;
+using KoeBook.Core;
using KoeBook.Core.Contracts.Services;
using KoeBook.Core.Models;
using KoeBook.Epub.Contracts.Services;
using KoeBook.Epub.Models;
-namespace KoeBook.Core.Services;
+namespace KoeBook.Epub.Services;
public partial class AnalyzerService(IScraperSelectorService scrapingService, IEpubDocumentStoreService epubDocumentStoreService, ILlmAnalyzerService llmAnalyzerService) : IAnalyzerService
{
@@ -56,7 +57,9 @@ public async ValueTask AnalyzeAsync(BookProperties bookProperties,
// ルビを置換
line = ReplaceBaseTextWithRuby(line, rubyDict);
- scriptLines.Add(new ScriptLine(paragraph, line, "", ""));
+ var scriptLine = new ScriptLine(line, "", "");
+ paragraph.ScriptLine = scriptLine;
+ scriptLines.Add(scriptLine);
}
}
}
diff --git a/KoeBook.Core/Services/EpubDocumentStoreService.cs b/Epub/KoeBook.Epub/Services/EpubDocumentStoreService.cs
similarity index 93%
rename from KoeBook.Core/Services/EpubDocumentStoreService.cs
rename to Epub/KoeBook.Epub/Services/EpubDocumentStoreService.cs
index 4c51415..0ef2725 100644
--- a/KoeBook.Core/Services/EpubDocumentStoreService.cs
+++ b/Epub/KoeBook.Epub/Services/EpubDocumentStoreService.cs
@@ -1,8 +1,8 @@
using System.Threading.Tasks;
-using KoeBook.Core.Contracts.Services;
+using KoeBook.Epub.Contracts.Services;
using KoeBook.Epub.Models;
-namespace KoeBook.Core.Services;
+namespace KoeBook.Epub.Services;
public class EpubDocumentStoreService : IEpubDocumentStoreService
{
diff --git a/KoeBook.Core/Services/EpubGenerateService.cs b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs
similarity index 85%
rename from KoeBook.Core/Services/EpubGenerateService.cs
rename to Epub/KoeBook.Epub/Services/EpubGenerateService.cs
index 2810e8d..058795d 100644
--- a/KoeBook.Core/Services/EpubGenerateService.cs
+++ b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs
@@ -1,10 +1,11 @@
-using KoeBook.Core.Contracts.Services;
+using KoeBook.Core;
+using KoeBook.Core.Contracts.Services;
using KoeBook.Core.Models;
using KoeBook.Epub;
using KoeBook.Epub.Contracts.Services;
using KoeBook.Epub.Models;
-namespace KoeBook.Core.Services;
+namespace KoeBook.Epub.Services;
public class EpubGenerateService(ISoundGenerationService soundGenerationService, IEpubDocumentStoreService epubDocumentStoreService, IEpubCreateService epubCreateService) : IEpubGenerateService
{
@@ -21,7 +22,7 @@ public async ValueTask GenerateEpubAsync(BookScripts bookScripts, string
foreach (var scriptLine in bookScripts.ScriptLines)
{
- scriptLine.Paragraph.Audio = new Audio(await _soundGenerationService.GenerateLineSoundAsync(scriptLine, bookScripts.Options, cancellationToken).ConfigureAwait(false));
+ scriptLine.Audio = new Audio(await _soundGenerationService.GenerateLineSoundAsync(scriptLine, bookScripts.Options, cancellationToken).ConfigureAwait(false));
}
if (await _createService.TryCreateEpubAsync(document, tempDirectory, cancellationToken).ConfigureAwait(false))
diff --git a/KoeBook.Core/KoeBook.Core.csproj b/KoeBook.Core/KoeBook.Core.csproj
index 92b37e0..3963f59 100644
--- a/KoeBook.Core/KoeBook.Core.csproj
+++ b/KoeBook.Core/KoeBook.Core.csproj
@@ -1,4 +1,4 @@
-
+
net8.0
KoeBook.Core
@@ -11,10 +11,7 @@
+
-
-
-
-
diff --git a/Epub/KoeBook.Epub/Models/Audio.cs b/KoeBook.Core/Models/Audio.cs
similarity index 100%
rename from Epub/KoeBook.Epub/Models/Audio.cs
rename to KoeBook.Core/Models/Audio.cs
diff --git a/KoeBook.Core/Models/ScriptLine.cs b/KoeBook.Core/Models/ScriptLine.cs
index 7f7cbec..3fcb5e4 100644
--- a/KoeBook.Core/Models/ScriptLine.cs
+++ b/KoeBook.Core/Models/ScriptLine.cs
@@ -5,12 +5,15 @@ namespace KoeBook.Core.Models;
///
/// 読み上げ1行分
///
-public class ScriptLine(Paragraph paragraph, string text, string character, string style)
+//public class ScriptLine(Paragraph paragraph, string text, string character, string style)
+//{
+// ///
+// /// 読み上げ位置との関連付け
+// ///
+// public Paragraph Paragraph { get; } = paragraph;
+public class ScriptLine(string text, string character, string style)
{
- ///
- /// 読み上げ位置との関連付け
- ///
- public Paragraph Paragraph { get; } = paragraph;
+ public Audio? Audio { get; set; }
///
/// 読み上げテキスト
diff --git a/KoeBook/Services/CoreMocks/AnalyzerServiceMock.cs b/KoeBook/Services/CoreMocks/AnalyzerServiceMock.cs
index 6e6432f..04468bf 100644
--- a/KoeBook/Services/CoreMocks/AnalyzerServiceMock.cs
+++ b/KoeBook/Services/CoreMocks/AnalyzerServiceMock.cs
@@ -40,9 +40,9 @@ public async ValueTask AnalyzeAsync(BookProperties bookProperties,
return new(bookProperties, new(characterMapping))
{
ScriptLines = [
- new(new Paragraph { Text = "a" }, "読み上げテキスト1", "Hoge", "Angry"),
- new(new Paragraph { Text = "b" }, "読み上げテキスト2", "Fuga", "Sad"),
- new(new Paragraph { Text = "c" }, "読み上げテキスト3", "Narration", "Narration"),
+ new("読み上げテキスト1", "Hoge", "Angry"),
+ new("読み上げテキスト2", "Fuga", "Sad"),
+ new("読み上げテキスト3", "Narration", "Narration"),
],
};
}
From 67e01a1254655c0e9e5618552f3172fe41eb161d Mon Sep 17 00:00:00 2001
From: aiueo-1234 <130837816+aiueo-1234@users.noreply.github.com>
Date: Fri, 15 Mar 2024 17:24:35 +0900
Subject: [PATCH 33/45] =?UTF-8?q?#17-1=20Core=E3=81=AE=E3=83=97=E3=83=AD?=
=?UTF-8?q?=E3=82=B8=E3=82=A7=E3=82=AF=E3=83=88=E3=82=92Epub=E3=82=BD?=
=?UTF-8?q?=E3=83=AA=E3=83=A5=E3=83=BC=E3=82=B7=E3=83=A7=E3=83=B3=E3=81=AB?=
=?UTF-8?q?=E8=BF=BD=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Epub/KoeBook.Epub.sln | 51 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 50 insertions(+), 1 deletion(-)
diff --git a/Epub/KoeBook.Epub.sln b/Epub/KoeBook.Epub.sln
index dc90218..732b485 100644
--- a/Epub/KoeBook.Epub.sln
+++ b/Epub/KoeBook.Epub.sln
@@ -1,4 +1,5 @@
-Microsoft Visual Studio Solution File, Format Version 12.00
+
+Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.10.34607.79
MinimumVisualStudioVersion = 10.0.40219.1
@@ -6,20 +7,68 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KoeBook.Epub", "KoeBook.Epu
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EpubConsoleApp", "EpubConsoleApp\EpubConsoleApp.csproj", "{DE1F3CE9-4F3B-4428-9293-D18446F333D8}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "KoeBook.Core", "..\KoeBook.Core\KoeBook.Core.csproj", "{9F11B1EF-8330-400E-A60C-CFC98E827AA7}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
+ Debug|arm64 = Debug|arm64
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
+ Release|arm64 = Release|arm64
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Debug|arm64.ActiveCfg = Debug|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Debug|arm64.Build.0 = Debug|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Debug|x64.Build.0 = Debug|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Debug|x86.Build.0 = Debug|Any CPU
{E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Release|arm64.ActiveCfg = Release|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Release|arm64.Build.0 = Release|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Release|x64.ActiveCfg = Release|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Release|x64.Build.0 = Release|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Release|x86.ActiveCfg = Release|Any CPU
+ {E8E224F2-D1E9-437E-8222-FF2F33DB3FCD}.Release|x86.Build.0 = Release|Any CPU
{DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Debug|arm64.ActiveCfg = Debug|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Debug|arm64.Build.0 = Debug|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Debug|x64.Build.0 = Debug|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Debug|x86.Build.0 = Debug|Any CPU
{DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Release|Any CPU.Build.0 = Release|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Release|arm64.ActiveCfg = Release|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Release|arm64.Build.0 = Release|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Release|x64.ActiveCfg = Release|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Release|x64.Build.0 = Release|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Release|x86.ActiveCfg = Release|Any CPU
+ {DE1F3CE9-4F3B-4428-9293-D18446F333D8}.Release|x86.Build.0 = Release|Any CPU
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Debug|arm64.ActiveCfg = Debug|arm64
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Debug|arm64.Build.0 = Debug|arm64
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Debug|x64.ActiveCfg = Debug|x64
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Debug|x64.Build.0 = Debug|x64
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Debug|x86.ActiveCfg = Debug|x86
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Debug|x86.Build.0 = Debug|x86
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Release|Any CPU.Build.0 = Release|Any CPU
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Release|arm64.ActiveCfg = Release|arm64
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Release|arm64.Build.0 = Release|arm64
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Release|x64.ActiveCfg = Release|x64
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Release|x64.Build.0 = Release|x64
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Release|x86.ActiveCfg = Release|x86
+ {9F11B1EF-8330-400E-A60C-CFC98E827AA7}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
From bca75d9e465cc3713143cbc3ba846f184d6fa306 Mon Sep 17 00:00:00 2001
From: aiueo-1234 <130837816+aiueo-1234@users.noreply.github.com>
Date: Fri, 15 Mar 2024 18:55:37 +0900
Subject: [PATCH 34/45] =?UTF-8?q?#17-1=20Epub=E4=BD=9C=E6=88=90=E9=83=A8?=
=?UTF-8?q?=E5=88=86=E3=81=AEException=E8=AA=BF=E6=95=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Epub/KoeBook.Epub/Services/EpubGenerateService.cs | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/Epub/KoeBook.Epub/Services/EpubGenerateService.cs b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs
index 058795d..513b89e 100644
--- a/Epub/KoeBook.Epub/Services/EpubGenerateService.cs
+++ b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs
@@ -9,10 +9,10 @@ namespace KoeBook.Epub.Services;
public class EpubGenerateService(ISoundGenerationService soundGenerationService, IEpubDocumentStoreService epubDocumentStoreService, IEpubCreateService epubCreateService) : IEpubGenerateService
{
- private ISoundGenerationService _soundGenerationService = soundGenerationService;
- private IEpubDocumentStoreService _documentStoreService = epubDocumentStoreService;
- private IEpubCreateService _createService = epubCreateService;
-
+ private readonly ISoundGenerationService _soundGenerationService = soundGenerationService;
+ private readonly IEpubDocumentStoreService _documentStoreService = epubDocumentStoreService;
+ private readonly IEpubCreateService _createService = epubCreateService;
+
public async ValueTask GenerateEpubAsync(BookScripts bookScripts, string tempDirectory, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -32,7 +32,8 @@ public async ValueTask GenerateEpubAsync(BookScripts bookScripts, string
}
else
{
- throw new EbookException(ExceptionType.EpubCreateError);
+ EbookException.Throw(ExceptionType.EpubCreateError);
+ return "";
}
}
}
From 8f2900eeb357170de49ef02ef020171700adab21 Mon Sep 17 00:00:00 2001
From: aiueo-1234 <130837816+aiueo-1234@users.noreply.github.com>
Date: Fri, 15 Mar 2024 18:56:50 +0900
Subject: [PATCH 35/45] =?UTF-8?q?=E3=83=95=E3=82=A9=E3=83=BC=E3=83=9E?=
=?UTF-8?q?=E3=83=83=E3=83=88?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Epub/KoeBook.Epub/Services/EpubGenerateService.cs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Epub/KoeBook.Epub/Services/EpubGenerateService.cs b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs
index 513b89e..c43dc74 100644
--- a/Epub/KoeBook.Epub/Services/EpubGenerateService.cs
+++ b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs
@@ -12,7 +12,7 @@ public class EpubGenerateService(ISoundGenerationService soundGenerationService,
private readonly ISoundGenerationService _soundGenerationService = soundGenerationService;
private readonly IEpubDocumentStoreService _documentStoreService = epubDocumentStoreService;
private readonly IEpubCreateService _createService = epubCreateService;
-
+
public async ValueTask GenerateEpubAsync(BookScripts bookScripts, string tempDirectory, CancellationToken cancellationToken)
{
cancellationToken.ThrowIfCancellationRequested();
From fa3f28ce4097fcdfa32ee427117799b0219823ed Mon Sep 17 00:00:00 2001
From: aiueo-1234 <130837816+aiueo-1234@users.noreply.github.com>
Date: Fri, 15 Mar 2024 22:05:10 +0900
Subject: [PATCH 36/45] =?UTF-8?q?#17-1=20DI=E8=BF=BD=E5=8A=A0&throw=20exce?=
=?UTF-8?q?ption=E3=81=AB=E5=A4=89=E6=9B=B4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Epub/KoeBook.Epub/Services/EpubGenerateService.cs | 3 +--
KoeBook/App.xaml.cs | 1 +
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Epub/KoeBook.Epub/Services/EpubGenerateService.cs b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs
index c43dc74..1543f30 100644
--- a/Epub/KoeBook.Epub/Services/EpubGenerateService.cs
+++ b/Epub/KoeBook.Epub/Services/EpubGenerateService.cs
@@ -32,8 +32,7 @@ public async ValueTask GenerateEpubAsync(BookScripts bookScripts, string
}
else
{
- EbookException.Throw(ExceptionType.EpubCreateError);
- return "";
+ throw new EbookException(ExceptionType.EpubCreateError);
}
}
}
diff --git a/KoeBook/App.xaml.cs b/KoeBook/App.xaml.cs
index 3b1e62f..0ed636f 100644
--- a/KoeBook/App.xaml.cs
+++ b/KoeBook/App.xaml.cs
@@ -103,6 +103,7 @@ public App()
.AddSingleton()
.AddSingleton();
services.AddSingleton