Skip to content

Commit

Permalink
feat: update exporting service to use formatting service
Browse files Browse the repository at this point in the history
  • Loading branch information
Thundernerd committed Feb 22, 2024
1 parent c1d3128 commit 88e2e5c
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/Mangarr.Stack/Exporting/ExportService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Mangarr.Stack.Archival;
using Mangarr.Stack.Database.Documents;
using Mangarr.Stack.Database.Repositories;
using Mangarr.Stack.Formatting;
using RequestedChapterDocument = Mangarr.Stack.Database.Documents.RequestedChapterDocument;
using RequestedMangaDocument = Mangarr.Stack.Database.Documents.RequestedMangaDocument;

Expand All @@ -12,12 +13,18 @@ namespace Mangarr.Stack.Exporting;
public class ExportService
{
private readonly AniListApi _aniListApi;
private readonly FormattingService _formattingService;
private readonly RootFolderRepository _rootFolderRepository;

public ExportService(AniListApi aniListApi, RootFolderRepository rootFolderRepository)
public ExportService(
AniListApi aniListApi,
RootFolderRepository rootFolderRepository,
FormattingService formattingService
)
{
_aniListApi = aniListApi;
_rootFolderRepository = rootFolderRepository;
_formattingService = formattingService;
}

public async Task<Result> Export(
Expand All @@ -35,10 +42,13 @@ Archive archive
return Result.Fail("Root folder missing");
}

string mangaTitle = _aniListApi.GetPreferredTitle(requestedMangaDocument);
string chapterTitle = requestedChapterDocument.ChapterNumber.ToString(CultureInfo.InvariantCulture);
string archiveName = $"{mangaTitle} - {chapterTitle}.cbz"; // TODO: Support archive extension
string archiveDirectory = Path.Combine(rootFolderDocument.Path, mangaTitle);
string archiveDirectory = Path.Combine(rootFolderDocument.Path,
_formattingService.FormatDirectory(requestedMangaDocument));

// TODO: Support archive extension
string archiveName = _formattingService.FormatFilename(
requestedMangaDocument,
requestedChapterDocument) + ".cbz";

if (!Directory.Exists(archiveDirectory))
{
Expand Down

0 comments on commit 88e2e5c

Please sign in to comment.