diff --git a/rss-generator/Class/Eroterest/MovieEroterestConfig.cs b/rss-generator/Class/Eroterest/MovieEroterestConfig.cs
index 5a688ad..f9374ac 100644
--- a/rss-generator/Class/Eroterest/MovieEroterestConfig.cs
+++ b/rss-generator/Class/Eroterest/MovieEroterestConfig.cs
@@ -55,4 +55,9 @@ internal static class MovieEroterestConfig
/// 記事詳細およびブログ取得時の並列度
///
public const int MaxParallelTasks = 3;
+
+ ///
+ /// RSS の pubDate に元動画の公開日を優先するかどうか(false の場合は記事の実際の公開日を優先し、元動画公開日は本文に記載)
+ ///
+ public const bool PreferOriginalVideoDateOverArticleDate = false;
}
diff --git a/rss-generator/Class/Eroterest/MovieEroterestFeedManager.cs b/rss-generator/Class/Eroterest/MovieEroterestFeedManager.cs
index b95ed7d..26cce34 100644
--- a/rss-generator/Class/Eroterest/MovieEroterestFeedManager.cs
+++ b/rss-generator/Class/Eroterest/MovieEroterestFeedManager.cs
@@ -127,8 +127,9 @@ internal static class MovieEroterestFeedManager
new Uri(pageUrl)
);
- var preliminaryItems = new List<(string ArticleUrl, string Title, string? Thumbnail, string? Duration, string? Provider, string? SiteName)>();
+ var preliminaryItems = new List<(string ArticleUrl, string Title, string? Thumbnail, string? Duration, string? Provider, string? SiteName, string? ItemTime, int Order)>();
var seenUrls = new HashSet(StringComparer.OrdinalIgnoreCase);
+ int orderIndex = 0;
foreach (var itemEl in itemElements)
{
@@ -170,7 +171,10 @@ internal static class MovieEroterestFeedManager
// まとめブログ名
var siteName = itemEl.QuerySelector(".itemSiteName")?.TextContent?.Trim();
- preliminaryItems.Add((fullUrl, title, thumbSrc, duration, provider, siteName));
+ // 記事公開時間(相対時間表記: 例 "4分前", "1時間前")
+ var itemTime = itemEl.QuerySelector(".itemTime")?.TextContent?.Trim();
+
+ preliminaryItems.Add((fullUrl, title, thumbSrc, duration, provider, siteName, itemTime, orderIndex++));
if (preliminaryItems.Count >= MovieEroterestConfig.MaxArticlesPerFeed)
{
@@ -178,10 +182,12 @@ internal static class MovieEroterestFeedManager
}
}
+ // 基準時刻
+ var baseTime = DateTimeOffset.Now;
+
// 同時並行数を制御して各記事の詳細と動画探索を実行
using var semaphore = new SemaphoreSlim(MovieEroterestConfig.MaxParallelTasks);
- var syndicationItems = new List();
- int itemOrder = 0;
+ var syndicationEntries = new List<(SyndicationItem Item, int Order)>();
var tasks = preliminaryItems.Select(async item =>
{
@@ -195,17 +201,16 @@ internal static class MovieEroterestFeedManager
item.Thumbnail,
item.Duration,
item.Provider,
- item.SiteName);
+ item.SiteName,
+ item.ItemTime,
+ baseTime);
if (articleInfo != null)
{
- // 新着順を保持するため秒単位で降順設定
- articleInfo.PublishDate = DateTimeOffset.Now.AddSeconds(-Interlocked.Increment(ref itemOrder));
-
var synItem = MovieEroterestVideoParser.CreateSyndicationItem(articleInfo);
- lock (syndicationItems)
+ lock (syndicationEntries)
{
- syndicationItems.Add(synItem);
+ syndicationEntries.Add((synItem, item.Order));
}
}
}
@@ -221,8 +226,12 @@ internal static class MovieEroterestFeedManager
await Task.WhenAll(tasks);
- // 新着順にソート
- feed.Items = syndicationItems.OrderByDescending(i => i.PublishDate).ToList();
+ // 公開日時順(同日時の場合は一覧の掲載順を維持)にソート
+ feed.Items = syndicationEntries
+ .OrderByDescending(e => e.Item.PublishDate)
+ .ThenBy(e => e.Order)
+ .Select(e => e.Item)
+ .ToList();
// XML ファイルへ出力 (filter24Hours: false で直近取得分を確実に出力)
await CmnUtil.ExportXMLFileAsync(outputFileName, feed, client, addDir: subDir, embedBase64: false, filter24Hours: false);
diff --git a/rss-generator/Class/Eroterest/MovieEroterestVideoParser.cs b/rss-generator/Class/Eroterest/MovieEroterestVideoParser.cs
index 1577533..8f67078 100644
--- a/rss-generator/Class/Eroterest/MovieEroterestVideoParser.cs
+++ b/rss-generator/Class/Eroterest/MovieEroterestVideoParser.cs
@@ -34,6 +34,11 @@ internal static class MovieEroterestVideoParser
public List Actresses { get; set; } = new();
public DateTimeOffset PublishDate { get; set; } = DateTimeOffset.Now;
+ // 日付・公開日情報
+ public string? RelativeTimeText { get; set; }
+ public DateTimeOffset? ArticlePublishDate { get; set; }
+ public DateTimeOffset? VideoPublishDate { get; set; }
+
// 探索結果
public string? DestinationBlogUrl { get; set; }
public string? DestinationBlogSiteName { get; set; }
@@ -55,6 +60,8 @@ internal static class MovieEroterestVideoParser
string? preliminaryDuration = null,
string? preliminaryProvider = null,
string? preliminarySiteName = null,
+ string? preliminaryItemTime = null,
+ DateTimeOffset? referenceTime = null,
CancellationToken ct = default)
{
var info = new EroterestArticleInfo
@@ -64,9 +71,16 @@ internal static class MovieEroterestVideoParser
ThumbnailUrl = preliminaryThumbnail,
Duration = preliminaryDuration,
Provider = preliminaryProvider,
- DestinationBlogSiteName = preliminarySiteName
+ DestinationBlogSiteName = preliminarySiteName,
+ RelativeTimeText = preliminaryItemTime
};
+ // 一覧から渡された相対時間(例: "4分前")から記事公開日を算出
+ if (!string.IsNullOrWhiteSpace(preliminaryItemTime))
+ {
+ info.ArticlePublishDate = ParseRelativeOrAbsoluteDate(preliminaryItemTime, referenceTime);
+ }
+
// 記事IDの抽出 (例: /page/44918986/)
var idMatch = Regex.Match(articleUrl, @"/page/([0-9]+)");
if (idMatch.Success)
@@ -129,6 +143,17 @@ internal static class MovieEroterestVideoParser
info.ClickCount = clickEl;
}
+ // 記事公開時間(詳細ページからフォールバック取得)
+ if (!info.ArticlePublishDate.HasValue)
+ {
+ var detailTime = articleDoc.QuerySelector(".itemFoot .itemTime, .itemTime")?.TextContent?.Trim();
+ if (!string.IsNullOrWhiteSpace(detailTime))
+ {
+ info.RelativeTimeText ??= detailTime;
+ info.ArticlePublishDate = ParseRelativeOrAbsoluteDate(detailTime, referenceTime);
+ }
+ }
+
// タグ
var tagElements = articleDoc.QuerySelectorAll(".itemTag a");
foreach (var t in tagElements)
@@ -200,6 +225,9 @@ internal static class MovieEroterestVideoParser
// 3. WebImageViewer の再生URLを決定
BuildViewerUrl(info);
+ // 4. RSS アイテムの日付を決定(設定・優先順位に基づく)
+ ResolvePublishDate(info);
+
return info;
}
@@ -401,32 +429,56 @@ internal static class MovieEroterestVideoParser
var content = script.TextContent;
if (string.IsNullOrWhiteSpace(content)) continue;
- if (content.Contains("contentUrl", StringComparison.OrdinalIgnoreCase))
+ try
{
- try
+ using var doc = JsonDocument.Parse(content);
+ var root = doc.RootElement;
+
+ // contentUrl (h264.m3u8)
+ if (string.IsNullOrWhiteSpace(info.StreamUrl) && root.TryGetProperty("contentUrl", out var contentUrlProp))
{
- using var doc = JsonDocument.Parse(content);
- var root = doc.RootElement;
- if (root.TryGetProperty("contentUrl", out var contentUrlProp))
+ var cUrl = contentUrlProp.GetString();
+ if (!string.IsNullOrWhiteSpace(cUrl))
{
- var cUrl = contentUrlProp.GetString();
- if (!string.IsNullOrWhiteSpace(cUrl))
- {
- info.StreamUrl = cUrl.Trim();
- break;
- }
+ info.StreamUrl = cUrl.Trim();
}
}
- catch
+
+ // uploadDate (元動画の公開日)
+ if (!info.VideoPublishDate.HasValue && root.TryGetProperty("uploadDate", out var uploadDateProp))
+ {
+ var uDateStr = uploadDateProp.GetString();
+ if (!string.IsNullOrWhiteSpace(uDateStr) && DateTimeOffset.TryParse(uDateStr, out var parsedUploadDate))
+ {
+ info.VideoPublishDate = parsedUploadDate;
+ }
+ }
+ }
+ catch
+ {
+ // JSONパースに失敗した場合は正規表現でフォールバック
+ if (string.IsNullOrWhiteSpace(info.StreamUrl))
{
- // JSONパースに失敗した場合は正規表現でフォールバック
var match = Regex.Match(content, @"""contentUrl""\s*:\s*""([^""]+)""");
if (match.Success)
{
info.StreamUrl = match.Groups[1].Value.Trim();
- break;
}
}
+
+ if (!info.VideoPublishDate.HasValue)
+ {
+ var dateMatch = Regex.Match(content, @"""uploadDate""\s*:\s*""([^""]+)""");
+ if (dateMatch.Success && DateTimeOffset.TryParse(dateMatch.Groups[1].Value, out var parsedDate))
+ {
+ info.VideoPublishDate = parsedDate;
+ }
+ }
+ }
+
+ if (!string.IsNullOrWhiteSpace(info.StreamUrl) && info.VideoPublishDate.HasValue)
+ {
+ break;
}
}
@@ -562,6 +614,15 @@ internal static class MovieEroterestVideoParser
// 4. メタ情報リスト
sb.Append("");
+ if (info.ArticlePublishDate.HasValue)
+ {
+ var relSuffix = !string.IsNullOrWhiteSpace(info.RelativeTimeText) ? $" ({WebUtility.HtmlEncode(info.RelativeTimeText)})" : "";
+ sb.Append($"- 📅 記事公開日: {info.ArticlePublishDate.Value:yyyy/MM/dd HH:mm}{relSuffix}
");
+ }
+ if (info.VideoPublishDate.HasValue)
+ {
+ sb.Append($"- 🎬 元動画公開日: {info.VideoPublishDate.Value:yyyy/MM/dd HH:mm}
");
+ }
if (!string.IsNullOrWhiteSpace(info.Provider))
{
sb.Append($"- 🏷 配信元・プロバイダ: {WebUtility.HtmlEncode(info.Provider)}
");
@@ -662,4 +723,95 @@ internal static class MovieEroterestVideoParser
}
return url;
}
+
+ ///
+ /// 設定および優先順位に基づいて RSS アイテムの公開日 (PublishDate) を決定します。
+ ///
+ public static void ResolvePublishDate(EroterestArticleInfo info)
+ {
+ if (MovieEroterestConfig.PreferOriginalVideoDateOverArticleDate && info.VideoPublishDate.HasValue)
+ {
+ info.PublishDate = info.VideoPublishDate.Value;
+ }
+ else if (info.ArticlePublishDate.HasValue)
+ {
+ info.PublishDate = info.ArticlePublishDate.Value;
+ }
+ else if (info.VideoPublishDate.HasValue)
+ {
+ info.PublishDate = info.VideoPublishDate.Value;
+ }
+ // フォールバック: 初期値 (DateTimeOffset.Now)
+ }
+
+ ///
+ /// 相対時間表記(例: "4秒前", "4分前", "11時間前", "1日前", "2か月前", "1年前")または絶対日付文字列から DateTimeOffset を算出します。
+ ///
+ public static DateTimeOffset? ParseRelativeOrAbsoluteDate(string? dateText, DateTimeOffset? referenceTime = null)
+ {
+ if (string.IsNullOrWhiteSpace(dateText)) return null;
+
+ var text = dateText.Trim();
+ var now = referenceTime ?? DateTimeOffset.Now;
+
+ // 1. 秒前
+ var secMatch = Regex.Match(text, @"^(\d+)\s*秒前");
+ if (secMatch.Success && int.TryParse(secMatch.Groups[1].Value, out int sec))
+ {
+ return now.AddSeconds(-sec);
+ }
+
+ // 2. 分前
+ var minMatch = Regex.Match(text, @"^(\d+)\s*分前");
+ if (minMatch.Success && int.TryParse(minMatch.Groups[1].Value, out int min))
+ {
+ return now.AddMinutes(-min);
+ }
+
+ // 3. 時間前
+ var hourMatch = Regex.Match(text, @"^(\d+)\s*時間前");
+ if (hourMatch.Success && int.TryParse(hourMatch.Groups[1].Value, out int hour))
+ {
+ return now.AddHours(-hour);
+ }
+
+ // 4. 日前
+ var dayMatch = Regex.Match(text, @"^(\d+)\s*日前");
+ if (dayMatch.Success && int.TryParse(dayMatch.Groups[1].Value, out int day))
+ {
+ return now.AddDays(-day);
+ }
+
+ // 5. か月前 / ヶ月前 / カ月前
+ var monthMatch = Regex.Match(text, @"^(\d+)\s*(?:か月|ヶ月|カ月)前");
+ if (monthMatch.Success && int.TryParse(monthMatch.Groups[1].Value, out int month))
+ {
+ return now.AddMonths(-month);
+ }
+
+ // 6. 年前
+ var yearMatch = Regex.Match(text, @"^(\d+)\s*年前");
+ if (yearMatch.Success && int.TryParse(yearMatch.Groups[1].Value, out int year))
+ {
+ return now.AddYears(-year);
+ }
+
+ // 7. 昨日・一昨日
+ if (text.StartsWith("昨日"))
+ {
+ return now.AddDays(-1);
+ }
+ if (text.StartsWith("一昨日"))
+ {
+ return now.AddDays(-2);
+ }
+
+ // 8. ISO 8601 または標準日時形式 (YYYY-MM-DD, YYYY/MM/DD 等)
+ if (DateTimeOffset.TryParse(text, out var parsedDto))
+ {
+ return parsedDto;
+ }
+
+ return null;
+ }
}