新規追加: japaneseavi.blogspot.com向けRSSフィード生成機能(タイトル整形・直下ダウンロードグリッド・ドメイン分離)
This commit is contained in:
1 parent
32786ca023
commit
80ba9afcc1
2 files changed
+550
-1
No files matched your search
@@ -0,0 +1,547 @@
|
|||||||
|
using AngleSharp.Dom;
|
||||||
|
using AngleSharp.Html.Dom;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.ServiceModel.Syndication;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml;
|
||||||
|
using rss_generator.Class.Common;
|
||||||
|
|
||||||
|
namespace rss_generator.Class.JapaneseAvi;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// japaneseavi.blogspot.com から記事情報を収集し、RSS フィード (japaneseavi.xml) を生成するクラスです。
|
||||||
|
/// </summary>
|
||||||
|
internal class japaneseavi
|
||||||
|
{
|
||||||
|
#region □定数(Private)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// プロジェクト固有規則に基づく出力先ドメインディレクトリ名です。
|
||||||
|
/// </summary>
|
||||||
|
private const string DomainDir = "japaneseavi.blogspot.com";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// キャッシュ判定用の最新フォーマット識別子です。
|
||||||
|
/// </summary>
|
||||||
|
private const string CacheFormatTag = "avi-format-v1";
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □クラス(Private)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 既存の RSS フィードから読み込んだ記事情報を保持する内部クラスです。
|
||||||
|
/// </summary>
|
||||||
|
private sealed class ExistingFeedEntry
|
||||||
|
{
|
||||||
|
/// <summary>記事のタイトルを取得または設定します。</summary>
|
||||||
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>記事の本文 HTML (Summary) を取得または設定します。</summary>
|
||||||
|
public string SummaryHtml { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>記事の初回公開日時を取得または設定します。</summary>
|
||||||
|
public DateTimeOffset PublishDate { get; set; }
|
||||||
|
|
||||||
|
/// <summary>記事の最終更新日時を取得または設定します。</summary>
|
||||||
|
public DateTimeOffset LastUpdatedTime { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// ダウンロードリンクの情報を保持する内部クラスです。
|
||||||
|
/// </summary>
|
||||||
|
private sealed class DownloadItem
|
||||||
|
{
|
||||||
|
/// <summary>プロバイダー名を取得または設定します。</summary>
|
||||||
|
public string ProviderName { get; set; } = "Mediafire";
|
||||||
|
|
||||||
|
/// <summary>ダウンロード先 URL を取得または設定します。</summary>
|
||||||
|
public string DownloadUrl { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 解析された記事詳細情報を保持する内部クラスです。
|
||||||
|
/// </summary>
|
||||||
|
private sealed class ArticleDetailInfo
|
||||||
|
{
|
||||||
|
/// <summary>品番(例: SOE-798, MXGS-422 等)を取得または設定します。</summary>
|
||||||
|
public string ProductId { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>整形されたタイトル文字列を取得または設定します。</summary>
|
||||||
|
public string CleanTitle { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>メディア形式(例: DVD, WMV 等)を取得または設定します。</summary>
|
||||||
|
public string MediaFormat { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>メインカバー画像の URL を取得または設定します。</summary>
|
||||||
|
public string ImageUrl { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>ダウンロードリンク一覧を取得または設定します。</summary>
|
||||||
|
public List<DownloadItem> Downloads { get; set; } = new();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Public)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// japaneseavi.blogspot.com から記事情報を収集し、RSS フィード (japaneseavi.xml) を生成・出力します。
|
||||||
|
/// プロジェクト固有規則に基づき、ドメイン別ディレクトリ output/japaneseavi.blogspot.com/ に出力します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client">HTTP 通信用 HttpClient</param>
|
||||||
|
/// <returns>非同期タスク</returns>
|
||||||
|
public static async Task CreateRSSAsync(HttpClient client)
|
||||||
|
{
|
||||||
|
var feedUrl = "https://japaneseavi.blogspot.com/feeds/posts/default?alt=json&max-results=50";
|
||||||
|
var fileName = "japaneseavi.xml";
|
||||||
|
|
||||||
|
var feed = new SyndicationFeed("Japanese Porn Movie XXX Mediafire", "japaneseavi.blogspot.com RSS Feed", new Uri("https://japaneseavi.blogspot.com/"));
|
||||||
|
var items = new List<SyndicationItem>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 既存フィードの読み込み(ドメイン別サブディレクトリ)
|
||||||
|
var existingEntries = LoadExistingEntries(fileName);
|
||||||
|
|
||||||
|
// Blogger JSON フィードを取得
|
||||||
|
string jsonString = await client.GetStringAsync(feedUrl);
|
||||||
|
using var jsonDoc = JsonDocument.Parse(jsonString);
|
||||||
|
|
||||||
|
if (!jsonDoc.RootElement.TryGetProperty("feed", out var feedElem) ||
|
||||||
|
!feedElem.TryGetProperty("entry", out var entriesElem) ||
|
||||||
|
entriesElem.ValueKind != JsonValueKind.Array)
|
||||||
|
{
|
||||||
|
LogManager.AddLog("[情報] 【japaneseavi】 エントリが見つかりませんでした。");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var entry in entriesElem.EnumerateArray())
|
||||||
|
{
|
||||||
|
// タイトル取得
|
||||||
|
string rawTitle = string.Empty;
|
||||||
|
if (entry.TryGetProperty("title", out var titleElem) &&
|
||||||
|
titleElem.TryGetProperty("$t", out var titleTextElem))
|
||||||
|
{
|
||||||
|
rawTitle = titleTextElem.GetString() ?? string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 記事リンクの取得
|
||||||
|
string articleUrl = string.Empty;
|
||||||
|
if (entry.TryGetProperty("link", out var linkArrayElem) && linkArrayElem.ValueKind == JsonValueKind.Array)
|
||||||
|
{
|
||||||
|
foreach (var linkElem in linkArrayElem.EnumerateArray())
|
||||||
|
{
|
||||||
|
if (linkElem.TryGetProperty("rel", out var relElem) && relElem.GetString() == "alternate" &&
|
||||||
|
linkElem.TryGetProperty("href", out var hrefElem))
|
||||||
|
{
|
||||||
|
articleUrl = hrefElem.GetString() ?? string.Empty;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(articleUrl))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var itemUri = new Uri(articleUrl);
|
||||||
|
var guid = CmnUtil.CreateGuid(articleUrl);
|
||||||
|
|
||||||
|
// 公開日時・更新日時の取得
|
||||||
|
DateTimeOffset publishDate = DateTimeOffset.Now;
|
||||||
|
DateTimeOffset updatedDate = DateTimeOffset.Now;
|
||||||
|
if (entry.TryGetProperty("published", out var pubElem) && pubElem.TryGetProperty("$t", out var pubTextElem))
|
||||||
|
{
|
||||||
|
if (DateTimeOffset.TryParse(pubTextElem.GetString(), out var dt))
|
||||||
|
{
|
||||||
|
publishDate = dt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (entry.TryGetProperty("updated", out var updElem) && updElem.TryGetProperty("$t", out var updTextElem))
|
||||||
|
{
|
||||||
|
if (DateTimeOffset.TryParse(updTextElem.GetString(), out var dt))
|
||||||
|
{
|
||||||
|
updatedDate = dt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 本文 HTML (content) の取得
|
||||||
|
string rawContent = string.Empty;
|
||||||
|
if (entry.TryGetProperty("content", out var contentElem) &&
|
||||||
|
contentElem.TryGetProperty("$t", out var contentTextElem))
|
||||||
|
{
|
||||||
|
rawContent = contentTextElem.GetString() ?? string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
existingEntries.TryGetValue(articleUrl, out var prevEntry);
|
||||||
|
if (prevEntry == null && !string.IsNullOrEmpty(guid))
|
||||||
|
{
|
||||||
|
existingEntries.TryGetValue(guid, out prevEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 最新フォーマット識別子 avi-format-v1 が含まれているキャッシュのみ再利用
|
||||||
|
bool isLatestFormat = prevEntry != null &&
|
||||||
|
prevEntry.SummaryHtml.Contains("avi-dl-section") &&
|
||||||
|
prevEntry.SummaryHtml.Contains(CacheFormatTag);
|
||||||
|
|
||||||
|
SyndicationItem item;
|
||||||
|
if (isLatestFormat && prevEntry != null)
|
||||||
|
{
|
||||||
|
// 【キャッシュヒット(未更新記事)】
|
||||||
|
item = new SyndicationItem(
|
||||||
|
prevEntry.Title,
|
||||||
|
(string?)null,
|
||||||
|
itemUri,
|
||||||
|
guid,
|
||||||
|
prevEntry.LastUpdatedTime
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PublishDate = prevEntry.PublishDate,
|
||||||
|
LastUpdatedTime = prevEntry.LastUpdatedTime,
|
||||||
|
Summary = new TextSyndicationContent(prevEntry.SummaryHtml, TextSyndicationContentKind.Html)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 【新規記事またはフォーマット更新記事】
|
||||||
|
var detailInfo = ParseArticleContent(rawTitle, rawContent);
|
||||||
|
|
||||||
|
// フォルダ名用タイトルの構築: [品番] タイトル [メディア形式]
|
||||||
|
string folderTitle = BuildFolderTitle(detailInfo, rawTitle);
|
||||||
|
|
||||||
|
// 本文 HTML の構築(フォルダ名コピー枠、タイトル表示、直下ダウンロードグリッド、高画質カバー画像)
|
||||||
|
string summaryHtml = BuildSummaryHtml(detailInfo, folderTitle, itemUri);
|
||||||
|
|
||||||
|
item = new SyndicationItem(
|
||||||
|
folderTitle,
|
||||||
|
(string?)null,
|
||||||
|
itemUri,
|
||||||
|
guid,
|
||||||
|
updatedDate
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PublishDate = publishDate,
|
||||||
|
LastUpdatedTime = updatedDate,
|
||||||
|
Summary = new TextSyndicationContent(summaryHtml, TextSyndicationContentKind.Html)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
items.Add(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
feed.Items = items;
|
||||||
|
|
||||||
|
// プロジェクト固有規則に従い、ドメイン名サブディレクトリ (output/japaneseavi.blogspot.com/japaneseavi.xml) に出力
|
||||||
|
await CmnUtil.ExportXMLFileAsync(
|
||||||
|
fileName,
|
||||||
|
feed,
|
||||||
|
client,
|
||||||
|
addDir: DomainDir,
|
||||||
|
embedBase64: false,
|
||||||
|
filter24Hours: false);
|
||||||
|
|
||||||
|
LogManager.AddLog($"[情報] 【japaneseavi】 出力完了 - 記事数: {items.Count}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogManager.AddLog($"[エラー] 【japaneseavi】 {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region □メソッド(Private)
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// タイトルおよび本文 HTML から各種情報(品番、クリーンタイトル、メディア形式、画像、ダウンロードリンク)を抽出・解析します。
|
||||||
|
/// </summary>
|
||||||
|
private static ArticleDetailInfo ParseArticleContent(string rawTitle, string rawContent)
|
||||||
|
{
|
||||||
|
var info = new ArticleDetailInfo();
|
||||||
|
|
||||||
|
// 1. 品番(Product ID)の抽出(例: SOE-798, MXGS-422, ONSD-643, XV-1077, WDI-028, ONED-448 等)
|
||||||
|
var pidMatch = Regex.Match(rawTitle, @"\b([A-Z0-9]{2,5}-\d{3,4})\b", RegexOptions.IgnoreCase);
|
||||||
|
if (pidMatch.Success)
|
||||||
|
{
|
||||||
|
info.ProductId = pidMatch.Groups[1].Value.ToUpperInvariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. メディア形式(DVD, WMV 等)の抽出
|
||||||
|
var formatMatch = Regex.Match(rawTitle, @"\[(DVD|WMV|MP4|AVI|HD|FHD)\]|\b(DVD|WMV|MP4|AVI)\b", RegexOptions.IgnoreCase);
|
||||||
|
if (formatMatch.Success)
|
||||||
|
{
|
||||||
|
string fmt = !string.IsNullOrWhiteSpace(formatMatch.Groups[1].Value)
|
||||||
|
? formatMatch.Groups[1].Value
|
||||||
|
: formatMatch.Groups[2].Value;
|
||||||
|
info.MediaFormat = fmt.ToUpperInvariant();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. タイトル文字列のクリーンアップ([CEN], [DVD], 品番などを整理)
|
||||||
|
string clean = rawTitle;
|
||||||
|
clean = Regex.Replace(clean, @"\[?CEN\]?", "", RegexOptions.IgnoreCase);
|
||||||
|
clean = Regex.Replace(clean, @"\[(DVD|WMV|MP4|AVI|HD|FHD)\]", "", RegexOptions.IgnoreCase);
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.ProductId))
|
||||||
|
{
|
||||||
|
clean = Regex.Replace(clean, @"[\[\(\{]?" + Regex.Escape(info.ProductId) + @"[\]\)\}]?", "", RegexOptions.IgnoreCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 前後の記号や空白を整形
|
||||||
|
clean = clean.Trim(' ', '-', '–', '—', ':', '・', '[', ']', '(', ')');
|
||||||
|
clean = Regex.Replace(clean, @"\s{2,}", " ").Trim();
|
||||||
|
info.CleanTitle = clean;
|
||||||
|
|
||||||
|
// 4. 高解像度メイン画像の抽出
|
||||||
|
var imgMatch = Regex.Match(rawContent, @"<a[^>]+href=""([^""]+\.(?:jpg|jpeg|png|webp))""[^>]*>[\s\S]*?<img", RegexOptions.IgnoreCase);
|
||||||
|
if (imgMatch.Success)
|
||||||
|
{
|
||||||
|
info.ImageUrl = imgMatch.Groups[1].Value;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var directImg = Regex.Match(rawContent, @"<img[^>]+src=""([^""]+)""", RegexOptions.IgnoreCase);
|
||||||
|
if (directImg.Success)
|
||||||
|
{
|
||||||
|
info.ImageUrl = directImg.Groups[1].Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. ダウンロードリンクの抽出
|
||||||
|
var aMatches = Regex.Matches(rawContent, @"<a\s+[^>]*href=""([^""]+)""[^>]*>([\s\S]*?)</a>", RegexOptions.IgnoreCase);
|
||||||
|
foreach (Match a in aMatches)
|
||||||
|
{
|
||||||
|
string href = a.Groups[1].Value;
|
||||||
|
string text = Regex.Replace(a.Groups[2].Value, @"<[^>]+>", "").Trim();
|
||||||
|
|
||||||
|
// 画像リンクそのものは除外
|
||||||
|
if (href.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
href.EndsWith(".png", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
href.EndsWith(".webp", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (href.Contains("adf.ly", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
href.Contains("mediafire.com", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
text.Contains("download", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
text.Contains("mediafire", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
string provider = "Mediafire";
|
||||||
|
if (text.Contains("Mediafire", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
provider = "Mediafire";
|
||||||
|
}
|
||||||
|
|
||||||
|
info.Downloads.Add(new DownloadItem
|
||||||
|
{
|
||||||
|
ProviderName = provider,
|
||||||
|
DownloadUrl = href
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 解析情報から Windows のフォルダ名としてコピー可能なタイトル文字列を生成します。
|
||||||
|
/// </summary>
|
||||||
|
private static string BuildFolderTitle(ArticleDetailInfo info, string fallbackRawTitle)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
// 1. 品番を先頭に配置
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.ProductId))
|
||||||
|
{
|
||||||
|
sb.Append($"[{info.ProductId}] ");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. クリーンタイトル
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.CleanTitle))
|
||||||
|
{
|
||||||
|
sb.Append(info.CleanTitle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sb.Append(fallbackRawTitle);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. メディア形式(末尾に付加)
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.MediaFormat) &&
|
||||||
|
!sb.ToString().Contains(info.MediaFormat, StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
sb.Append($" [{info.MediaFormat}]");
|
||||||
|
}
|
||||||
|
|
||||||
|
return SanitizeWindowsPath(sb.ToString().Trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 整形された本文 HTML を生成します。
|
||||||
|
/// フォルダ名コピー枠、タイトル表示、直下ダウンロードグリッド、高画質カバー画像を配置します。
|
||||||
|
/// </summary>
|
||||||
|
private static string BuildSummaryHtml(ArticleDetailInfo info, string folderTitle, Uri articleUri)
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
|
// 1. バッジ
|
||||||
|
sb.Append("<div style=\"margin-bottom: 12px;\">");
|
||||||
|
sb.Append("<span style=\"display: inline-block; background-color: #c2185b; color: #ffffff; padding: 4px 10px; border-radius: 4px; font-weight: bold; font-size: 13px;\">🎬 JAV (Japanese Adult Video)</span>");
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.ProductId))
|
||||||
|
{
|
||||||
|
sb.Append($"<span style=\"display: inline-block; background-color: #374151; color: #ffffff; padding: 4px 8px; border-radius: 4px; font-size: 13px; font-weight: bold; margin-left: 8px;\">🏷️ {WebUtility.HtmlEncode(info.ProductId)}</span>");
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.MediaFormat))
|
||||||
|
{
|
||||||
|
sb.Append($"<span style=\"display: inline-block; background-color: #1976d2; color: #ffffff; padding: 4px 8px; border-radius: 4px; font-size: 13px; font-weight: bold; margin-left: 8px;\">💿 {WebUtility.HtmlEncode(info.MediaFormat)}</span>");
|
||||||
|
}
|
||||||
|
sb.Append("</div>");
|
||||||
|
|
||||||
|
// 2. フォルダ名用タイトルコピー枠(ワンクリック全選択コピー可能)
|
||||||
|
sb.Append($"<div class=\"avi-folder-title {CacheFormatTag}\" style=\"background-color: #f3f4f6; border-left: 4px solid #374151; padding: 10px 14px; margin-bottom: 12px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif; border-radius: 0 4px 4px 0;\">");
|
||||||
|
sb.Append("<div style=\"font-size: 11px; font-weight: bold; color: #4b5563; margin-bottom: 4px;\">📁 フォルダ名用タイトル (コピー用):</div>");
|
||||||
|
sb.Append($"<div style=\"font-size: 15px; font-weight: bold; color: #111827; user-select: all; -webkit-user-select: all;\">{WebUtility.HtmlEncode(folderTitle)}</div>");
|
||||||
|
sb.Append("</div>");
|
||||||
|
|
||||||
|
// 3. タイトル・詳細情報ブロック
|
||||||
|
sb.Append("<div class=\"avi-info-block\" style=\"background-color: #f8fafc; border-left: 4px solid #0284c7; padding: 8px 12px; margin-bottom: 12px; font-size: 14px; border-radius: 0 4px 4px 0;\">");
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.ProductId))
|
||||||
|
{
|
||||||
|
sb.Append($"<div style=\"margin-bottom: 4px;\"><strong style=\"color: #0369a1;\">品番 (Product ID):</strong> <span>{WebUtility.HtmlEncode(info.ProductId)}</span></div>");
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.CleanTitle))
|
||||||
|
{
|
||||||
|
sb.Append($"<div><strong style=\"color: #0369a1;\">作品名 (Title):</strong> <span>{WebUtility.HtmlEncode(info.CleanTitle)}</span></div>");
|
||||||
|
}
|
||||||
|
sb.Append("</div>");
|
||||||
|
|
||||||
|
// 4. ダウンロードセクション (avi-dl-section) - タイトル直下に整然としたグリッドレイアウトで配置
|
||||||
|
if (info.Downloads.Any())
|
||||||
|
{
|
||||||
|
sb.Append("<div class=\"avi-dl-section\" style=\"background-color: #f7f9fa; border: 1px solid #cfd8dc; border-radius: 6px; padding: 14px; margin-top: 10px; margin-bottom: 14px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;\">");
|
||||||
|
sb.Append("<h4 style=\"margin: 0 0 10px 0; font-size: 16px; border-bottom: 2px solid #e53935; padding-bottom: 6px; color: #c62828;\">");
|
||||||
|
sb.Append("📥 ダウンロード (DOWNLOAD)");
|
||||||
|
sb.Append("</h4>");
|
||||||
|
|
||||||
|
sb.Append("<div style=\"display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-bottom: 6px;\">");
|
||||||
|
|
||||||
|
foreach (var dl in info.Downloads)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrWhiteSpace(dl.DownloadUrl))
|
||||||
|
{
|
||||||
|
sb.Append($"<a href=\"{dl.DownloadUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" referrerpolicy=\"no-referrer\" style=\"display: flex; align-items: center; justify-content: center; gap: 6px; text-align: center; background-color: #1976d2; color: #ffffff; padding: 10px 14px; border-radius: 4px; text-decoration: none; font-weight: bold; font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,0.12);\">");
|
||||||
|
sb.Append($"<span>⬇️</span> <span>{WebUtility.HtmlEncode(dl.ProviderName)} Download</span>");
|
||||||
|
sb.Append("</a>");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sb.Append("</div>");
|
||||||
|
sb.Append("</div>");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. メインカバー画像(高画質表示)
|
||||||
|
if (!string.IsNullOrWhiteSpace(info.ImageUrl))
|
||||||
|
{
|
||||||
|
sb.Append("<div style=\"margin-bottom: 14px; text-align: center;\">");
|
||||||
|
sb.Append($"<img src=\"{info.ImageUrl}\" referrerpolicy=\"no-referrer\" alt=\"{WebUtility.HtmlEncode(folderTitle)}\" style=\"max-width: 100%; height: auto; border-radius: 4px; box-shadow: 0 2px 4px rgba(0,0,0,0.15);\" />");
|
||||||
|
sb.Append("</div>");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 6. 記事ページへのリンク
|
||||||
|
sb.Append("<div style=\"margin-top: 16px; padding-top: 10px; border-top: 1px solid #e0e0e0; font-size: 13px;\">");
|
||||||
|
sb.Append($"<a href=\"{articleUri}\" target=\"_blank\" rel=\"noopener noreferrer\" referrerpolicy=\"no-referrer\" style=\"color: #1976d2; text-decoration: none;\">🔗 japaneseavi.blogspot.com 記事ページを開く</a>");
|
||||||
|
sb.Append("</div>");
|
||||||
|
|
||||||
|
return sb.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Windows のフォルダ名に使用できない記号文字を全角文字に置換します。
|
||||||
|
/// </summary>
|
||||||
|
private static string SanitizeWindowsPath(string name)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
return name
|
||||||
|
.Replace('\\', '¥')
|
||||||
|
.Replace('/', '/')
|
||||||
|
.Replace(':', ':')
|
||||||
|
.Replace('*', '*')
|
||||||
|
.Replace('?', '?')
|
||||||
|
.Replace('"', '”')
|
||||||
|
.Replace('<', '<')
|
||||||
|
.Replace('>', '>')
|
||||||
|
.Replace('|', '|')
|
||||||
|
.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 既存の XML ファイルから各記事のタイトル・本文 HTML・公開日時・更新日時を読み込みます。
|
||||||
|
/// プロジェクト固有規則に基づき、ドメイン別サブディレクトリ(output/japaneseavi.blogspot.com/)内のファイルを読み込みます。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">XML ファイル名</param>
|
||||||
|
/// <returns>URL または GUID をキーとする既存エントリの辞書</returns>
|
||||||
|
private static Dictionary<string, ExistingFeedEntry> LoadExistingEntries(string fileName)
|
||||||
|
{
|
||||||
|
var existingEntries = new Dictionary<string, ExistingFeedEntry>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string xmlPath = CmnUtil.GetExportXmlPath(fileName, addDir: DomainDir);
|
||||||
|
if (!File.Exists(xmlPath))
|
||||||
|
{
|
||||||
|
return existingEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
using var reader = XmlReader.Create(xmlPath);
|
||||||
|
var existingFeed = SyndicationFeed.Load(reader);
|
||||||
|
if (existingFeed?.Items != null)
|
||||||
|
{
|
||||||
|
foreach (var item in existingFeed.Items)
|
||||||
|
{
|
||||||
|
var linkUrl = item.Links.FirstOrDefault()?.Uri?.AbsoluteUri;
|
||||||
|
var guid = item.Id;
|
||||||
|
|
||||||
|
var entry = new ExistingFeedEntry
|
||||||
|
{
|
||||||
|
Title = item.Title?.Text?.Trim() ?? string.Empty,
|
||||||
|
SummaryHtml = item.Summary?.Text?.Trim() ?? string.Empty,
|
||||||
|
PublishDate = item.PublishDate != DateTimeOffset.MinValue
|
||||||
|
? item.PublishDate
|
||||||
|
: (item.LastUpdatedTime != DateTimeOffset.MinValue ? item.LastUpdatedTime : DateTimeOffset.Now),
|
||||||
|
LastUpdatedTime = item.LastUpdatedTime != DateTimeOffset.MinValue
|
||||||
|
? item.LastUpdatedTime
|
||||||
|
: (item.PublishDate != DateTimeOffset.MinValue ? item.PublishDate : DateTimeOffset.Now)
|
||||||
|
};
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(linkUrl) && !existingEntries.ContainsKey(linkUrl))
|
||||||
|
{
|
||||||
|
existingEntries[linkUrl] = entry;
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrWhiteSpace(guid) && !existingEntries.ContainsKey(guid))
|
||||||
|
{
|
||||||
|
existingEntries[guid] = entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogManager.AddLog($"[情報] japaneseavi 既存エントリ読み込みスキップ: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return existingEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
@@ -8,6 +8,7 @@ using rss_generator.Class.EHentai;
|
|||||||
using rss_generator.Class.Eroterest;
|
using rss_generator.Class.Eroterest;
|
||||||
using rss_generator.Class.HentaiPaw;
|
using rss_generator.Class.HentaiPaw;
|
||||||
using rss_generator.Class.HitomiLa;
|
using rss_generator.Class.HitomiLa;
|
||||||
|
using rss_generator.Class.JapaneseAvi;
|
||||||
using rss_generator.Class.Javtwi;
|
using rss_generator.Class.Javtwi;
|
||||||
using rss_generator.Class.KimochiInfo;
|
using rss_generator.Class.KimochiInfo;
|
||||||
using rss_generator.Class.Mangalear;
|
using rss_generator.Class.Mangalear;
|
||||||
@@ -23,7 +24,6 @@ using rss_generator.Class.YahooBaseball;
|
|||||||
using rss_generator.Class.YouTube;
|
using rss_generator.Class.YouTube;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
|
|
||||||
// 1. 同期スレッド等の未処理例外
|
// 1. 同期スレッド等の未処理例外
|
||||||
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
|
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
|
||||||
{
|
{
|
||||||
@@ -100,12 +100,14 @@ while (true)
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
nonFlareActions.Add(("YouTube", client => YouTubeFeedManager.CreateRSSAsync(client)));
|
nonFlareActions.Add(("YouTube", client => YouTubeFeedManager.CreateRSSAsync(client)));
|
||||||
nonFlareActions.Add(("ryuugames", client => ryuugames.CreateRSSAsync(client)));
|
nonFlareActions.Add(("ryuugames", client => ryuugames.CreateRSSAsync(client)));
|
||||||
|
nonFlareActions.Add(("japaneseavi", client => japaneseavi.CreateRSSAsync(client)));
|
||||||
#else
|
#else
|
||||||
// ※ movie.eroterest.net は取得処理停止のため除外
|
// ※ movie.eroterest.net は取得処理停止のため除外
|
||||||
nonFlareActions.Add(("ryuugames", client => ryuugames.CreateRSSAsync(client)));
|
nonFlareActions.Add(("ryuugames", client => ryuugames.CreateRSSAsync(client)));
|
||||||
nonFlareActions.Add(("YouTube", client => YouTubeFeedManager.CreateRSSAsync(client)));
|
nonFlareActions.Add(("YouTube", client => YouTubeFeedManager.CreateRSSAsync(client)));
|
||||||
nonFlareActions.Add(("X (Twitter)", client => x_list.CreateRSSAsync(client)));
|
nonFlareActions.Add(("X (Twitter)", client => x_list.CreateRSSAsync(client)));
|
||||||
nonFlareActions.Add(("kimochiinfo", client => kimochiinfo.CreateRSSAsync(client)));
|
nonFlareActions.Add(("kimochiinfo", client => kimochiinfo.CreateRSSAsync(client)));
|
||||||
|
nonFlareActions.Add(("japaneseavi", client => japaneseavi.CreateRSSAsync(client)));
|
||||||
nonFlareActions.Add(("ci_en", client => ci_en.CreateRSSAsync(client)));
|
nonFlareActions.Add(("ci_en", client => ci_en.CreateRSSAsync(client)));
|
||||||
nonFlareActions.Add(("javtwi", client => javtwi.CreateRSSAsync(client)));
|
nonFlareActions.Add(("javtwi", client => javtwi.CreateRSSAsync(client)));
|
||||||
nonFlareActions.Add(("mangalear", client => mangalear.CreateRSSAsync(client)));
|
nonFlareActions.Add(("mangalear", client => mangalear.CreateRSSAsync(client)));
|
||||||
|
|||||||
Reference in new issue
Block a user