feat: implement RSS generation modules for X lists, YouTube playlists, and CI-EN content

This commit is contained in:
armonica committed 2026-09-06 03:37:29 +09:00
1 parent 46808590c6
commit 44864cde19
7 files changed
+19 -20

No files matched your search

+3 -3
View File
@@ -384,14 +384,14 @@ public class CmnUtil
} }
/// <summary> /// <summary>
/// Feed を非同期でファイルに出力します。画像 Base64 変換が有効な場合は自動で変換を行います。 /// Feed を非同期でファイルに出力します。画像 Base64 変換が有効な場合は自動で変換を行います(Pixiv のみ有効)。
/// </summary> /// </summary>
/// <param name="fileName">出力先ファイル名</param> /// <param name="fileName">出力先ファイル名</param>
/// <param name="feed">SyndicationFeed</param> /// <param name="feed">SyndicationFeed</param>
/// <param name="client">画像ダウンロード用 HttpClient</param> /// <param name="client">画像ダウンロード用 HttpClient</param>
/// <param name="addDir">サブディレクトリ</param> /// <param name="addDir">サブディレクトリ</param>
/// <param name="embedBase64">画像を Base64 変換するかどうか(false の場合は通常の画像リンクを維持)</param> /// <param name="embedBase64">画像を Base64 変換するかどうか(Pixiv 以外は false)</param>
public static async Task ExportXMLFileAsync(string fileName, SyndicationFeed feed, HttpClient? client = null, string addDir = "", bool embedBase64 = true) public static async Task ExportXMLFileAsync(string fileName, SyndicationFeed feed, HttpClient? client = null, string addDir = "", bool embedBase64 = false)
{ {
// 24時間以上前の古い記事を除外 // 24時間以上前の古い記事を除外
if (feed.Items != null) if (feed.Items != null)
@@ -587,7 +587,8 @@ internal static class pixiv_common
items items
); );
await CmnUtil.ExportXMLFileAsync(fileName, feed, client); // Pixiv は Base64 画像埋め込みを有効にして出力する
await CmnUtil.ExportXMLFileAsync(fileName, feed, client, embedBase64: true);
} }
/// <summary> /// <summary>
+2 -1
View File
@@ -90,7 +90,8 @@ internal class x_list
simplifiedItems simplifiedItems
); );
await CmnUtil.ExportXMLFileAsync($"{fileName}.xml", mergedFeed, client); // X (Twitter) は画像リンクを Base64 変換せず、通常の画像リンクとして出力する
await CmnUtil.ExportXMLFileAsync($"{fileName}.xml", mergedFeed, client, embedBase64: false);
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -354,7 +354,8 @@ public static class YouTubeFeedManager
distinctItems distinctItems
); );
await CmnUtil.ExportXMLFileAsync(fileName, feed, client, YouTubeConfig.OutputSubDir); // YouTube は画像リンクを Base64 変換せず、通常の画像リンクとして出力する
await CmnUtil.ExportXMLFileAsync(fileName, feed, client, YouTubeConfig.OutputSubDir, embedBase64: false);
} }
/// <summary> /// <summary>
+2 -1
View File
@@ -50,7 +50,8 @@ internal class Youtube
items items
); );
await CmnUtil.ExportXMLFileAsync($"{fileName}.xml", mergedFeed, client, "youtube"); // YouTube は画像リンクを Base64 変換せず、通常の画像リンクとして出力する
await CmnUtil.ExportXMLFileAsync($"{fileName}.xml", mergedFeed, client, "youtube", embedBase64: false);
} }
} }
catch (Exception ex) catch (Exception ex)
+2 -1
View File
@@ -183,7 +183,8 @@ internal class ci_en
} }
feed.Items = items; feed.Items = items;
await CmnUtil.ExportXMLFileAsync("ci_en.xml", feed, client); // ci_en は画像リンクを Base64 変換せず、通常の画像リンクとして出力する
await CmnUtil.ExportXMLFileAsync("ci_en.xml", feed, client, embedBase64: false);
} }
catch (Exception ex) catch (Exception ex)
{ {
+6 -12
View File
@@ -39,13 +39,11 @@ var httpClientFactory = serviceProvider.GetRequiredService<IHttpClientFactory>()
LogManager.AddLog($"[情報] rss-generatorの起動"); LogManager.AddLog($"[情報] rss-generatorの起動");
var isFirst = true; var isFirst = true;
// 実行したい指定の「分」を配列で設定(例:毎時 0分 と 30分) // 生成完了後の待機時間(固定で30分)
int[] targetMinutes = new int[] { 0, 30 }; TimeSpan waitInterval = TimeSpan.FromMinutes(30);
while (true) while (true)
{ {
var nowDate = DateTime.Now;
if (isFirst) if (isFirst)
{ {
isFirst = false; isFirst = false;
@@ -54,15 +52,11 @@ while (true)
{ {
#if DEBUG #if DEBUG
#else #else
// 次に実行すべき指定時刻を取得 var nextRunTime = DateTime.Now.Add(waitInterval);
var nextRunTime = CmnUtil.GetNextTargetTime(nowDate, targetMinutes); LogManager.AddLog($"[情報] 次回実行予定: {nextRunTime:HH:mm:ss} (固定で30分待機)");
// 次の時刻までの待ち時間(TimeSpan)を計算
TimeSpan delay = nextRunTime - nowDate;
LogManager.AddLog($"[情報] 次回実行予定: {nextRunTime:HH:mm:ss} (あと {delay.TotalMinutes:F1} 分待機)"); // 生成完了後、固定で30分待機(非同期スリープ)
await Task.Delay(waitInterval);
// 指定時刻まで完全に処理を停止(非同期スリープ)
await Task.Delay(delay);
#endif #endif
} }