feat: add RSS generator for mangalear.blog with image extraction and gallery link support

This commit is contained in:
armonica committed 2026-09-05 14:05:59 +09:00
1 parent 020c11103e
commit b182316504
1 file changed
+22 -1
+22 -1
View File
@@ -6,6 +6,7 @@ using System.Linq;
using System.Net; using System.Net;
using System.ServiceModel.Syndication; using System.ServiceModel.Syndication;
using System.Text; using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks; using System.Threading.Tasks;
using static rss_generator.Class.LogManager; using static rss_generator.Class.LogManager;
@@ -92,6 +93,24 @@ internal class mangalear
if (link != null) if (link != null)
{ {
// ギャラリー表示リンクの生成
string? galleryId = null;
string? galleryUrl = null;
var linkStr = link.ToString();
var idMatch = Regex.Match(linkStr, @"(?:mangalear\.blog)?/(?:[a-zA-Z0-9_-]+/)?(?<id>\d+)/?(?:\?.*)?$");
if (!idMatch.Success)
{
idMatch = Regex.Match(linkStr, @"[?&]p=(?<id>\d+)");
}
if (idMatch.Success)
{
galleryId = idMatch.Groups["id"].Value;
galleryUrl = $"https://udukipc-web.armonica-vps.work/mangalear/{galleryId}/";
body.Append($"<div>");
body.Append($"<a href=\"{galleryUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" referrerpolicy=\"no-referrer\">[Gallery]</a>");
body.Append($"</div>");
}
// 記事詳細ページの HTML を取得 // 記事詳細ページの HTML を取得
var docContents = await CmnUtil.GetDocument(client, link.ToString()); var docContents = await CmnUtil.GetDocument(client, link.ToString());
if (docContents != null) if (docContents != null)
@@ -150,7 +169,9 @@ internal class mangalear
{ {
if (Uri.TryCreate(link, singleImageUrl, out var absoluteImgUri)) if (Uri.TryCreate(link, singleImageUrl, out var absoluteImgUri))
{ {
body.Append($@"<div style=""margin-bottom: 12px;""><a href=""{link}"" target=""_blank"" rel=""noopener noreferrer"" referrerpolicy=""no-referrer""><img src=""{absoluteImgUri}"" referrerpolicy=""no-referrer"" alt=""{WebUtility.HtmlEncode(title)}"" style=""max-width: 100%; height: auto;"" /></a></div>"); var imgUriStr = absoluteImgUri.ToString().Replace("http://", "https://");
var clickTargetUrl = galleryUrl ?? link.ToString();
body.Append($@"<div style=""margin-bottom: 12px;""><a href=""{clickTargetUrl}"" target=""_blank"" rel=""noopener noreferrer"" referrerpolicy=""no-referrer""><img src=""{imgUriStr}"" referrerpolicy=""no-referrer"" alt=""{WebUtility.HtmlEncode(title)}"" style=""max-width: 100%; height: auto;"" /></a></div>");
} }
} }
} }