feat: SpankBangの動画個別ページから公開日時を取得・設定するよう変更
This commit is contained in:
1 parent
922e226b0a
commit
2f3ac958bf
1 file changed
+29
-5
@@ -150,8 +150,32 @@ internal static class spankbang
|
|||||||
body.Append($@"</div>");
|
body.Append($@"</div>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 個別動画ページから正確な公開時間(投稿日時)を取得
|
||||||
|
DateTimeOffset? publishedDateOffset = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var detailDoc = await CmnUtil.GetDocumentFlareSolverr(client, fullUrl, session: sessionId);
|
||||||
|
if (detailDoc != null)
|
||||||
|
{
|
||||||
|
var timeElement = detailDoc.QuerySelector("time[datetime]");
|
||||||
|
var dateTimeStr = timeElement?.GetAttribute("datetime");
|
||||||
|
if (!string.IsNullOrEmpty(dateTimeStr) && DateTimeOffset.TryParse(dateTimeStr, out var parsedDto))
|
||||||
|
{
|
||||||
|
publishedDateOffset = parsedDto;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogManager.AddLog($"[警告] spankbang 詳細ページ取得失敗 ({fullUrl}): {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
// メタ情報一覧
|
// メタ情報一覧
|
||||||
body.Append(@"<ul style=""font-size: 0.9em; color: #555; list-style-type: none; padding-left: 0; margin: 6px 0;"">");
|
body.Append(@"<ul style=""font-size: 0.9em; color: #555; list-style-type: none; padding-left: 0; margin: 6px 0;"">");
|
||||||
|
if (publishedDateOffset != null)
|
||||||
|
{
|
||||||
|
body.Append($@"<li>📅 <strong>公開日:</strong> {publishedDateOffset.Value.LocalDateTime:yyyy/MM/dd HH:mm:ss}</li>");
|
||||||
|
}
|
||||||
if (!string.IsNullOrEmpty(length))
|
if (!string.IsNullOrEmpty(length))
|
||||||
{
|
{
|
||||||
body.Append($@"<li>⏱ <strong>時間:</strong> {WebUtility.HtmlEncode(length)}</li>");
|
body.Append($@"<li>⏱ <strong>時間:</strong> {WebUtility.HtmlEncode(length)}</li>");
|
||||||
@@ -173,8 +197,8 @@ internal static class spankbang
|
|||||||
// 下部リンク
|
// 下部リンク
|
||||||
body.Append($@"<p style=""margin-top: 10px;""><a href=""{viewerUrl}"" target=""_blank"" rel=""noopener noreferrer"" style=""font-weight: bold; color: #e11d48;"">▶ WebImageViewerで動画を再生する</a> | <a href=""{itemUri}"" target=""_blank"" rel=""noopener noreferrer"" referrerpolicy=""no-referrer"">SpankBang公式で視聴する</a></p>");
|
body.Append($@"<p style=""margin-top: 10px;""><a href=""{viewerUrl}"" target=""_blank"" rel=""noopener noreferrer"" style=""font-weight: bold; color: #e11d48;"">▶ WebImageViewerで動画を再生する</a> | <a href=""{itemUri}"" target=""_blank"" rel=""noopener noreferrer"" referrerpolicy=""no-referrer"">SpankBang公式で視聴する</a></p>");
|
||||||
|
|
||||||
// 新着順を保持するために現在時刻から数秒ずつ引いて設定
|
// 取得できた場合はその日時、取得できなかった場合は新着順維持のためフォールバック日時
|
||||||
var publishedDate = DateTime.Now.AddSeconds(-itemIndex);
|
var itemPubDate = publishedDateOffset ?? new DateTimeOffset(DateTime.Now.AddSeconds(-itemIndex));
|
||||||
itemIndex++;
|
itemIndex++;
|
||||||
|
|
||||||
var item = new SyndicationItem(
|
var item = new SyndicationItem(
|
||||||
@@ -182,11 +206,11 @@ internal static class spankbang
|
|||||||
string.Empty,
|
string.Empty,
|
||||||
itemUri,
|
itemUri,
|
||||||
CmnUtil.CreateGuid(fullUrl),
|
CmnUtil.CreateGuid(fullUrl),
|
||||||
publishedDate
|
itemPubDate
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
PublishDate = publishedDate,
|
PublishDate = itemPubDate,
|
||||||
LastUpdatedTime = publishedDate
|
LastUpdatedTime = itemPubDate
|
||||||
};
|
};
|
||||||
|
|
||||||
// カテゴリ
|
// カテゴリ
|
||||||
|
|||||||
Reference in new issue
Block a user