();
+
+ foreach (var illust in illusts)
+ {
+ try
+ {
+ var itemUrl = $"https://www.pixiv.net/artworks/{illust.Id}";
+ var authorUrl = $"https://www.pixiv.net/users/{illust.UserId}";
+
+ var item = new SyndicationItem
+ {
+ Title = new TextSyndicationContent(string.IsNullOrWhiteSpace(illust.Title) ? $"作品 #{illust.Id}" : illust.Title),
+ Id = CmnUtil.CreateGuid($"pixiv_{illust.Id}")
+ };
+
+ // 作品ページへのリンク
+ if (Uri.TryCreate(itemUrl, UriKind.Absolute, out var uri))
+ {
+ item.Links.Add(new SyndicationLink(uri));
+ }
+
+ // 公開・更新日時
+ var parsedDate = DateTimeOffset.Now;
+ if (!string.IsNullOrWhiteSpace(illust.CreateDate) && DateTimeOffset.TryParse(illust.CreateDate, CultureInfo.InvariantCulture, DateTimeStyles.None, out var cDate))
+ {
+ parsedDate = cDate;
+ }
+ else if (!string.IsNullOrWhiteSpace(illust.UpdateDate) && DateTimeOffset.TryParse(illust.UpdateDate, CultureInfo.InvariantCulture, DateTimeStyles.None, out var uDate))
+ {
+ parsedDate = uDate;
+ }
+ item.PublishDate = parsedDate;
+ item.LastUpdatedTime = parsedDate;
+
+ // 作者情報
+ if (!string.IsNullOrWhiteSpace(illust.UserName))
+ {
+ item.Authors.Add(new SyndicationPerson { Name = illust.UserName, Uri = authorUrl });
+ }
+
+ // タグをカテゴリとして追加
+ if (illust.Tags != null)
+ {
+ foreach (var tag in illust.Tags)
+ {
+ if (!string.IsNullOrWhiteSpace(tag))
+ {
+ item.Categories.Add(new SyndicationCategory(tag));
+ }
+ }
+ }
+
+ // 年齢制限タグの補完
+ if (illust.XRestrict == 1 && !item.Categories.Any(c => c.Name.Equals("R-18", StringComparison.OrdinalIgnoreCase)))
+ {
+ item.Categories.Add(new SyndicationCategory("R-18"));
+ }
+ else if (illust.XRestrict == 2 && !item.Categories.Any(c => c.Name.Equals("R-18G", StringComparison.OrdinalIgnoreCase)))
+ {
+ item.Categories.Add(new SyndicationCategory("R-18G"));
+ }
+
+ // AI 生成タグの補完 (aiType: 2 は AI生成作品)
+ if (illust.AiType == 2 && !item.Categories.Any(c => c.Name.Contains("AI")))
+ {
+ item.Categories.Add(new SyndicationCategory("AI生成"));
+ }
+
+ // 本文 HTML の生成
+ var body = new StringBuilder();
+
+ // 画像 URL の決定(プロキシ適用)
+ var displayImageUrl = illust.Url;
+ if (UseImageProxy && !string.IsNullOrWhiteSpace(displayImageUrl))
+ {
+ displayImageUrl = displayImageUrl.Replace("i.pximg.net", ImageProxyHost);
+ }
+
+ if (!string.IsNullOrWhiteSpace(displayImageUrl))
+ {
+ body.Append($"");
+ }
+
+ // 作者・作品メタ情報
+ body.Append($"");
+ body.Append($"作者: {WebUtility.HtmlEncode(illust.UserName)}");
+ if (illust.PageCount > 1)
+ {
+ body.Append($" | ページ数: {illust.PageCount}P");
+ }
+ if (illust.AiType == 2)
+ {
+ body.Append($" | [AI生成]");
+ }
+ if (illust.XRestrict >= 1)
+ {
+ body.Append($" | [R-18]");
+ }
+ body.Append($"
");
+
+ // キャプション / 説明文
+ if (!string.IsNullOrWhiteSpace(illust.Description))
+ {
+ body.Append($"");
+ body.Append(illust.Description);
+ body.Append($"
");
+ }
+
+ // タグ一覧
+ if (illust.Tags != null && illust.Tags.Count > 0)
+ {
+ body.Append($"");
+ body.Append($"タグ: {string.Join(" ", illust.Tags.Select(t => $"#{WebUtility.HtmlEncode(t)}"))}");
+ body.Append($"
");
+ }
+
+ item.Summary = new TextSyndicationContent(body.ToString(), TextSyndicationContentKind.Html);
+ items.Add(item);
+ }
+ catch (Exception ex)
+ {
+ AddLog($"[エラー] [pixiv_common] SyndicationItem 変換中にエラー (ID={illust.Id}): {ex.Message}");
+ }
+ }
+
+ return items;
+ }
+
+ ///
+ /// SyndicationFeed を作成し、指定されたファイル名の XML として出力します。
+ ///
+ /// フィードのタイトル
+ /// フィードの説明
+ /// フィードのWebサイトリンク
+ /// 出力XMLファイル名 (例: pixiv_r18.xml)
+ /// フィードアイテムリスト
+ public static void CreateAndExportFeed(string feedTitle, string feedDescription, string feedLink, string fileName, List items)
+ {
+ var feed = new SyndicationFeed(
+ feedTitle,
+ feedDescription,
+ new Uri(feedLink),
+ items
+ );
+
+ CmnUtil.ExportXMLFile(fileName, feed);
+ AddLog($"[情報] {fileName} を正常に出力しました (作品数: {items.Count})");
+ }
+
+ #region Pixiv API レスポンス用データモデル
+
+ public class PixivFollowLatestResponse
+ {
+ [JsonPropertyName("error")]
+ public bool Error { get; set; }
+
+ [JsonPropertyName("message")]
+ public string Message { get; set; } = string.Empty;
+
+ [JsonPropertyName("body")]
+ public PixivFollowLatestBody? Body { get; set; }
+ }
+
+ public class PixivFollowLatestBody
+ {
+ [JsonPropertyName("page")]
+ public PixivPageInfo? Page { get; set; }
+
+ [JsonPropertyName("thumbnails")]
+ public PixivThumbnails? Thumbnails { get; set; }
+ }
+
+ public class PixivPageInfo
+ {
+ [JsonPropertyName("ids")]
+ public List? Ids { get; set; }
+
+ [JsonPropertyName("isLastPage")]
+ public bool IsLastPage { get; set; }
+ }
+
+ public class PixivThumbnails
+ {
+ [JsonPropertyName("illust")]
+ public List? Illust { get; set; }
+ }
+
+ public class PixivIllustItem
+ {
+ [JsonPropertyName("id")]
+ public string Id { get; set; } = string.Empty;
+
+ [JsonPropertyName("title")]
+ public string Title { get; set; } = string.Empty;
+
+ [JsonPropertyName("illustType")]
+ public int IllustType { get; set; }
+
+ ///
+ /// 年齢制限 (0: 全年齢, 1: R-18, 2: R-18G)
+ ///
+ [JsonPropertyName("xRestrict")]
+ public int XRestrict { get; set; }
+
+ [JsonPropertyName("restrict")]
+ public int Restrict { get; set; }
+
+ [JsonPropertyName("sl")]
+ public int Sl { get; set; }
+
+ [JsonPropertyName("url")]
+ public string Url { get; set; } = string.Empty;
+
+ [JsonPropertyName("description")]
+ public string Description { get; set; } = string.Empty;
+
+ [JsonPropertyName("tags")]
+ public List Tags { get; set; } = new();
+
+ [JsonPropertyName("userId")]
+ public string UserId { get; set; } = string.Empty;
+
+ [JsonPropertyName("userName")]
+ public string UserName { get; set; } = string.Empty;
+
+ [JsonPropertyName("width")]
+ public int Width { get; set; }
+
+ [JsonPropertyName("height")]
+ public int Height { get; set; }
+
+ [JsonPropertyName("pageCount")]
+ public int PageCount { get; set; }
+
+ [JsonPropertyName("bookmarkCount")]
+ public int BookmarkCount { get; set; }
+
+ [JsonPropertyName("createDate")]
+ public string CreateDate { get; set; } = string.Empty;
+
+ [JsonPropertyName("updateDate")]
+ public string UpdateDate { get; set; } = string.Empty;
+
+ ///
+ /// AI 生成タイプ (1: 通常, 2: AI生成作品)
+ ///
+ [JsonPropertyName("aiType")]
+ public int AiType { get; set; }
+ }
+
+ ///
+ /// 数値や文字列など様々な型のJSONトークンを安全に string として読み込むコンバータ
+ ///
+ public class FlexibleStringConverter : JsonConverter
+ {
+ public override string? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
+ {
+ return reader.TokenType switch
+ {
+ JsonTokenType.String => reader.GetString(),
+ JsonTokenType.Number => reader.TryGetInt64(out long l) ? l.ToString() : reader.GetDouble().ToString(CultureInfo.InvariantCulture),
+ JsonTokenType.True => "true",
+ JsonTokenType.False => "false",
+ JsonTokenType.Null => null,
+ _ => reader.GetString()
+ };
+ }
+
+ public override void Write(Utf8JsonWriter writer, string value, JsonSerializerOptions options)
+ {
+ writer.WriteStringValue(value);
+ }
+ }
+
+ #endregion
+}
diff --git a/rss-generator/Class/RSS/Pixiv/pixiv_non_r18.cs b/rss-generator/Class/RSS/Pixiv/pixiv_non_r18.cs
new file mode 100644
index 0000000..4dbf993
--- /dev/null
+++ b/rss-generator/Class/RSS/Pixiv/pixiv_non_r18.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Threading.Tasks;
+using static rss_generator.Class.LogManager;
+
+namespace rss_generator.Class.RSS.Pixiv;
+
+///
+/// Pixiv のフォロー中ユーザーの最新全年齢(非R-18)作品フィード (pixiv_non_r18.xml) を生成するクラス
+///
+internal class pixiv_non_r18
+{
+ private const string FEED_TITLE = "Pixiv (Follow General)";
+ private const string FEED_DESCRIPTION = "Pixiv のフォロー中ユーザーによる最新全年齢作品フィード";
+ private const string FEED_LINK = "https://www.pixiv.net/bookmark_new_illust.php";
+ private const string XML_FILE_NAME = "pixiv_non_r18.xml";
+
+ ///
+ /// Pixiv のフォロー新着から全年齢作品を取得し、pixiv_non_r18.xml を生成します。
+ ///
+ /// HttpClient インスタンス
+ public static async Task CreateRSSAsync(HttpClient client)
+ {
+ try
+ {
+ // mode="all" でフォロー新着作品を取得
+ var illusts = await pixiv_common.FetchFollowLatestIllustsAsync(client, mode: "all", maxPages: pixiv_common.MaxPagesPerRun);
+
+ // 全年齢作品のみ (xRestrict == 0) を抽出
+ var generalIllusts = illusts.Where(x => x.XRestrict == 0).ToList();
+
+ // SyndicationItem のリストに変換
+ var items = pixiv_common.ConvertToSyndicationItems(generalIllusts);
+
+ // フィード作成と XML 出力
+ pixiv_common.CreateAndExportFeed(
+ FEED_TITLE,
+ FEED_DESCRIPTION,
+ FEED_LINK,
+ XML_FILE_NAME,
+ items
+ );
+ }
+ catch (Exception ex)
+ {
+ AddLog($"[エラー] [pixiv_non_r18]: {ex.Message}");
+ CmnUtil.PrintCallStackToEvent(ex);
+ }
+ }
+}
diff --git a/rss-generator/Class/RSS/Pixiv/pixiv_r18.cs b/rss-generator/Class/RSS/Pixiv/pixiv_r18.cs
new file mode 100644
index 0000000..9cecce1
--- /dev/null
+++ b/rss-generator/Class/RSS/Pixiv/pixiv_r18.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Threading.Tasks;
+using static rss_generator.Class.LogManager;
+
+namespace rss_generator.Class.RSS.Pixiv;
+
+///
+/// Pixiv のフォロー中ユーザーの最新 R-18 作品フィード (pixiv_r18.xml) を生成するクラス
+///
+internal class pixiv_r18
+{
+ private const string FEED_TITLE = "Pixiv (Follow R-18)";
+ private const string FEED_DESCRIPTION = "Pixiv のフォロー中ユーザーによる最新 R-18 作品フィード";
+ private const string FEED_LINK = "https://www.pixiv.net/bookmark_new_illust_r18.php";
+ private const string XML_FILE_NAME = "pixiv_r18.xml";
+
+ ///
+ /// Pixiv のフォロー新着から R-18 作品を取得し、pixiv_r18.xml を生成します。
+ ///
+ /// HttpClient インスタンス
+ public static async Task CreateRSSAsync(HttpClient client)
+ {
+ try
+ {
+ // mode="r18" でフォロー新着作品を取得
+ var illusts = await pixiv_common.FetchFollowLatestIllustsAsync(client, mode: "r18", maxPages: pixiv_common.MaxPagesPerRun);
+
+ // 安全のため R-18 以上の作品 (xRestrict >= 1) のみ抽出
+ var r18Illusts = illusts.Where(x => x.XRestrict >= 1).ToList();
+
+ // SyndicationItem のリストに変換
+ var items = pixiv_common.ConvertToSyndicationItems(r18Illusts);
+
+ // フィード作成と XML 出力
+ pixiv_common.CreateAndExportFeed(
+ FEED_TITLE,
+ FEED_DESCRIPTION,
+ FEED_LINK,
+ XML_FILE_NAME,
+ items
+ );
+ }
+ catch (Exception ex)
+ {
+ AddLog($"[エラー] [pixiv_r18]: {ex.Message}");
+ CmnUtil.PrintCallStackToEvent(ex);
+ }
+ }
+}
diff --git a/rss-generator/Program.cs b/rss-generator/Program.cs
index 9b86c54..64b9377 100644
--- a/rss-generator/Program.cs
+++ b/rss-generator/Program.cs
@@ -3,6 +3,7 @@ using rss_generator.Class;
using rss_generator.Class.RSS;
using rss_generator.Class.RSS.e_hentai;
using rss_generator.Class.RSS.hitomi_la;
+using rss_generator.Class.RSS.Pixiv;
using rss_generator.Class.RSS.YouTube;
using System.Diagnostics;
@@ -79,7 +80,9 @@ while (true)
tasks.Add(momonga_magazine.CreateRSSAsync(client));
}
#if DEBUG
- tasks.Add(aurahentai.CreateRSSAsync(client));
+ //tasks.Add(aurahentai.CreateRSSAsync(client));
+ tasks.Add(pixiv_r18.CreateRSSAsync(client));
+ tasks.Add(pixiv_non_r18.CreateRSSAsync(client));
//tasks.Add(YouTubeFeedManager.CreateRSSAsync(client));
//tasks.Add(momonga_fanzine.CreateRSSAsync(client));
//tasks.Add(momonga_magazine.CreateRSSAsync(client));
@@ -101,6 +104,8 @@ while (true)
tasks.Add(mangalear.CreateRSSAsync(client));
tasks.Add(e_hentai_ai.CreateRSSAsync(client));
tasks.Add(e_hentai_non_ai.CreateRSSAsync(client));
+ tasks.Add(pixiv_r18.CreateRSSAsync(client));
+ tasks.Add(pixiv_non_r18.CreateRSSAsync(client));
tasks.Add(index_japanese.CreateRSSAsync(client));
#endif