規則制定・修正: ドメイン毎の出力先フォルダ分離規則の制定およびRyuugamesの対応

- プロジェクト固有規則ファイル AGENTS.md を作成し、ドメイン毎のサブフォルダ作成・出力規則を明文化
- ryuugames.cs の出力先およびキャッシュ読込先を ryuugames.com サブディレクトリに変更
- C:\feeds\ryuugames.com\ 配下への正常出力を確認
This commit is contained in:
armonica committed 2026-11-11 13:07:10 +09:00
1 parent e4aa86589c
commit 9b5953fbca
2 files changed
+59 -6

No files matched your search

+36
View File
@@ -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ファイルを探索・読み込んでください。
+23 -6
View File
@@ -44,6 +44,15 @@ internal class ryuugames
#endregion
#region □定数(Private)
/// <summary>
/// 出力先ドメインサブフォルダ名
/// </summary>
private const string DomainDir = "ryuugames.com";
#endregion
#region □クラス(Private)
/// <summary>
@@ -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
/// <summary>
/// 既存の XML ファイルから過去のエントリ情報を読み込み、URLおよびGUIDをキーとする辞書を返します。
/// ドメインサブフォルダ(addDir)および旧ルート直下の両方を探索して互換性を維持します。
/// </summary>
/// <param name="fileName">XML ファイル名</param>
/// <param name="addDir">出力先ドメインサブディレクトリ名</param>
/// <returns>既存エントリの辞書</returns>
private static Dictionary<string, ExistingFeedEntry> LoadExistingEntries(string fileName)
private static Dictionary<string, ExistingFeedEntry> LoadExistingEntries(string fileName, string addDir = "")
{
var existingEntries = new Dictionary<string, ExistingFeedEntry>(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;