Initial implementation of voice works scanning.
This commit is contained in:
74
JSMR.Infrastructure/Scanning/JapaneseVoiceWorksScanner.cs
Normal file
74
JSMR.Infrastructure/Scanning/JapaneseVoiceWorksScanner.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using JSMR.Infrastructure.Caching;
|
||||
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)
|
||||
{
|
||||
protected override ILocale Locale => new JapaneseLocale();
|
||||
|
||||
protected override ISupportedLanguage[] SupportedLanguages =>
|
||||
[
|
||||
new JapaneseLanguage(),
|
||||
new EnglishLanguage(),
|
||||
new TraditionalChineseLanguage(),
|
||||
new SimplifiedChineseLanguage(),
|
||||
new KoreanLanguage(),
|
||||
new AlingualLanguage()
|
||||
];
|
||||
|
||||
protected override DateTime? GetEstimatedReleaseDate(string expectedDate)
|
||||
{
|
||||
if (expectedDate.Contains("販売中") || expectedDate.Contains("発売予定未定"))
|
||||
return null;
|
||||
|
||||
Regex textRegex = new Regex("(.*?)年(.*?)月(.*)", RegexOptions.IgnoreCase);
|
||||
MatchCollection textMatches = textRegex.Matches(expectedDate);
|
||||
|
||||
if (textMatches.Count == 0 || textMatches[0].Groups.Count < 4)
|
||||
return null;
|
||||
|
||||
int releaseYear = Convert.ToInt32(textMatches[0].Groups[1].Value);
|
||||
int releaseMonth = Convert.ToInt32(textMatches[0].Groups[2].Value);
|
||||
int releaseDay = 1;
|
||||
|
||||
string releaseTime = textMatches[0].Groups[3].Value;
|
||||
|
||||
switch (releaseTime)
|
||||
{
|
||||
case "上旬発売予定":
|
||||
case "上旬 発売予定":
|
||||
releaseDay = 1;
|
||||
break;
|
||||
case "中旬発売予定":
|
||||
case "中旬 発売予定":
|
||||
releaseDay = 11;
|
||||
break;
|
||||
case "下旬発売予定":
|
||||
case "下旬 発売予定":
|
||||
releaseDay = 21;
|
||||
break;
|
||||
}
|
||||
|
||||
return new DateTime(releaseYear, releaseMonth, releaseDay);
|
||||
}
|
||||
|
||||
protected override DateTime? GetSalesDate(string salesDate)
|
||||
{
|
||||
Regex textRegex = new Regex("販売日: (.*?)年(.*?)月(.*)日", RegexOptions.IgnoreCase);
|
||||
MatchCollection textMatches = textRegex.Matches(salesDate);
|
||||
|
||||
if (textMatches.Count == 0 || textMatches[0].Groups.Count < 4)
|
||||
return null;
|
||||
|
||||
int releaseYear = Convert.ToInt32(textMatches[0].Groups[1].Value);
|
||||
int releaseMonth = Convert.ToInt32(textMatches[0].Groups[2].Value);
|
||||
int releaseDay = Convert.ToInt32(textMatches[0].Groups[3].Value);
|
||||
|
||||
return new DateTime(releaseYear, releaseMonth, releaseDay);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user