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