Added additional voice work update logic.

This commit is contained in:
2025-10-11 17:28:39 -04:00
parent db0c3349a2
commit 278b6df650
38 changed files with 56745 additions and 64 deletions

View File

@@ -1,5 +1,6 @@
using JSMR.Application.Common;
using JSMR.Application.Integrations.DLSite.Models;
using JSMR.Infrastructure.Common.SupportedLanguages;
using JSMR.Infrastructure.Integrations.DLSite.Models;
namespace JSMR.Infrastructure.Integrations.DLSite.Mapping;
@@ -23,9 +24,25 @@ public static class DLSiteToDomainMapper
("CHI_HANS", Language.ChineseSimplified)
];
private static readonly (string Code, ISupportedLanguage Lang)[] SupportedLanguageFlags2 =
[
("JPN", new JapaneseLanguage()),
("ENG", new EnglishLanguage()),
("CHI", new ChineseLanguage()),
("CHI_HANT", new TraditionalChineseLanguage()),
("CHI_HANS", new SimplifiedChineseLanguage())
];
private static readonly Dictionary<string, Language> TranslationLanguageMap =
SupportedLanguageFlags.ToDictionary(x => x.Code, x => x.Lang, StringComparer.OrdinalIgnoreCase);
private static readonly Dictionary<int, AgeRating> AgeRatingMap = new()
{
{ 1, AgeRating.AllAges },
{ 2, AgeRating.R15 },
{ 3, AgeRating.R18 }
};
public static VoiceWorkDetailCollection Map(ProductInfoCollection? productInfoCollection)
{
VoiceWorkDetailCollection result = [];
@@ -63,7 +80,8 @@ public static class DLSiteToDomainMapper
AI = MapAIGeneration(optionsSet),
HasTrial = optionsSet.Contains(OptTrial),
HasDLPlay = optionsSet.Contains(OptDLPlay),
HasReviews = optionsSet.Contains(OptReviews)
HasReviews = optionsSet.Contains(OptReviews),
AgeRating = MapAgeRating(productInfo)
};
}
@@ -105,11 +123,11 @@ public static class DLSiteToDomainMapper
};
}
private static Language[] MapSupportedLanguages(HashSet<string> options)
private static ISupportedLanguage[] MapSupportedLanguages(HashSet<string> options)
{
List<Language> languages = [];
List<ISupportedLanguage> languages = [];
foreach (var (code, language) in SupportedLanguageFlags)
foreach (var (code, language) in SupportedLanguageFlags2)
{
if (options.Contains(code) && !languages.Contains(language))
languages.Add(language);
@@ -128,4 +146,12 @@ public static class DLSiteToDomainMapper
return AIGeneration.None;
}
private static AgeRating MapAgeRating(ProductInfo productInfo)
{
if (AgeRatingMap.TryGetValue(productInfo.AgeCategory, out AgeRating ageRating))
return ageRating;
return AgeRating.R18;
}
}