Updated scanner logic, and added initial scanner tests.
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
using JSMR.Application.Common.Caching;
|
||||
using JSMR.Infrastructure.Common.Locales;
|
||||
using JSMR.Infrastructure.Common.Locales;
|
||||
using JSMR.Infrastructure.Common.SupportedLanguages;
|
||||
using JSMR.Infrastructure.Http;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace JSMR.Infrastructure.Scanning;
|
||||
|
||||
public class JapaneseVoiceWorksScanner(IHtmlLoader loader, ISpamCircleCache spamCircleCache)
|
||||
: VoiceWorksScanner(loader, spamCircleCache)
|
||||
public class JapaneseVoiceWorksScanner(IHtmlLoader loader) : VoiceWorksScanner(loader)
|
||||
{
|
||||
protected override ILocale Locale => new JapaneseLocale();
|
||||
|
||||
@@ -21,7 +19,7 @@ public class JapaneseVoiceWorksScanner(IHtmlLoader loader, ISpamCircleCache spam
|
||||
new AlingualLanguage()
|
||||
];
|
||||
|
||||
protected override DateTime? GetEstimatedReleaseDate(string expectedDate)
|
||||
protected override DateOnly? GetEstimatedReleaseDate(string expectedDate)
|
||||
{
|
||||
if (expectedDate.Contains("販売中") || expectedDate.Contains("発売予定未定"))
|
||||
return null;
|
||||
@@ -54,10 +52,10 @@ public class JapaneseVoiceWorksScanner(IHtmlLoader loader, ISpamCircleCache spam
|
||||
break;
|
||||
}
|
||||
|
||||
return new DateTime(releaseYear, releaseMonth, releaseDay);
|
||||
return new DateOnly(releaseYear, releaseMonth, releaseDay);
|
||||
}
|
||||
|
||||
protected override DateTime? GetSalesDate(string salesDate)
|
||||
protected override DateOnly? GetSalesDate(string salesDate)
|
||||
{
|
||||
Regex textRegex = new Regex("販売日: (.*?)年(.*?)月(.*)日", RegexOptions.IgnoreCase);
|
||||
MatchCollection textMatches = textRegex.Matches(salesDate);
|
||||
@@ -69,6 +67,6 @@ public class JapaneseVoiceWorksScanner(IHtmlLoader loader, ISpamCircleCache spam
|
||||
int releaseMonth = Convert.ToInt32(textMatches[0].Groups[2].Value);
|
||||
int releaseDay = Convert.ToInt32(textMatches[0].Groups[3].Value);
|
||||
|
||||
return new DateTime(releaseYear, releaseMonth, releaseDay);
|
||||
return new DateOnly(releaseYear, releaseMonth, releaseDay);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user