targetBlocks = paragraphs.Count > 0 ? paragraphs : new[] { container };
+
+ foreach (var block in targetBlocks)
+ {
+ // 各 内を
単位の行に分割して走査することで、グループ見出し行やプロバイダープレフィックスを正確に判定
+ var lines = SplitElementIntoLines(block);
+ string pendingGroupLabel = string.Empty;
+ var currentGroup = new DownloadGroup();
+
+ foreach (var lineNodes in lines)
+ {
+ var lineAnchors = new List();
+ foreach (var node in lineNodes)
+ {
+ if (node is IHtmlAnchorElement a)
+ {
+ lineAnchors.Add(a);
+ }
+ else if (node is IElement elem)
+ {
+ lineAnchors.AddRange(elem.QuerySelectorAll("a").OfType());
+ }
+ }
+
+ string lineText = NormalizeSingleLineText(string.Concat(lineNodes.Select(n => n.TextContent)));
+
+ // リンクを含まないテキストのみの行はグループ見出し(例: Full Game V1.0, Update Only (...))として扱う
+ if (lineAnchors.Count == 0)
+ {
+ if (!string.IsNullOrWhiteSpace(lineText) && !lineText.StartsWith("Free Download", StringComparison.OrdinalIgnoreCase))
+ {
+ // 既にボタンが溜まっていればグループを確定させて次グループの見出しにする
+ if (currentGroup.Items.Count > 0)
+ {
+ groups.Add(currentGroup);
+ currentGroup = new DownloadGroup();
+ }
+ pendingGroupLabel = lineText;
+ currentGroup.GroupLabel = pendingGroupLabel;
+ }
+ continue;
+ }
+
+ // 行の先頭側に "OtomiCloud:" のようなプレフィックスがある場合は抽出
+ string linePrefix = ExtractLineProviderPrefix(lineNodes);
+
+ foreach (var anchor in lineAnchors)
+ {
+ string href = (anchor.GetAttribute("href") ?? string.Empty).Trim();
+ if (string.IsNullOrWhiteSpace(href) ||
+ !Uri.TryCreate(href, UriKind.Absolute, out var uri) ||
+ (uri.Scheme != Uri.UriSchemeHttp && uri.Scheme != Uri.UriSchemeHttps))
+ {
+ continue;
+ }
+
+ // 本文全体フォールバック時は、非ダウンロードリンク(DLsite, Steam, 自サイト記事ページ等)を確実に除外
+ if (restrictToKnownHosts && !IsDownloadLinkHost(href))
+ {
+ continue;
+ }
+
+ // サイト側の重複リンク(WorkUpload が datanodes.to を指して直後の Mirror 1 と重複する等)を除外
+ if (!globalSeenUrls.Add(href))
+ {
+ continue;
+ }
+
+ string anchorText = NormalizeSingleLineText(anchor.TextContent);
+ var (providerName, bgColor, icon) = ResolveProviderInfo(uri, anchorText, linePrefix);
+ string partLabel = DeterminePartLabel(uri, anchorText);
+
+ currentGroup.Items.Add(new DownloadItem
+ {
+ ProviderName = providerName,
+ Url = href,
+ PartLabel = partLabel,
+ BgColor = bgColor,
+ Icon = icon
+ });
+ }
+ }
+
+ if (currentGroup.Items.Count > 0)
+ {
+ if (string.IsNullOrWhiteSpace(currentGroup.GroupLabel) && !string.IsNullOrWhiteSpace(pendingGroupLabel))
+ {
+ currentGroup.GroupLabel = pendingGroupLabel;
+ }
+ groups.Add(currentGroup);
+ }
+ }
+
+ return groups;
+ }
+
+ ///
+ /// 要素の子ノード列を <br> 要素で区切った行リストへ分割します。
+ ///
+ /// 分割対象要素
+ /// 行ごとのノードリスト
+ private static List> SplitElementIntoLines(IElement element)
+ {
+ var lines = new List>();
+ var currentLine = new List();
+
+ foreach (var child in element.ChildNodes)
+ {
+ if (child is IElement el && el.TagName.Equals("BR", StringComparison.OrdinalIgnoreCase))
+ {
+ if (currentLine.Count > 0)
+ {
+ lines.Add(currentLine);
+ currentLine = new List();
+ }
+ continue;
+ }
+
+ currentLine.Add(child);
+ }
+
+ if (currentLine.Count > 0)
+ {
+ lines.Add(currentLine);
+ }
+
+ return lines;
+ }
+
+ ///
+ /// 分割行ノード列の先頭テキストから「OtomiCloud:」等のプレフィックス表記を抽出します。
+ ///
+ /// 行内のノード列
+ /// 抽出されたプレフィックス(該当なしの場合は空文字)
+ private static string ExtractLineProviderPrefix(List lineNodes)
+ {
+ var prefixBuilder = new StringBuilder();
+ foreach (var node in lineNodes)
+ {
+ if (node is IHtmlAnchorElement || (node is IElement elem && elem.QuerySelector("a") != null))
+ {
+ break;
+ }
+ prefixBuilder.Append(node.TextContent);
+ }
+
+ string rawPrefix = NormalizeSingleLineText(prefixBuilder.ToString());
+ if (rawPrefix.EndsWith(':'))
+ {
+ return rawPrefix.TrimEnd(':').Trim();
+ }
+
+ return string.Empty;
+ }
+
+ ///
+ /// ダウンロード先 URL のホスト名、アンカーテキスト、行プレフィックスから
+ /// 実プロバイダー名・ブランドカラー・アイコンを判定します。
+ ///
+ /// ダウンロード先 URI
+ /// アンカーテキスト
+ /// 行冒頭のラベル
+ /// (プロバイダー名, 背景色, アイコン)
+ private static (string ProviderName, string BgColor, string Icon) ResolveProviderInfo(Uri uri, string anchorText, string linePrefix)
+ {
+ string host = uri.Host.ToLowerInvariant();
+
+ if (host.Contains("pre.otomi-games.com"))
+ {
+ return ("OtomiCloud", "#2e7d32", "⚡");
+ }
+ if (host.Contains("megaup.net"))
+ {
+ return ("MegaUp", "#1565c0", "⬇️");
+ }
+ if (host.Contains("workupload.com"))
+ {
+ return ("WorkUpload", "#ea580c", "☁️");
+ }
+ if (host.Contains("datanodes.to"))
+ {
+ return ("DataNodes", "#0277bd", "💾");
+ }
+ if (host.Contains("bzzhr.co") || host.Contains("buzzheavier.com"))
+ {
+ return ("Buzzheavier", "#6a1b9a", "🚀");
+ }
+ if (host.Contains("pixeldrain.com"))
+ {
+ return ("Pixeldrain", "#7b1fa2", "💧");
+ }
+ if (host.Contains("mega.nz"))
+ {
+ return ("MEGA", "#d32f2f", "☁️");
+ }
+ if (host.Contains("gofile.io"))
+ {
+ return ("Gofile", "#00897b", "📂");
+ }
+ if (host.Contains("mediafire.com"))
+ {
+ return ("MediaFire", "#00539b", "🔥");
+ }
+ if (host.Contains("drive.google.com"))
+ {
+ return ("Google Drive", "#0f9d58", "💾");
+ }
+ if (host.Contains("rapidgator.net"))
+ {
+ return ("Rapidgator", "#1976d2", "⬇️");
+ }
+ if (host.Contains("katfile."))
+ {
+ return ("Katfile", "#f57c00", "⬇️");
+ }
+ if (host.Contains("nitroflare.com"))
+ {
+ return ("Nitroflare", "#d32f2f", "⬇️");
+ }
+ if (host.Contains("frdl."))
+ {
+ return ("Frdl", "#388e3c", "⬇️");
+ }
+ if (host.Contains("mixdrop."))
+ {
+ return ("MixDrop", "#5e35b1", "⬇️");
+ }
+ if (host.Contains("krakenfiles.com"))
+ {
+ return ("Krakenfiles", "#3949ab", "⬇️");
+ }
+ if (host.Contains("uploadhaven.com"))
+ {
+ return ("UploadHaven", "#00838f", "⬇️");
+ }
+ if (host.Contains("1fichier.com"))
+ {
+ return ("1fichier", "#ef6c00", "⬇️");
+ }
+
+ // 未知プロバイダーの場合はアンカーテキスト → 行プレフィックス → ホスト名の順で採用
+ bool isPartAnchor = Regex.IsMatch(anchorText, @"^Part\s*\d+$", RegexOptions.IgnoreCase);
+ if (!string.IsNullOrWhiteSpace(anchorText) && !isPartAnchor && !anchorText.StartsWith("Mirror", StringComparison.OrdinalIgnoreCase))
+ {
+ return (anchorText, "#455a64", "⬇️");
+ }
+ if (!string.IsNullOrWhiteSpace(linePrefix))
+ {
+ return (linePrefix, "#455a64", "⬇️");
+ }
+
+ return (uri.Host, "#455a64", "⬇️");
+ }
+
+ ///
+ /// アンカーテキストおよび URL パスから分割ファイルのパート表記(Part 1, Part 2 等)を判定します。
+ ///
+ /// ダウンロード先 URI
+ /// アンカーテキスト
+ /// パート表記文字列(単一ファイルの場合は空文字)
+ private static string DeterminePartLabel(Uri uri, string anchorText)
+ {
+ var textMatch = Regex.Match(anchorText, @"Part\s*(\d+)", RegexOptions.IgnoreCase);
+ if (textMatch.Success)
+ {
+ return $"Part {textMatch.Groups[1].Value}";
+ }
+
+ string fileName = Path.GetFileName(uri.AbsolutePath);
+ if (!string.IsNullOrWhiteSpace(fileName))
+ {
+ var urlMatch = Regex.Match(fileName, @"(?:\.|_)part(\d+)(?:\.|$)", RegexOptions.IgnoreCase);
+ if (urlMatch.Success)
+ {
+ return $"Part {urlMatch.Groups[1].Value}";
+ }
+
+ var altMatch = Regex.Match(fileName, @"part(\d+)", RegexOptions.IgnoreCase);
+ if (altMatch.Success)
+ {
+ return $"Part {altMatch.Groups[1].Value}";
+ }
+ }
+
+ return string.Empty;
+ }
+
+ ///
+ /// 指定された URL がダウンロード用ストレージホスト(または直ファイルリンク)かどうかを判定します。
+ ///
+ /// 判定対象 URL
+ /// ダウンロードリンクとみなせる場合は true
+ private static bool IsDownloadLinkHost(string? url)
+ {
+ if (string.IsNullOrWhiteSpace(url) || !Uri.TryCreate(url, UriKind.Absolute, out var uri))
+ {
+ return false;
+ }
+
+ string host = uri.Host.ToLowerInvariant();
+
+ if (host.Contains("pre.otomi-games.com") ||
+ host.Contains("megaup.net") ||
+ host.Contains("workupload.com") ||
+ host.Contains("datanodes.to") ||
+ host.Contains("bzzhr.co") ||
+ host.Contains("buzzheavier.com") ||
+ host.Contains("pixeldrain.com") ||
+ host.Contains("mega.nz") ||
+ host.Contains("gofile.io") ||
+ host.Contains("mediafire.com") ||
+ host.Contains("drive.google.com") ||
+ host.Contains("rapidgator.net") ||
+ host.Contains("katfile.") ||
+ host.Contains("nitroflare.com") ||
+ host.Contains("frdl.") ||
+ host.Contains("mixdrop.") ||
+ host.Contains("krakenfiles.com") ||
+ host.Contains("uploadhaven.com") ||
+ host.Contains("1fichier.com") ||
+ host.Contains("wdho.ru") ||
+ host.Contains("download.gg") ||
+ host.Contains("anonfiles") ||
+ host.Contains("terabox"))
+ {
+ return true;
+ }
+
+ string path = uri.AbsolutePath.ToLowerInvariant();
+ return !host.Contains("otomi-games.com") &&
+ (path.EndsWith(".rar") || path.EndsWith(".zip") || path.EndsWith(".7z") || path.EndsWith(".torrent"));
+ }
+
+ ///
+ /// Windows の保存用フォルダ名として利用可能な整形済みタイトル([サークル名] タイトル (バージョン))を構築します。
+ /// 製品 ID を除去し、Windows 禁止文字を全角文字へ置換します。
+ ///
+ /// 記事詳細情報
+ /// 整形後のフォルダ名用タイトル
+ private static string BuildFolderTitle(ArticleInfo article)
+ {
+ // 1. ベースタイトルの選定(日本語原題を最優先)
+ string baseTitle = !string.IsNullOrWhiteSpace(article.JapaneseTitle)
+ ? article.JapaneseTitle
+ : StripTrailingBracketTags(article.RawArticleTitle);
+
+ baseTitle = RemoveProductIds(baseTitle);
+
+ // 2. サークル・開発元名プレフィックス
+ string circle = RemoveProductIds(article.Developer).Trim();
+ string titleBody = baseTitle;
+
+ if (!string.IsNullOrWhiteSpace(circle))
+ {
+ // タイトル先頭に既に [サークル名] が付いている場合は二重付与を回避
+ if (!titleBody.StartsWith($"[{circle}]", StringComparison.OrdinalIgnoreCase))
+ {
+ titleBody = $"[{circle}] {titleBody}".Trim();
+ }
+ }
+
+ // 3. バージョンサフィックスの付与(Final 以外の具体的バージョンのみ)
+ string ver = article.Version.Trim();
+ if (string.IsNullOrWhiteSpace(ver))
+ {
+ ver = ExtractVersionFromRawTitle(article.RawArticleTitle);
+ }
+
+ if (!string.IsNullOrWhiteSpace(ver) &&
+ !ver.Equals("Final", StringComparison.OrdinalIgnoreCase) &&
+ !ver.Equals("-", StringComparison.OrdinalIgnoreCase))
+ {
+ string formattedVer = ver.StartsWith("v", StringComparison.OrdinalIgnoreCase) ? $"V{ver.Substring(1)}" : $"V{ver}";
+ if (!titleBody.Contains(ver, StringComparison.OrdinalIgnoreCase) &&
+ !titleBody.Contains(formattedVer, StringComparison.OrdinalIgnoreCase))
+ {
+ titleBody = $"{titleBody} ({formattedVer})";
+ }
+ }
+
+ // 4. Windows 禁止文字を全角置換して返却
+ return SanitizeForWindows(titleBody);
+ }
+
+ ///
+ /// 記事詳細情報から視認性と実用性の高い本文 HTML を構築します。
+ /// ワンクリックコピー枠、直下ダウンロードグリッド、カバー画像、INFOテーブル、あらすじ、更新履歴、スクショを含みます。
+ ///
+ /// 記事詳細情報
+ /// 生成された本文 HTML
+ private static string BuildSummaryHtml(ArticleInfo article)
+ {
+ var sb = new StringBuilder();
+
+ sb.AppendLine("");
+
+ // 1. ヘッダーバッジ&日本時間 (JST) 表示
+ sb.AppendLine("
");
+ sb.AppendLine(" OTOMI-GAMES.COM");
+
+ var (langLabel, langBg) = GetLanguageBadge(article.LanguageRaw, article.Categories);
+ sb.AppendLine($" {WebUtility.HtmlEncode(langLabel)}");
+
+ if (!string.IsNullOrWhiteSpace(article.ProductId))
+ {
+ sb.AppendLine($" 🏷️ {WebUtility.HtmlEncode(article.ProductId)}");
+ }
+
+ if (!string.IsNullOrWhiteSpace(article.Version))
+ {
+ sb.AppendLine($" 📦 {WebUtility.HtmlEncode(article.Version)}");
+ }
+
+ sb.AppendLine($" 📅 {article.PublishDate.ToOffset(JstOffset):yyyy/MM/dd HH:mm:ss} (JST)");
+ sb.AppendLine("
");
+
+ // 2. 本文最上部のワンクリックコピー枠(AGENTS.md 4.2準拠)
+ sb.AppendLine("
");
+ sb.AppendLine("
📁 フォルダ名用タイトル(クリックで全選択)
");
+ sb.AppendLine($"
");
+ sb.AppendLine("
");
+
+ // 3. タイトル表示ブロック(日本語タイトル・元記事タイトル)
+ sb.AppendLine("
");
+ if (!string.IsNullOrWhiteSpace(article.JapaneseTitle))
+ {
+ sb.AppendLine($"
{WebUtility.HtmlEncode(article.JapaneseTitle)}
");
+ }
+ if (!string.IsNullOrWhiteSpace(article.RawArticleTitle) &&
+ !article.RawArticleTitle.Equals(article.JapaneseTitle, StringComparison.Ordinal))
+ {
+ sb.AppendLine($"
記事タイトル: {WebUtility.HtmlEncode(article.RawArticleTitle)}
");
+ }
+ sb.AppendLine("
");
+
+ // 4. ダウンロードセクション(タイトル直下・グリッドレイアウト配置)
+ if (article.DownloadGroups.Count > 0)
+ {
+ sb.AppendLine("
");
+ sb.AppendLine("
📥 ダウンロード (DIRECT DOWNLOAD)
");
+
+ bool showGroupLabel = article.DownloadGroups.Count > 1 ||
+ article.DownloadGroups.Any(g => !string.IsNullOrWhiteSpace(g.GroupLabel));
+
+ foreach (var group in article.DownloadGroups)
+ {
+ if (showGroupLabel && !string.IsNullOrWhiteSpace(group.GroupLabel))
+ {
+ sb.AppendLine($"
📦 {WebUtility.HtmlEncode(group.GroupLabel)}
");
+ }
+
+ sb.AppendLine("
");
+ foreach (var dl in group.Items)
+ {
+ string btnText = string.IsNullOrWhiteSpace(dl.PartLabel)
+ ? dl.ProviderName
+ : $"{dl.ProviderName} {dl.PartLabel}";
+
+ sb.AppendLine($"
{dl.Icon} {WebUtility.HtmlEncode(btnText)}");
+ }
+ sb.AppendLine("
");
+ }
+
+ sb.AppendLine("
");
+ sb.AppendLine($" 🔑 解凍パスワード (Password): {ArchivePassword}");
+ sb.AppendLine("
");
+ sb.AppendLine("
");
+ }
+
+ // 5. 公式ストアリンクボタン
+ if (!string.IsNullOrWhiteSpace(article.OfficialStoreUrl))
+ {
+ string storeName = string.IsNullOrWhiteSpace(article.OfficialStoreName) ? "Official Store" : article.OfficialStoreName;
+ sb.AppendLine("
");
+ }
+
+ // 6. カバー画像(本文中央センタリング + 原寸・高解像度リンクラップ)
+ if (!string.IsNullOrWhiteSpace(article.CoverImageUrl))
+ {
+ sb.AppendLine("
");
+ }
+
+ // 7. 基本情報テーブル (INFO)
+ var infoRows = new List<(string Label, string ValueHtml)>();
+ if (!string.IsNullOrWhiteSpace(article.JapaneseTitle))
+ {
+ infoRows.Add(("タイトル (原題)", WebUtility.HtmlEncode(article.JapaneseTitle)));
+ }
+ if (!string.IsNullOrWhiteSpace(article.Developer))
+ {
+ infoRows.Add(("開発元 / サークル", WebUtility.HtmlEncode(article.Developer)));
+ }
+ if (!string.IsNullOrWhiteSpace(article.Publisher) &&
+ !article.Publisher.Equals(article.Developer, StringComparison.OrdinalIgnoreCase))
+ {
+ infoRows.Add(("パブリッシャー", WebUtility.HtmlEncode(article.Publisher)));
+ }
+ if (!string.IsNullOrWhiteSpace(article.ReleaseDate))
+ {
+ infoRows.Add(("発売日", WebUtility.HtmlEncode(article.ReleaseDate)));
+ }
+ if (!string.IsNullOrWhiteSpace(article.Version))
+ {
+ infoRows.Add(("バージョン", WebUtility.HtmlEncode(article.Version)));
+ }
+ if (!string.IsNullOrWhiteSpace(article.LanguageRaw))
+ {
+ infoRows.Add(("対応言語", WebUtility.HtmlEncode(article.LanguageRaw)));
+ }
+ if (!string.IsNullOrWhiteSpace(article.Censored))
+ {
+ infoRows.Add(("修正・規制", WebUtility.HtmlEncode(article.Censored)));
+ }
+ if (article.Categories.Count > 0)
+ {
+ infoRows.Add(("カテゴリ", WebUtility.HtmlEncode(string.Join(", ", article.Categories))));
+ }
+ if (!string.IsNullOrWhiteSpace(article.OfficialStoreUrl))
+ {
+ string storeLabel = string.IsNullOrWhiteSpace(article.OfficialStoreName) ? article.OfficialStoreUrl : article.OfficialStoreName;
+ infoRows.Add(("公式ストア", $"
{WebUtility.HtmlEncode(storeLabel)}"));
+ }
+
+ if (infoRows.Count > 0)
+ {
+ sb.AppendLine("
");
+ foreach (var (label, valueHtml) in infoRows)
+ {
+ sb.AppendLine($" | {WebUtility.HtmlEncode(label)} | {valueHtml} |
");
+ }
+ sb.AppendLine("
");
+ }
+
+ // 8. 作品解説・あらすじ
+ if (article.DescriptionParagraphs.Count > 0)
+ {
+ sb.AppendLine("
");
+ sb.AppendLine("
📖 作品解説・あらすじ
");
+ foreach (var para in article.DescriptionParagraphs)
+ {
+ string encoded = WebUtility.HtmlEncode(para).Replace("\n", "
");
+ sb.AppendLine($"
{encoded}
");
+ }
+ sb.AppendLine("
");
+ }
+
+ // 9. 更新履歴 (CHANGELOG)
+ if (article.ChangelogLines.Count > 0)
+ {
+ sb.AppendLine("
");
+ sb.AppendLine("
📝 更新履歴 (CHANGELOG)
");
+ sb.AppendLine("
");
+ foreach (var line in article.ChangelogLines)
+ {
+ sb.AppendLine($" - {WebUtility.HtmlEncode(line)}
");
+ }
+ sb.AppendLine("
");
+ sb.AppendLine("
");
+ }
+
+ // 10. スクリーンショットギャラリー
+ if (article.ScreenshotUrls.Count > 0)
+ {
+ sb.AppendLine("
");
+ sb.AppendLine("
🖼️ スクリーンショット
");
+ foreach (var imgUrl in article.ScreenshotUrls)
+ {
+ sb.AppendLine("
");
+ }
+ sb.AppendLine("
");
+ }
+
+ // 11. 元記事リンクおよびキャッシュフォーマット識別タグ
+ sb.AppendLine("
");
+ sb.AppendLine($" ");
+ sb.AppendLine("
");
+
+ return sb.ToString().Trim();
+ }
+
+ ///
+ /// 指定された情報から を構築します。
+ /// GUID には による SHA512 ハッシュ値を設定します。
+ ///
+ private static SyndicationItem CreateSyndicationItem(
+ string title,
+ string summaryHtml,
+ Uri articleUri,
+ string guid,
+ DateTimeOffset publishDate,
+ DateTimeOffset lastUpdatedTime,
+ IEnumerable categories)
+ {
+ var item = new SyndicationItem(
+ title,
+ (string?)null,
+ articleUri,
+ guid,
+ lastUpdatedTime)
+ {
+ PublishDate = publishDate,
+ LastUpdatedTime = lastUpdatedTime,
+ Summary = new TextSyndicationContent(summaryHtml, TextSyndicationContentKind.Html)
+ };
+
+ if (categories != null)
+ {
+ foreach (var cat in categories)
+ {
+ if (!string.IsNullOrWhiteSpace(cat) &&
+ !item.Categories.Any(c => c.Name.Equals(cat, StringComparison.OrdinalIgnoreCase)))
+ {
+ item.Categories.Add(new SyndicationCategory(cat));
+ }
+ }
+ }
+
+ return item;
+ }
+
+ ///
+ /// 既存の XML ファイルからキャッシュエントリ(URL・GUID 辞書および順序付きリスト)を読み込みます。
+ ///
+ /// 読み込む XML ファイル名
+ /// (URL/GUID 検索用辞書, 既存エントリ一覧)
+ private static (Dictionary ByKey, List List) LoadExistingEntries(string fileName)
+ {
+ var byKey = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ var list = new List();
+
+ string filePath = CmnUtil.GetExportXmlPath(fileName, addDir: DomainDir);
+ if (!File.Exists(filePath))
+ {
+ return (byKey, list);
+ }
+
+ try
+ {
+ using var reader = XmlReader.Create(filePath);
+ var existingFeed = SyndicationFeed.Load(reader);
+ if (existingFeed?.Items == null)
+ {
+ return (byKey, list);
+ }
+
+ foreach (var item in existingFeed.Items)
+ {
+ string linkUrl = item.Links.FirstOrDefault()?.Uri?.AbsoluteUri ?? string.Empty;
+ string guid = item.Id ?? string.Empty;
+
+ if (string.IsNullOrWhiteSpace(linkUrl))
+ {
+ continue;
+ }
+
+ var entry = new ExistingFeedEntry
+ {
+ Url = linkUrl,
+ Title = item.Title?.Text?.Trim() ?? string.Empty,
+ SummaryHtml = item.Summary?.Text?.Trim() ?? string.Empty,
+ PublishDate = item.PublishDate != DateTimeOffset.MinValue
+ ? item.PublishDate.ToOffset(JstOffset)
+ : (item.LastUpdatedTime != DateTimeOffset.MinValue ? item.LastUpdatedTime.ToOffset(JstOffset) : DateTimeOffset.MinValue),
+ LastUpdatedTime = item.LastUpdatedTime != DateTimeOffset.MinValue
+ ? item.LastUpdatedTime.ToOffset(JstOffset)
+ : (item.PublishDate != DateTimeOffset.MinValue ? item.PublishDate.ToOffset(JstOffset) : DateTimeOffset.MinValue),
+ Categories = item.Categories
+ .Select(c => c.Name)
+ .Where(n => !string.IsNullOrWhiteSpace(n))
+ .Distinct(StringComparer.OrdinalIgnoreCase)
+ .ToList()
+ };
+
+ list.Add(entry);
+
+ string normUrl = NormalizeUrl(linkUrl);
+ string hashGuid = CmnUtil.CreateGuid(linkUrl);
+ string normHashGuid = CmnUtil.CreateGuid(normUrl);
+
+ byKey.TryAdd(linkUrl, entry);
+ byKey.TryAdd(normUrl, entry);
+ byKey.TryAdd(hashGuid, entry);
+ byKey.TryAdd(normHashGuid, entry);
+ if (!string.IsNullOrWhiteSpace(guid))
+ {
+ byKey.TryAdd(guid, entry);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.AddLog($"[警告] 【otomigames】 既存フィードの読み込み中にエラーが発生しました: {ex.Message}");
+ }
+
+ return (byKey, list);
+ }
+
+ ///
+ /// JSON 要素から指定プロパティの文字列値を安全に取得します。
+ ///
+ private static string? GetJsonString(JsonElement elem, string propertyName)
+ {
+ return elem.TryGetProperty(propertyName, out var prop) && prop.ValueKind == JsonValueKind.String
+ ? prop.GetString()
+ : null;
+ }
+
+ ///
+ /// WordPress REST API の UTC 日時文字列(date_gmt 等)を確実に UTC として解釈し、日本時間 (JST = +09:00) へ変換します。
+ ///
+ /// GMT/UTC 日時文字列
+ /// フォールバック日時文字列
+ /// パース失敗時の既定値
+ /// 日本時間 (JST) の DateTimeOffset
+ private static DateTimeOffset ParseUtcDateToJst(string? gmtStr, string? fallbackStr, DateTimeOffset defaultValue)
+ {
+ string? target = !string.IsNullOrWhiteSpace(gmtStr) ? gmtStr : fallbackStr;
+ if (!string.IsNullOrWhiteSpace(target) &&
+ DateTimeOffset.TryParse(
+ target,
+ CultureInfo.InvariantCulture,
+ DateTimeStyles.AssumeUniversal | DateTimeStyles.AdjustToUniversal,
+ out var utcDto))
+ {
+ return utcDto.ToOffset(JstOffset);
+ }
+
+ return defaultValue.ToOffset(JstOffset);
+ }
+
+ ///
+ /// 言語表記およびカテゴリから表示用の言語バッジ(テキスト・背景色)を決定します。
+ ///
+ private static (string Label, string BgColor) GetLanguageBadge(string languageRaw, List categories)
+ {
+ bool hasJapanese = languageRaw.Contains("Japanese", StringComparison.OrdinalIgnoreCase) ||
+ categories.Any(c => c.Equals("Japanese", StringComparison.OrdinalIgnoreCase));
+ bool hasOtherLang = languageRaw.Contains("English", StringComparison.OrdinalIgnoreCase) ||
+ languageRaw.Contains("Chinese", StringComparison.OrdinalIgnoreCase) ||
+ languageRaw.Contains("Korean", StringComparison.OrdinalIgnoreCase);
+
+ if (hasJapanese && !hasOtherLang)
+ {
+ return ("🇯🇵 日本語版", "#2e7d32");
+ }
+ if (hasJapanese && hasOtherLang)
+ {
+ return ("🌐 多言語 (日本語対応)", "#0284c7");
+ }
+ return ("🔤 海外版 / 英語等", "#546e7a");
+ }
+
+ ///
+ /// 段落要素から <br> を改行として保持しつつ、クリーンなテキストを抽出します。
+ ///
+ private static string ExtractParagraphTextWithLineBreaks(IElement element)
+ {
+ var sb = new StringBuilder();
+ foreach (var child in element.ChildNodes)
+ {
+ if (child is IElement el && el.TagName.Equals("BR", StringComparison.OrdinalIgnoreCase))
+ {
+ sb.Append('\n');
+ }
+ else if (child is IElement childElem)
+ {
+ sb.Append(ExtractParagraphTextWithLineBreaks(childElem));
+ }
+ else
+ {
+ sb.Append(child.TextContent);
+ }
+ }
+
+ string decoded = WebUtility.HtmlDecode(sb.ToString()).Replace("\r\n", "\n").Replace('\r', '\n');
+ var lines = decoded.Split('\n').Select(l => Regex.Replace(l, @"[ \t]+", " ").Trim());
+ return string.Join("\n", lines).Trim();
+ }
+
+ ///
+ /// 単一行テキスト内の HTML エンティティおよび連続空白・改行を正規化します。
+ ///
+ private static string NormalizeSingleLineText(string? text)
+ {
+ if (string.IsNullOrWhiteSpace(text))
+ {
+ return string.Empty;
+ }
+
+ string decoded = WebUtility.HtmlDecode(text);
+ return Regex.Replace(decoded, @"\s+", " ").Trim();
+ }
+
+ ///
+ /// INFO 項目の値が空・ダッシュ記号のみのプレースホルダーかどうかを判定します。
+ ///
+ private static bool IsPlaceholderValue(string? value)
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ return true;
+ }
+ string trimmed = value.Trim();
+ return trimmed == "-" || trimmed == "–" || trimmed == "—" || trimmed.Equals("N/A", StringComparison.OrdinalIgnoreCase);
+ }
+
+ ///
+ /// 記事タイトルおよび公式ストア URL から製品 ID(RJ / VJ / BJ 番号)を抽出します。
+ ///
+ private static string ExtractProductId(string rawTitle, string storeUrl)
+ {
+ var titleMatch = Regex.Match(rawTitle, @"\b((?:RJ|VJ|BJ)\d{6,8})\b", RegexOptions.IgnoreCase);
+ if (titleMatch.Success)
+ {
+ return titleMatch.Groups[1].Value.ToUpperInvariant();
+ }
+
+ if (!string.IsNullOrWhiteSpace(storeUrl))
+ {
+ var urlMatch = Regex.Match(storeUrl, @"\b((?:RJ|VJ|BJ)\d{6,8})\b", RegexOptions.IgnoreCase);
+ if (urlMatch.Success)
+ {
+ return urlMatch.Groups[1].Value.ToUpperInvariant();
+ }
+ }
+
+ return string.Empty;
+ }
+
+ ///
+ /// INFO 欄から開発元を取得できなかった場合、タイトル末尾の角括弧 [サークル名] からサークル名を抽出します。
+ ///
+ private static string ExtractCircleFromTitle(string rawTitle)
+ {
+ if (string.IsNullOrWhiteSpace(rawTitle))
+ {
+ return string.Empty;
+ }
+
+ var matches = Regex.Matches(rawTitle, @"\[([^\]]+)\]");
+ for (int i = matches.Count - 1; i >= 0; i--)
+ {
+ string candidate = matches[i].Groups[1].Value.Trim();
+ if (string.IsNullOrWhiteSpace(candidate))
+ {
+ continue;
+ }
+ if (Regex.IsMatch(candidate, @"^(?:RJ|VJ|BJ|d_)\d+$", RegexOptions.IgnoreCase))
+ {
+ continue;
+ }
+ if (Regex.IsMatch(candidate, @"^v?\d+(?:\.\d+)*(?:[a-zA-Z0-9.+_-]*)$", RegexOptions.IgnoreCase))
+ {
+ continue;
+ }
+ return candidate;
+ }
+
+ return string.Empty;
+ }
+
+ ///
+ /// 生タイトル末尾・中間のタグ([RJ...], [V...], [サークル名] 等)を除去し、作品タイトル本体を取り出します。
+ ///
+ private static string StripTrailingBracketTags(string rawTitle)
+ {
+ if (string.IsNullOrWhiteSpace(rawTitle))
+ {
+ return string.Empty;
+ }
+
+ string stripped = Regex.Replace(rawTitle, @"(?:\s*\[[^\]]+\])+\s*$", "");
+ stripped = Regex.Replace(stripped, @"\s*\((?:Update\s*)?[vV]?\d+[^)]*\)\s*$", "", RegexOptions.IgnoreCase);
+ return stripped.Trim();
+ }
+
+ ///
+ /// 生タイトルからバージョン表記のみをフォールバック抽出します。
+ ///
+ private static string ExtractVersionFromRawTitle(string rawTitle)
+ {
+ if (string.IsNullOrWhiteSpace(rawTitle))
+ {
+ return string.Empty;
+ }
+
+ var match = Regex.Match(rawTitle, @"\[[vV](\d+[^\]]*)\]|\([vV](\d+[^)]*)\)");
+ if (match.Success)
+ {
+ return !string.IsNullOrWhiteSpace(match.Groups[1].Value)
+ ? match.Groups[1].Value.Trim()
+ : match.Groups[2].Value.Trim();
+ }
+
+ return string.Empty;
+ }
+
+ ///
+ /// 文字列から製品 ID([RJxxxxxx], (VJxxxxxx), [BJxxxxxx] 等)を除去します。
+ ///
+ private static string RemoveProductIds(string text)
+ {
+ if (string.IsNullOrWhiteSpace(text))
+ {
+ return string.Empty;
+ }
+
+ string cleaned = Regex.Replace(text, @"\s*[\[\(\{\【]\s*(?:RJ|VJ|BJ|d_)\d{5,8}\s*[\]\)\}\】]", "", RegexOptions.IgnoreCase);
+ cleaned = Regex.Replace(cleaned, @"\b(?:RJ|VJ|BJ)\d{6,8}\b", "", RegexOptions.IgnoreCase);
+ return Regex.Replace(cleaned, @"\s{2,}", " ").Trim();
+ }
+
+ ///
+ /// Windows のフォルダ名に使用できない禁止文字(\ / : * ? " < > |)を全角文字に置換します。
+ ///
+ private static string SanitizeForWindows(string text)
+ {
+ if (string.IsNullOrWhiteSpace(text))
+ {
+ return string.Empty;
+ }
+
+ var sb = new StringBuilder(text);
+ sb.Replace('\\', '¥');
+ sb.Replace('/', '/');
+ sb.Replace(':', ':');
+ sb.Replace('*', '*');
+ sb.Replace('?', '?');
+ sb.Replace('"', '”');
+ sb.Replace('<', '<');
+ sb.Replace('>', '>');
+ sb.Replace('|', '|');
+ sb.Replace("\r", " ");
+ sb.Replace("\n", " ");
+
+ return Regex.Replace(sb.ToString(), @"\s+", " ").Trim();
+ }
+
+ ///
+ /// URL の末尾スラッシュやフラグメントを正規化します。
+ ///
+ private static string NormalizeUrl(string url)
+ {
+ if (string.IsNullOrWhiteSpace(url))
+ {
+ return string.Empty;
+ }
+
+ int hashIdx = url.IndexOf('#');
+ if (hashIdx >= 0)
+ {
+ url = url.Substring(0, hashIdx);
+ }
+
+ return url.Trim().TrimEnd('/');
+ }
+
+ #endregion
+}
diff --git a/rss-generator/Class/Po85/po85.cs b/rss-generator/Class/Po85/po85.cs
new file mode 100644
index 0000000..548e324
--- /dev/null
+++ b/rss-generator/Class/Po85/po85.cs
@@ -0,0 +1,707 @@
+using AngleSharp.Dom;
+using AngleSharp.Html.Dom;
+using AngleSharp.Html.Parser;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.ServiceModel.Syndication;
+using System.Text;
+using System.Text.RegularExpressions;
+using System.Threading.Tasks;
+using System.Xml;
+using rss_generator.Class.Common;
+
+namespace rss_generator.Class.Po85;
+
+///
+/// 85PO (https://www.85po.com/) の新着RSS (https://www.85po.com/ja/rss/) を取得し、
+/// WebImageViewer (https://udukipc-web.armonica-vps.work/) への再生リンク、ワンクリックフォルダ名コピー枠、
+/// 高解像度プレビュー画像、ダウンロード直リンク等を付加した拡張 RSS フィード (85po.xml) を生成・出力するクラスです。
+///
+internal static class po85
+{
+ #region □定数(Private)
+
+ ///
+ /// プロジェクト固有規則に基づく出力先ドメインディレクトリ名です。
+ ///
+ private const string DomainDir = "85po.com";
+
+ ///
+ /// 出力フィードのファイル名です。
+ ///
+ private const string FileName = "85po.xml";
+
+ ///
+ /// 取得元の公式RSSフィードURLです。
+ ///
+ private const string TargetFeedUrl = "https://www.85po.com/ja/rss/";
+
+ ///
+ /// 85PO のベースURLです。
+ ///
+ private const string BaseUrl = "https://www.85po.com";
+
+ ///
+ /// WebImageViewer のベースURLです。
+ ///
+ private const string WebImageViewerBaseUrl = "https://udukipc-web.armonica-vps.work/?url=";
+
+ ///
+ /// キャッシュ判定用の最新フォーマット識別子です。
+ ///
+ private const string CacheFormatTag = "85po-format-v1";
+
+ ///
+ /// フィードで保持する最大アイテム数です。
+ ///
+ private const int MaxFeedItems = 100;
+
+ #endregion
+
+ #region □クラス(Private)
+
+ ///
+ /// 既存の RSS フィードから読み込んだ記事情報を保持する内部クラスです。
+ ///
+ private sealed class ExistingFeedEntry
+ {
+ ///
+ /// 記事のタイトルを取得または設定します。
+ ///
+ public string Title { get; set; } = string.Empty;
+
+ ///
+ /// 記事の本文 HTML (Summary) を取得または設定します。
+ ///
+ public string SummaryHtml { get; set; } = string.Empty;
+
+ ///
+ /// 記事の初回公開日時を取得または設定します。
+ ///
+ public DateTimeOffset PublishDate { get; set; }
+
+ ///
+ /// 記事の最終更新日時を取得または設定します。
+ ///
+ public DateTimeOffset LastUpdatedTime { get; set; }
+
+ ///
+ /// カテゴリ一覧を取得または設定します。
+ ///
+ public List Categories { get; set; } = new();
+ }
+
+ ///
+ /// 各動画の詳細情報を保持する内部クラスです。
+ ///
+ private sealed class VideoDetailInfo
+ {
+ ///
+ /// 動画の元タイトルを取得または設定します。
+ ///
+ public string OriginalTitle { get; set; } = string.Empty;
+
+ ///
+ /// Windows フォルダ名用に整形されたタイトルを取得または設定します。
+ ///
+ public string CleanTitle { get; set; } = string.Empty;
+
+ ///
+ /// 動画ページのURLを取得または設定します。
+ ///
+ public string VideoUrl { get; set; } = string.Empty;
+
+ ///
+ /// サムネイル画像URLを取得または設定します。
+ ///
+ public string? ThumbnailUrl { get; set; }
+
+ ///
+ /// 高解像度プレビュー画像URLを取得または設定します。
+ ///
+ public string? PreviewImageUrl { get; set; }
+
+ ///
+ /// 動画の再生時間文字列を取得または設定します。
+ ///
+ public string? Duration { get; set; }
+
+ ///
+ /// 動画のタグ一覧を取得または設定します。
+ ///
+ public List Tags { get; set; } = new();
+
+ ///
+ /// ダウンロード直リンクURLを取得または設定します。
+ ///
+ public string? DownloadUrl { get; set; }
+
+ ///
+ /// ダウンロードリンクの表示ラベル(画質・サイズ等)を取得または設定します。
+ ///
+ public string? DownloadLabel { get; set; }
+
+ ///
+ /// 動画の説明文を取得または設定します。
+ ///
+ public string? Description { get; set; }
+ }
+
+ #endregion
+
+ #region □メソッド(Public)
+
+ ///
+ /// 85PO の新着RSSを取得し、WebImageViewer へのリンク等を追加した拡張 RSS フィードを非同期で生成・出力します。
+ ///
+ /// HTTP 通信に使用する HttpClient インスタンス
+ /// 非同期タスク
+ public static async Task CreateRSSAsync(HttpClient client)
+ {
+ var feed = new SyndicationFeed(
+ "85PO - 新着ビデオ (WebImageViewer拡張版)",
+ "85POの最新新着動画フィードです。WebImageViewerでの直接再生リンクおよびダウンロードリンクが含まれています。",
+ new Uri("https://www.85po.com/ja/latest-updates/"));
+
+ try
+ {
+ // 1. 既存XMLフィードの読み込み(未更新記事の再利用および過去記事のマージ用)
+ var existingEntries = LoadExistingEntries(FileName, DomainDir);
+ LogManager.AddLog($"[情報] 【85po】 既存フィードキャッシュ件数: {existingEntries.Count} 件");
+
+ // 2. 85PO 公式RSSフィードの取得
+ using var request = new HttpRequestMessage(HttpMethod.Get, TargetFeedUrl);
+ request.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
+ request.Headers.Add("Accept", "application/rss+xml,application/xml,text/xml;q=0.9,*/*;q=0.8");
+
+ using var response = await client.SendAsync(request);
+ if (!response.IsSuccessStatusCode)
+ {
+ LogManager.AddLog($"[エラー] 【85po】 RSSフィードの取得に失敗しました。HTTPステータス: {(int)response.StatusCode}");
+ return;
+ }
+
+ var rssXml = await response.Content.ReadAsStringAsync();
+ if (string.IsNullOrWhiteSpace(rssXml))
+ {
+ LogManager.AddLog("[エラー] 【85po】 RSSフィードの内容が空でした。");
+ return;
+ }
+
+ // 3. XML の読み込みとパース
+ using var stringReader = new StringReader(rssXml);
+ using var xmlReader = XmlReader.Create(stringReader, new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore });
+ var sourceFeed = SyndicationFeed.Load(xmlReader);
+ if (sourceFeed == null || sourceFeed.Items == null)
+ {
+ LogManager.AddLog("[エラー] 【85po】 RSSフィードのXML解析に失敗しました。");
+ return;
+ }
+
+ var currentItems = new List();
+ var processedUrls = new HashSet(StringComparer.OrdinalIgnoreCase);
+
+ foreach (var srcItem in sourceFeed.Items)
+ {
+ var articleUrl = srcItem.Links.FirstOrDefault()?.Uri?.AbsoluteUri
+ ?? srcItem.Id
+ ?? string.Empty;
+
+ if (string.IsNullOrWhiteSpace(articleUrl))
+ {
+ continue;
+ }
+
+ if (!processedUrls.Add(articleUrl))
+ {
+ continue;
+ }
+
+ // プロジェクト固有規則: GUIDのハッシュ化(CmnUtil.CreateGuid)
+ var guid = CmnUtil.CreateGuid(articleUrl);
+ var itemUri = new Uri(articleUrl);
+
+ // 日時を日本時間(JST = UTC+9)に正確に変換
+ var pubDate = ConvertToJst(srcItem.PublishDate);
+
+ // 既存キャッシュの確認
+ existingEntries.TryGetValue(articleUrl, out var prevEntry);
+ if (prevEntry == null && !string.IsNullOrEmpty(guid))
+ {
+ existingEntries.TryGetValue(guid, out prevEntry);
+ }
+
+ // 最新フォーマット(85po-format-v1)を持つ既存キャッシュはそのまま再利用して高速化&未読化防止
+ if (prevEntry != null &&
+ !string.IsNullOrEmpty(prevEntry.SummaryHtml) &&
+ prevEntry.SummaryHtml.Contains(CacheFormatTag))
+ {
+ var cachedItem = new SyndicationItem(
+ prevEntry.Title,
+ (string?)null,
+ itemUri,
+ guid,
+ prevEntry.LastUpdatedTime)
+ {
+ PublishDate = prevEntry.PublishDate,
+ LastUpdatedTime = prevEntry.LastUpdatedTime,
+ Summary = new TextSyndicationContent(prevEntry.SummaryHtml, TextSyndicationContentKind.Html)
+ };
+
+ foreach (var cat in prevEntry.Categories)
+ {
+ cachedItem.Categories.Add(new SyndicationCategory(cat));
+ }
+
+ currentItems.Add(cachedItem);
+ continue;
+ }
+
+ // 新規記事またはフォーマット未更新の記事: 詳細情報取得
+ var rawTitle = srcItem.Title?.Text?.Trim() ?? "タイトルなし";
+ var rawDesc = srcItem.Summary?.Text ?? string.Empty;
+
+ var detailInfo = await FetchVideoDetailAsync(client, articleUrl, rawTitle, rawDesc);
+ var summaryHtml = BuildSummaryHtml(detailInfo, pubDate);
+
+ var newItem = new SyndicationItem(
+ detailInfo.CleanTitle,
+ (string?)null,
+ itemUri,
+ guid,
+ pubDate)
+ {
+ PublishDate = pubDate,
+ LastUpdatedTime = pubDate,
+ Summary = new TextSyndicationContent(summaryHtml, TextSyndicationContentKind.Html)
+ };
+
+ foreach (var tag in detailInfo.Tags)
+ {
+ newItem.Categories.Add(new SyndicationCategory(tag));
+ }
+
+ currentItems.Add(newItem);
+ }
+
+ // 4. 過去記事の差分マージ(最大100件まで保持)
+ foreach (var kvp in existingEntries)
+ {
+ var entry = kvp.Value;
+ if (string.IsNullOrEmpty(kvp.Key) || processedUrls.Contains(kvp.Key))
+ {
+ continue;
+ }
+
+ // URLとして有効なキーのみマージ対象とする
+ if (!Uri.TryCreate(kvp.Key, UriKind.Absolute, out var pastUri))
+ {
+ continue;
+ }
+
+ if (!processedUrls.Add(kvp.Key))
+ {
+ continue;
+ }
+
+ var pastGuid = CmnUtil.CreateGuid(kvp.Key);
+ var pastItem = new SyndicationItem(
+ entry.Title,
+ (string?)null,
+ pastUri,
+ pastGuid,
+ entry.LastUpdatedTime)
+ {
+ PublishDate = entry.PublishDate,
+ LastUpdatedTime = entry.LastUpdatedTime,
+ Summary = new TextSyndicationContent(entry.SummaryHtml, TextSyndicationContentKind.Html)
+ };
+
+ foreach (var cat in entry.Categories)
+ {
+ pastItem.Categories.Add(new SyndicationCategory(cat));
+ }
+
+ currentItems.Add(pastItem);
+ }
+
+ // 5. 日時降順ソートおよび件数制限
+ var finalItems = currentItems
+ .OrderByDescending(x => x.PublishDate)
+ .Take(MaxFeedItems)
+ .ToList();
+
+ feed.Items = finalItems;
+ LogManager.AddLog($"[情報] 【85po】 最終出力アイテム数: {finalItems.Count} 件");
+
+ // 6. XML ファイルへの出力(プロジェクト固有規則: addDir にドメインディレクトリを指定)
+ await CmnUtil.ExportXMLFileAsync(
+ FileName,
+ feed,
+ client,
+ addDir: DomainDir,
+ embedBase64: false,
+ filter24Hours: false);
+
+ LogManager.AddLog($"[情報] 【85po】 RSS 生成完了: output/{DomainDir}/{FileName}");
+ }
+ catch (Exception ex)
+ {
+ LogManager.AddLog($"[エラー] 【85po】 CreateRSSAsync 実行時例外: {ex.Message}");
+ LogManager.AddLog($"{ex.StackTrace}");
+ }
+ }
+
+ #endregion
+
+ #region □メソッド(Private)
+
+ ///
+ /// 動画個別ページを取得し、詳細情報を解析・構築します。
+ /// 取得失敗時はRSSフィード内の情報からフォールバックして安全に構築します。
+ ///
+ /// HttpClient インスタンス
+ /// 動画ページのURL
+ /// RSSフィードから取得したタイトル
+ /// RSSフィードから取得した説明文HTML
+ /// 動画詳細情報オブジェクト
+ private static async Task FetchVideoDetailAsync(
+ HttpClient client,
+ string videoUrl,
+ string feedTitle,
+ string feedDesc)
+ {
+ var cleanTitle = CleanFileNameTitle(feedTitle);
+ var info = new VideoDetailInfo
+ {
+ OriginalTitle = feedTitle,
+ CleanTitle = cleanTitle,
+ VideoUrl = videoUrl
+ };
+
+ // RSS の description からサムネイル画像および説明テキストを初期抽出
+ ExtractFromFeedDescription(feedDesc, info);
+
+ try
+ {
+ using var request = new HttpRequestMessage(HttpMethod.Get, videoUrl);
+ request.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
+ request.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
+
+ using var response = await client.SendAsync(request);
+ if (response.IsSuccessStatusCode)
+ {
+ var html = await response.Content.ReadAsStringAsync();
+ var parser = new HtmlParser();
+ using var document = await parser.ParseDocumentAsync(html);
+
+ // タイトル取得
+ var h1Title = document.QuerySelector(".headline-video h1")?.TextContent?.Trim();
+ if (!string.IsNullOrWhiteSpace(h1Title))
+ {
+ info.OriginalTitle = h1Title;
+ info.CleanTitle = CleanFileNameTitle(h1Title);
+ }
+
+ // 再生時間取得
+ var durationText = document.QuerySelector(".headline-item i.icon-playlist ~ span.text")?.TextContent?.Trim();
+ if (!string.IsNullOrWhiteSpace(durationText))
+ {
+ info.Duration = durationText;
+ }
+
+ // 高画質プレビュー画像(og:image)
+ var ogImage = document.QuerySelector("meta[property='og:image']")?.GetAttribute("content")?.Trim();
+ if (!string.IsNullOrWhiteSpace(ogImage))
+ {
+ info.PreviewImageUrl = ogImage;
+ }
+
+ // 説明文
+ var desc = document.QuerySelector("meta[name='description']")?.GetAttribute("content")?.Trim();
+ if (!string.IsNullOrWhiteSpace(desc) && string.IsNullOrWhiteSpace(info.Description))
+ {
+ info.Description = desc;
+ }
+
+ // タグ・カテゴリ
+ var tagElements = document.QuerySelectorAll("ul.tags-list a.tags-link");
+ foreach (var tagEl in tagElements)
+ {
+ var tagText = tagEl.TextContent?.Trim();
+ if (!string.IsNullOrWhiteSpace(tagText) && !info.Tags.Contains(tagText))
+ {
+ info.Tags.Add(tagText);
+ }
+ }
+
+ // ダウンロード直リンク (MP4) の取得
+ var downloadAnchor = document.QuerySelector("div.block-details a[href*='/get_file/']");
+ if (downloadAnchor != null)
+ {
+ var rawDownloadHref = downloadAnchor.GetAttribute("href")?.Trim() ?? string.Empty;
+ if (!string.IsNullOrWhiteSpace(rawDownloadHref))
+ {
+ info.DownloadUrl = rawDownloadHref.StartsWith("http", StringComparison.OrdinalIgnoreCase)
+ ? rawDownloadHref
+ : $"{BaseUrl.TrimEnd('/')}/{rawDownloadHref.TrimStart('/')}";
+ info.DownloadLabel = downloadAnchor.TextContent?.Trim() ?? "MP4 動画ダウンロード";
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.AddLog($"[警告] 【85po】 詳細ページ取得スキップ ({videoUrl}): {ex.Message}");
+ }
+
+ // 高解像度プレビュー画像が未設定で、サムネイルが取得できている場合はプレビュー画像パスを自動推定
+ if (string.IsNullOrEmpty(info.PreviewImageUrl) && !string.IsNullOrEmpty(info.ThumbnailUrl))
+ {
+ // 例: https://www.85po.com/contents/videos_screenshots/37000/37405/320x180/1.jpg
+ // → https://www.85po.com/contents/videos_screenshots/37000/37405/preview.jpg
+ info.PreviewImageUrl = Regex.Replace(info.ThumbnailUrl, @"/\d+x\d+/\d+\.jpg$", "/preview.jpg");
+ }
+
+ return info;
+ }
+
+ ///
+ /// RSSフィードの description HTML からサムネイル画像および説明テキストを抽出します。
+ ///
+ /// RSSフィードの説明文HTML
+ /// 格納先オブジェクト
+ private static void ExtractFromFeedDescription(string feedDesc, VideoDetailInfo info)
+ {
+ if (string.IsNullOrWhiteSpace(feedDesc))
+ {
+ return;
+ }
+
+ try
+ {
+ var parser = new HtmlParser();
+ using var doc = parser.ParseDocument($"{feedDesc}");
+
+ var img = doc.QuerySelector("img");
+ var src = img?.GetAttribute("src")?.Trim();
+ if (!string.IsNullOrEmpty(src))
+ {
+ info.ThumbnailUrl = src;
+ }
+
+ var text = doc.Body?.TextContent?.Trim();
+ if (!string.IsNullOrWhiteSpace(text))
+ {
+ info.Description = text;
+ }
+ }
+ catch
+ {
+ // 解析エラー時はフォールバックとして正規表現による抽出を試行
+ var imgMatch = Regex.Match(feedDesc, @"
]*src=[""']([^""']+)[""']", RegexOptions.IgnoreCase);
+ if (imgMatch.Success)
+ {
+ info.ThumbnailUrl = imgMatch.Groups[1].Value.Trim();
+ }
+ }
+ }
+
+ ///
+ /// 記事の本文 HTML (Summary) を構築します。
+ /// WebImageViewer へのリンク、フォルダ名ワンクリックコピー枠、ダウンロードボタン等を配置します。
+ ///
+ /// 動画詳細情報
+ /// 日本時間の公開日時
+ /// 本文 HTML 文字列
+ private static string BuildSummaryHtml(VideoDetailInfo info, DateTimeOffset pubDate)
+ {
+ var sb = new StringBuilder();
+
+ // 1. フォーマット識別タグ(キャッシュ判定用)
+ sb.AppendLine($"");
+
+ // 2. Windows フォルダ名用タイトル(クリックで全選択)枠 (AGENTS.md 規則 4.2)
+ sb.AppendLine("");
+ sb.AppendLine("
📁 フォルダ名用タイトル(クリックで全選択)
");
+ sb.AppendLine($"
");
+ sb.AppendLine("
");
+
+ // 3. WebImageViewer への再生リンク & 85PO公式ページリンク
+ var viewerUrl = $"{WebImageViewerBaseUrl}{Uri.EscapeDataString(info.VideoUrl)}";
+ sb.AppendLine("");
+
+ // 4. ダウンロードリンク直リンク配置 (AGENTS.md 規則 5)
+ if (!string.IsNullOrEmpty(info.DownloadUrl))
+ {
+ var label = string.IsNullOrEmpty(info.DownloadLabel) ? "MP4 ダウンロード" : info.DownloadLabel;
+ sb.AppendLine("");
+ sb.AppendLine("
📥 ダウンロード
");
+ sb.AppendLine("
");
+ sb.AppendLine("
");
+ }
+
+ // 5. 日本時間表示 (AGENTS.md 規則 3.2)
+ sb.AppendLine("");
+ sb.AppendLine($" 📅 {pubDate:yyyy/MM/dd HH:mm:ss} (JST)");
+ if (!string.IsNullOrWhiteSpace(info.Duration))
+ {
+ sb.AppendLine($" ⏱ 再生時間: {WebUtility.HtmlEncode(info.Duration)}");
+ }
+ sb.AppendLine("
");
+
+ // 6. カバー画像 / プレビュー画像表示 (AGENTS.md 規則 6)
+ var displayImgUrl = !string.IsNullOrEmpty(info.PreviewImageUrl) ? info.PreviewImageUrl : info.ThumbnailUrl;
+ if (!string.IsNullOrEmpty(displayImgUrl))
+ {
+ sb.AppendLine("");
+ }
+
+ // 7. 説明文およびタグ
+ if (!string.IsNullOrWhiteSpace(info.Description))
+ {
+ sb.AppendLine("");
+ sb.AppendLine($" 説明: {WebUtility.HtmlEncode(info.Description)}");
+ sb.AppendLine("
");
+ }
+
+ if (info.Tags.Count > 0)
+ {
+ sb.AppendLine("");
+ sb.AppendLine($" タグ: {WebUtility.HtmlEncode(string.Join(", ", info.Tags))}");
+ sb.AppendLine("
");
+ }
+
+ return sb.ToString();
+ }
+
+ ///
+ /// タイトル文字列から Windows フォルダ名に使用できない禁止文字を全角に置換します。
+ ///
+ /// 元のタイトル文字列
+ /// 整形後のタイトル文字列
+ private static string CleanFileNameTitle(string rawTitle)
+ {
+ if (string.IsNullOrWhiteSpace(rawTitle))
+ {
+ return "タイトルなし";
+ }
+
+ var title = rawTitle.Trim();
+
+ // Windows 禁止文字 \ / : * ? " < > | を全角文字へ置換
+ title = title
+ .Replace('\\', '¥')
+ .Replace('/', '/')
+ .Replace(':', ':')
+ .Replace('*', '*')
+ .Replace('?', '?')
+ .Replace('"', '”')
+ .Replace('<', '<')
+ .Replace('>', '>')
+ .Replace('|', '|');
+
+ // 連続空白を1つに統合
+ title = Regex.Replace(title, @"\s+", " ").Trim();
+
+ return title;
+ }
+
+ ///
+ /// DateTimeOffset を正確な日本時間 (JST = UTC+9) に変換します。
+ ///
+ /// 変換元の DateTimeOffset
+ /// 日本時間 (UTC+9) の DateTimeOffset
+ private static DateTimeOffset ConvertToJst(DateTimeOffset dto)
+ {
+ if (dto == default)
+ {
+ return DateTimeOffset.Now;
+ }
+
+ return dto.ToOffset(TimeSpan.FromHours(9));
+ }
+
+ ///
+ /// 既存の RSS フィードファイルから記事エントリを読み込みます。
+ ///
+ /// ファイル名
+ /// ドメインサブディレクトリ名
+ /// 記事URLおよびGUIDをキーとする辞書
+ private static Dictionary LoadExistingEntries(string fileName, string addDir = "")
+ {
+ var existingEntries = new Dictionary(StringComparer.OrdinalIgnoreCase);
+
+ try
+ {
+ string xmlPath = CmnUtil.GetExportXmlPath(fileName, addDir);
+ if (!File.Exists(xmlPath) && !string.IsNullOrEmpty(addDir))
+ {
+ xmlPath = CmnUtil.GetExportXmlPath(fileName);
+ }
+
+ if (!File.Exists(xmlPath))
+ {
+ return existingEntries;
+ }
+
+ using var reader = XmlReader.Create(xmlPath);
+ var existingFeed = SyndicationFeed.Load(reader);
+ if (existingFeed?.Items != null)
+ {
+ foreach (var item in existingFeed.Items)
+ {
+ var linkUrl = item.Links.FirstOrDefault()?.Uri?.AbsoluteUri;
+ var guid = item.Id;
+
+ var entry = new ExistingFeedEntry
+ {
+ Title = item.Title?.Text ?? string.Empty,
+ SummaryHtml = item.Summary?.Text ?? string.Empty,
+ PublishDate = item.PublishDate,
+ LastUpdatedTime = item.LastUpdatedTime
+ };
+
+ foreach (var cat in item.Categories)
+ {
+ if (!string.IsNullOrEmpty(cat.Name))
+ {
+ entry.Categories.Add(cat.Name);
+ }
+ }
+
+ if (!string.IsNullOrEmpty(linkUrl) && !existingEntries.ContainsKey(linkUrl))
+ {
+ existingEntries[linkUrl] = entry;
+ }
+
+ if (!string.IsNullOrEmpty(guid) && !existingEntries.ContainsKey(guid))
+ {
+ existingEntries[guid] = entry;
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.AddLog($"[警告] 【85po】 既存フィード読み込みスキップ: {ex.Message}");
+ }
+
+ return existingEntries;
+ }
+
+ #endregion
+}
diff --git a/rss-generator/Program.cs b/rss-generator/Program.cs
index f228236..5f71414 100644
--- a/rss-generator/Program.cs
+++ b/rss-generator/Program.cs
@@ -16,7 +16,9 @@ using rss_generator.Class.Mangalear;
using rss_generator.Class.MissAV;
using rss_generator.Class.MissAV123;
using rss_generator.Class.Momonga;
+using rss_generator.Class.OtomiGames;
using rss_generator.Class.Pixiv;
+using rss_generator.Class.Po85;
using rss_generator.Class.Ryuugames;
using rss_generator.Class.Skebetter;
using rss_generator.Class.SpankBang;
@@ -99,18 +101,22 @@ while (true)
var nonFlareActions = new List<(string Name, Func Action)>();
#if DEBUG
+ nonFlareActions.Add(("85po", client => po85.CreateRSSAsync(client)));
nonFlareActions.Add(("YouTube", client => YouTubeFeedManager.CreateRSSAsync(client)));
nonFlareActions.Add(("ryuugames", client => ryuugames.CreateRSSAsync(client)));
nonFlareActions.Add(("japaneseavi", client => japaneseavi.CreateRSSAsync(client)));
nonFlareActions.Add(("jpfiles", client => jpfiles.CreateRSSAsync(client)));
+ nonFlareActions.Add(("otomigames", client => otomigames.CreateRSSAsync(client)));
#else
// ※ movie.eroterest.net は取得処理停止のため除外
+ nonFlareActions.Add(("85po", client => po85.CreateRSSAsync(client)));
nonFlareActions.Add(("ryuugames", client => ryuugames.CreateRSSAsync(client)));
nonFlareActions.Add(("YouTube", client => YouTubeFeedManager.CreateRSSAsync(client)));
nonFlareActions.Add(("X (Twitter)", client => x_list.CreateRSSAsync(client)));
nonFlareActions.Add(("kimochiinfo", client => kimochiinfo.CreateRSSAsync(client)));
nonFlareActions.Add(("japaneseavi", client => japaneseavi.CreateRSSAsync(client)));
nonFlareActions.Add(("jpfiles", client => jpfiles.CreateRSSAsync(client)));
+ nonFlareActions.Add(("otomigames", client => otomigames.CreateRSSAsync(client)));
nonFlareActions.Add(("ci_en", client => ci_en.CreateRSSAsync(client)));
nonFlareActions.Add(("javtwi", client => javtwi.CreateRSSAsync(client)));
nonFlareActions.Add(("mangalear", client => mangalear.CreateRSSAsync(client)));