プログラムの設置先変更
This commit is contained in:
1 parent
63188d87f4
commit
ef730787dd
7 files changed
+161
-59
No files matched your search
@@ -252,8 +252,8 @@ public class CmnUtil
|
||||
return null;
|
||||
}
|
||||
|
||||
// 15MB 以上の巨大画像は安全のためスキップ
|
||||
if (response.Content.Headers.ContentLength.HasValue && response.Content.Headers.ContentLength.Value > 15 * 1024 * 1024)
|
||||
// 2MB 以上の画像はメモリ保護のためスキップ(元のURLを参照させる)
|
||||
if (response.Content.Headers.ContentLength.HasValue && response.Content.Headers.ContentLength.Value > 2 * 1024 * 1024)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -281,7 +281,7 @@ public class CmnUtil
|
||||
/// SyndicationFeed に含まれる全記事(24時間フィルタ適用後)の HTML 本文から画像 URL を抽出し、
|
||||
/// 並列ダウンロードして Base64 形式(Data URI)に置換します。
|
||||
/// </summary>
|
||||
public static async Task EmbedImagesAsBase64InFeedAsync(SyndicationFeed feed, HttpClient client, int maxParallel = 8)
|
||||
public static async Task EmbedImagesAsBase64InFeedAsync(SyndicationFeed feed, HttpClient client, int maxParallel = 2)
|
||||
{
|
||||
if (feed.Items == null) return;
|
||||
|
||||
@@ -321,7 +321,7 @@ public class CmnUtil
|
||||
|
||||
if (targetUrls.Count == 0) return;
|
||||
|
||||
// 2. 並列ダウンロードして Base64 辞書を構築
|
||||
// 2. 並列ダウンロードして Base64 辞書を構築(メモリ節約のため同時並行数は2に制御)
|
||||
var cacheMap = new ConcurrentDictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
using var semaphore = new SemaphoreSlim(maxParallel);
|
||||
|
||||
@@ -377,6 +377,10 @@ public class CmnUtil
|
||||
|
||||
int distinctSuccess = targetUrls.Keys.Count(k => cacheMap.ContainsKey(k));
|
||||
LogManager.AddLog($"[情報] [CmnUtil] 画像の Base64 変換完了: {distinctSuccess}/{targetUrls.Count} 件成功 (記事数: {itemsList.Count})");
|
||||
|
||||
// 使用済みメモリの即時解放
|
||||
cacheMap.Clear();
|
||||
targetUrls.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -9,19 +9,30 @@ internal class x_list
|
||||
private const string QUERY2 = "showEmojiForRetweetAndReply=1?filter_title=%5E%28🔁%7CRT%29";
|
||||
public static async Task CreateRSSAsync(HttpClient client)
|
||||
{
|
||||
var tasks = new List<Task>()
|
||||
// メモリ消費を最小化するため、各リストを1つずつ順次処理
|
||||
var targets = new (string ListId, string FileName)[]
|
||||
{
|
||||
CreateSub1(client, "2076742238231818243", "granbluefantasy")
|
||||
, CreateSub1(client, "1695011723005280535", "AI")
|
||||
, CreateSub1(client, "1573473287333560321", "R18")
|
||||
, CreateSub1(client, "2070669317667217577", "VR")
|
||||
, CreateSub1(client, "1573916143969976320", "VTuber")
|
||||
, CreateSub1(client, "2070673943057539507", "AnimeReal")
|
||||
, CreateSub1(client, "1599409403743961088", "AnimeOther")
|
||||
, CreateSub1(client, "2070670309846655252", "NormalIllust")
|
||||
("2076742238231818243", "granbluefantasy"),
|
||||
("1695011723005280535", "AI"),
|
||||
("1573473287333560321", "R18"),
|
||||
("2070669317667217577", "VR"),
|
||||
("1573916143969976320", "VTuber"),
|
||||
("2070673943057539507", "AnimeReal"),
|
||||
("1599409403743961088", "AnimeOther"),
|
||||
("2070670309846655252", "NormalIllust")
|
||||
};
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
foreach (var (listId, fileName) in targets)
|
||||
{
|
||||
try
|
||||
{
|
||||
await CreateSub1(client, listId, fileName);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.AddLog($"[エラー] Xリスト生成失敗 ({fileName}): {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static async Task CreateSub1(HttpClient client, string listId, string fileName)
|
||||
|
||||
@@ -29,8 +29,8 @@ public static class YouTubeFeedManager
|
||||
var allVideoItems = new List<YouTubeVideoItem>();
|
||||
var allShortsItems = new List<YouTubeVideoItem>();
|
||||
|
||||
// YouTubeからのレート制限を防ぐため、同時並行数を安全な値(6)に制御
|
||||
using var semaphore = new System.Threading.SemaphoreSlim(6);
|
||||
// メモリ消費とレート制限を抑えるため、同時並行数を2に制御
|
||||
using var semaphore = new System.Threading.SemaphoreSlim(2);
|
||||
|
||||
var channelTasks = YouTubeConfig.Channels.Select(async channel =>
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user