Files
jsmr/JSMR.Application/Scanning/Contracts/VoiceWorkIngest.cs

60 lines
2.5 KiB
C#

using JSMR.Application.Integrations.DLSite.Models;
using JSMR.Domain.Enums;
using JSMR.Domain.ValueObjects;
namespace JSMR.Application.Scanning.Contracts;
public sealed record VoiceWorkIngest
{
public required string MakerId { get; init; }
public required string MakerName { get; init; }
public required string ProductId { get; init; }
public required string Title { get; init; }
public required string Description { get; init; }
public ICollection<string> Tags { get; init; } = [];
public ICollection<string> Creators { get; init; } = [];
public int WishlistCount { get; init; }
public int Downloads { get; init; }
public bool HasTrial { get; init; }
public bool HasDLPlay { get; init; }
public byte? StarRating { get; init; }
public int? Votes { get; init; }
public AgeRating AgeRating { get; init; }
public bool HasImage { get; init; }
public ICollection<SupportedLanguage> SupportedLanguages { get; init; } = [];
public DateOnly? ExpectedDate { get; init; }
public DateOnly? SalesDate { get; init; }
public DateTime? RegistrationDate { get; init; }
public AIGeneration AI { get; init; }
public VoiceWorkSeries? Series { get; init; }
public VoiceWorkTranslation? Translation { get; init; }
public static VoiceWorkIngest From(DLSiteWork work, VoiceWorkDetails? details)
{
return new VoiceWorkIngest()
{
MakerId = work.MakerId,
MakerName = work.Maker,
ProductId = work.ProductId,
Title = work.ProductName,
Description = work.Description ?? string.Empty,
Tags = work.Tags,
Creators = work.Creators,
WishlistCount = details?.WishlistCount ?? 0,
Downloads = Math.Max(work.Downloads, details?.DownloadCount ?? 0),
HasTrial = work.HasTrial || (details?.HasTrial ?? false),
HasDLPlay = details?.HasDLPlay ?? false,
StarRating = work.StarRating,
Votes = work.Votes,
AgeRating = details?.AgeRating ?? work.AgeRating,
HasImage = !string.IsNullOrEmpty(work.ImageUrl) && !work.ImageUrl.Contains("no_img", StringComparison.OrdinalIgnoreCase),
SupportedLanguages = details?.SupportedLanguages ?? [],
ExpectedDate = work.ExpectedDate,
SalesDate = work.SalesDate,
RegistrationDate = details?.RegistrationDate,
AI = details?.AI ?? AIGeneration.None,
Series = details?.Series,
Translation = details?.Translation
};
}
}