Initial implementation of voice works scanning.

This commit is contained in:
2025-09-11 00:07:49 -04:00
parent f250276a99
commit 3c0a39b324
50 changed files with 1351 additions and 88 deletions

View File

@@ -0,0 +1,25 @@
namespace JSMR.Application.Scanning.Contracts;
public class DLSiteWork
{
public DLSiteWorkType WorkType { get; set; }
public DLSiteWorkCategory Category { get; set; }
public string? ProductName { get; set; }
public string? ProductUrl { get; set; }
public string? ProductId { get; set; }
public DateOnly? AnnouncedDate { get; set; }
public DateTime? ExpectedDate { get; set; }
public DateTime? SalesDate { get; set; }
public int? Downloads { get; set; }
public byte? StarRating { get; set; }
public int? Votes { get; set; }
public string? Maker { get; set; }
public string? MakerId { get; set; }
public string? Description { get; set; }
public ICollection<string> Genres { get; set; } = [];
public ICollection<string> Tags { get; set; } = [];
public ICollection<string> Creators { get; set; } = [];
public string? ImageUrl { get; set; }
public string? SmallImageUrl { get; set; }
public string? Type { get; set; }
}

View File

@@ -0,0 +1,13 @@
namespace JSMR.Application.Scanning.Contracts;
public enum DLSiteWorkCategory
{
Unknown,
VoiceASMR,
Manga,
RPG,
Video,
Adventure,
Simulation,
CG
}

View File

@@ -0,0 +1,7 @@
namespace JSMR.Application.Scanning.Contracts;
public enum DLSiteWorkType
{
Released,
Announced
}

View File

@@ -0,0 +1,8 @@
using JSMR.Application.Scanning.Contracts;
namespace JSMR.Application.Scanning.Ports;
public interface IVoiceWorksScanner
{
Task<IReadOnlyList<DLSiteWork>> ScanPageAsync(ScanVoiceWorksRequest request, CancellationToken cancellationToken = default);
}

View File

@@ -0,0 +1,26 @@
using JSMR.Application.Scanning.Ports;
namespace JSMR.Application.Scanning;
public sealed class ScanVoiceWorksHandler(IVoiceWorksScanner scanner)
{
//public async Task<ScanVoiceWorksResponse> HandleAsync(ScanVoiceWorksRequest request, CancellationToken cancellationToken)
//{
// var works = await scanner.ScanPageAsync(request, cancellationToken);
// if (works.Count == 0)
// return new ScanVoiceWorksResponse();
// var ingests = works.Select(VoiceWorkIngest.From).ToList();
// var upsert = await _writer.UpsertAsync(ingests, ct);
// // only update search text for affected rows
// await _search.UpdateAsync(upsert.AffectedVoiceWorkIds, ct);
// return new ScanVoiceWorksResponse
// {
// Inserted = upsert.Inserted,
// Updated = upsert.Updated
// };
//}
}

View File

@@ -0,0 +1,5 @@
using JSMR.Application.Common;
namespace JSMR.Application.Scanning;
public sealed record ScanVoiceWorksRequest(int PageNumber, int PageSize, Locale Locale);

View File

@@ -0,0 +1,7 @@
namespace JSMR.Application.Scanning;
public sealed class ScanVoiceWorksResponse
{
public int Inserted { get; init; }
public int Updated { get; init; }
}

View File

@@ -0,0 +1,11 @@
using JSMR.Application.VoiceWorks.Ports;
namespace JSMR.Application.VoiceWorks.Commands.SetFavorite;
public sealed class SetVoiceWorkFavoriteHandler(IVoiceWorkWriter writer)
{
public async Task<SetVoiceWorkFavoriteResponse> HandleAsync(SetVoiceWorkFavoriteRequest request, CancellationToken cancellationToken = default)
{
return await writer.SetFavoriteAsync(request, cancellationToken);
}
}

View File

@@ -0,0 +1,3 @@
namespace JSMR.Application.VoiceWorks.Commands.SetFavorite;
public sealed record SetVoiceWorkFavoriteRequest(int VoiceWorkId, bool IsFavorite);

View File

@@ -0,0 +1,3 @@
namespace JSMR.Application.VoiceWorks.Commands.SetFavorite;
public sealed record SetVoiceWorkFavoriteResponse(int VoiceWorkId, bool IsFavorite);

View File

@@ -0,0 +1,8 @@
using JSMR.Application.VoiceWorks.Commands.SetFavorite;
namespace JSMR.Application.VoiceWorks.Ports;
public interface IVoiceWorkWriter
{
Task<SetVoiceWorkFavoriteResponse> SetFavoriteAsync(SetVoiceWorkFavoriteRequest request, CancellationToken cancellationToken);
}