Updated scanner/upsert logic.

This commit is contained in:
2025-09-17 09:40:24 -04:00
parent 3b2a0e3491
commit db0c3349a2
14 changed files with 434 additions and 66 deletions

View File

@@ -5,8 +5,14 @@ using System.Text.RegularExpressions;
namespace JSMR.Infrastructure.Scanning;
public class JapaneseVoiceWorksScanner(IHtmlLoader loader) : VoiceWorksScanner(loader)
public partial class JapaneseVoiceWorksScanner(IHtmlLoader loader) : VoiceWorksScanner(loader)
{
[GeneratedRegex("(.*?)年(.*?)月(.*)", RegexOptions.IgnoreCase, "en-US")]
private static partial Regex EstimatedDateRegex();
[GeneratedRegex("販売日: (.*?)年(.*?)月(.*)日", RegexOptions.IgnoreCase, "en-US")]
private static partial Regex SalesDateRegex();
protected override ILocale Locale => new JapaneseLocale();
protected override ISupportedLanguage[] SupportedLanguages =>
@@ -24,7 +30,7 @@ public class JapaneseVoiceWorksScanner(IHtmlLoader loader) : VoiceWorksScanner(l
if (expectedDate.Contains("販売中") || expectedDate.Contains("発売予定未定"))
return null;
Regex textRegex = new Regex("(.*?)年(.*?)月(.*)", RegexOptions.IgnoreCase);
Regex textRegex = EstimatedDateRegex();
MatchCollection textMatches = textRegex.Matches(expectedDate);
if (textMatches.Count == 0 || textMatches[0].Groups.Count < 4)
@@ -57,7 +63,7 @@ public class JapaneseVoiceWorksScanner(IHtmlLoader loader) : VoiceWorksScanner(l
protected override DateOnly? GetSalesDate(string salesDate)
{
Regex textRegex = new Regex("販売日:&nbsp;(.*?)年(.*?)月(.*)日", RegexOptions.IgnoreCase);
Regex textRegex = SalesDateRegex();
MatchCollection textMatches = textRegex.Matches(salesDate);
if (textMatches.Count == 0 || textMatches[0].Groups.Count < 4)