diff --git a/AGENTS.md b/AGENTS.md new file mode 100644 index 0000000..be5a33c --- /dev/null +++ b/AGENTS.md @@ -0,0 +1,36 @@ +# プロジェクト固有規則(rss-generator) + +本プロジェクト(`rss-generator`)におけるコード記述およびフィード生成処理では、以下のプロジェクト固有規則を厳格に遵守してください。 + +--- + +## 1. ドメイン毎の出力先フォルダ分離規則(必須) + +RSSフィード(XMLファイル)を出力する際は、`output` ディレクトリ直下に直接配置せず、**必ず対象サイトのドメイン名等に応じたサブディレクトリを作成し、その中にXMLファイルを出力してください**。 + +### 1.1 命名規則および具体例 +- 対象サイトのドメイン名(FQDN)またはサービス識別子をサブディレクトリ名として使用します。 + - `ryuugames.com` → `output/ryuugames.com/ryuugames.xml` + - `pixiv.net` → `output/pixiv.net/...` + - `x.com` → `output/x.com/...` + - `e-hentai.org` → `output/e-hentai.org/...` + - `momon-ga.com` → `output/momon-ga.com/...` + - `skebetter.com` → `output/skebetter.com/...` + - `danbooru` → `output/danbooru/...` + - `youtube` → `output/youtube/...` + +### 1.2 実装方法(C#) +- フィード出力メソッド `CmnUtil.ExportXMLFileAsync` を呼び出す際は、必ず `addDir` 引数に対象ドメインサブディレクトリ名を指定してください。 + ```csharp + // 例: ryuugames.com の場合 + private const string DomainDir = "ryuugames.com"; + + await CmnUtil.ExportXMLFileAsync( + fileName, + feed, + client, + addDir: DomainDir, + embedBase64: false, + filter24Hours: false); + ``` +- 既存XMLファイルを読み込むキャッシュ処理(`LoadExistingEntries` 等)を実装する場合も、`CmnUtil.GetExportXmlPath(fileName, addDir)` を使用して該当ドメインサブフォルダ内のXMLファイルを探索・読み込んでください。 diff --git a/rss-generator/Class/Ryuugames/ryuugames.cs b/rss-generator/Class/Ryuugames/ryuugames.cs index 6fafb98..f4f80bc 100644 --- a/rss-generator/Class/Ryuugames/ryuugames.cs +++ b/rss-generator/Class/Ryuugames/ryuugames.cs @@ -44,6 +44,15 @@ internal class ryuugames #endregion + #region □定数(Private) + + /// + /// 出力先ドメインサブフォルダ名 + /// + private const string DomainDir = "ryuugames.com"; + + #endregion + #region □クラス(Private) /// @@ -183,7 +192,7 @@ internal class ryuugames try { // 既存フィードからキャッシュ情報を読み込み(未更新記事の不要な未読化防止および高速化) - var existingEntries = LoadExistingEntries(feedFileNameAll); + var existingEntries = LoadExistingEntries(feedFileNameAll, DomainDir); // 1. 記事リンクの収集(公式フィード 2ページ分 + 日本語カテゴリ一覧 2ページ分) var articleLinks = await CollectArticleLinksAsync(client); @@ -295,9 +304,9 @@ internal class ryuugames feedTrans.Items = transItems; // 3つのフィードを出力(画像は直リンク、filter24Hours は未読維持のため false) - await CmnUtil.ExportXMLFileAsync(feedFileNameAll, feedAll, client, embedBase64: false, filter24Hours: false); - await CmnUtil.ExportXMLFileAsync(feedFileNameJp, feedJp, client, embedBase64: false, filter24Hours: false); - await CmnUtil.ExportXMLFileAsync(feedFileNameTrans, feedTrans, client, embedBase64: false, filter24Hours: false); + await CmnUtil.ExportXMLFileAsync(feedFileNameAll, feedAll, client, addDir: DomainDir, embedBase64: false, filter24Hours: false); + await CmnUtil.ExportXMLFileAsync(feedFileNameJp, feedJp, client, addDir: DomainDir, embedBase64: false, filter24Hours: false); + await CmnUtil.ExportXMLFileAsync(feedFileNameTrans, feedTrans, client, addDir: DomainDir, embedBase64: false, filter24Hours: false); LogManager.AddLog($"[情報] 【ryuugames】 出力完了 - 全件: {allItems.Count}件, 日本語版: {jpItems.Count}件, 翻訳版: {transItems.Count}件"); } @@ -712,15 +721,23 @@ internal class ryuugames /// /// 既存の XML ファイルから過去のエントリ情報を読み込み、URLおよびGUIDをキーとする辞書を返します。 + /// ドメインサブフォルダ(addDir)および旧ルート直下の両方を探索して互換性を維持します。 /// /// XML ファイル名 + /// 出力先ドメインサブディレクトリ名 /// 既存エントリの辞書 - private static Dictionary LoadExistingEntries(string fileName) + private static Dictionary LoadExistingEntries(string fileName, string addDir = "") { var existingEntries = new Dictionary(StringComparer.OrdinalIgnoreCase); try { - string xmlPath = CmnUtil.GetExportXmlPath(fileName); + // まずドメインサブフォルダ内のXMLを探索し、存在しなければルート直下をフォールバック探索 + string xmlPath = CmnUtil.GetExportXmlPath(fileName, addDir); + if (!File.Exists(xmlPath) && !string.IsNullOrEmpty(addDir)) + { + xmlPath = CmnUtil.GetExportXmlPath(fileName); + } + if (!File.Exists(xmlPath)) { return existingEntries;