新規追加: otomi-games.com向けRSSフィード生成機能(および未コミットの85po.com対応を反映)
This commit is contained in:
1 parent
39eb1fef31
commit
50d971520a
4 files changed
+2750
No files matched your search
@@ -14,6 +14,7 @@ RSSフィード(XMLファイル)を出力する際は、`output` ディレ
|
||||
- `kimochi.info` → `output/kimochi.info/kimochiinfo.xml`
|
||||
- `japaneseavi.blogspot.com` → `output/japaneseavi.blogspot.com/japaneseavi.xml`
|
||||
- `jpfiles.net` → `output/jpfiles.net/jpfiles.xml`
|
||||
- `otomi-games.com` → `output/otomi-games.com/otomigames.xml`
|
||||
- `pixiv.net` → `output/pixiv.net/...`
|
||||
- `x.com` → `output/x.com/...`
|
||||
- `e-hentai.org` → `output/e-hentai.org/...`
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,707 @@
|
||||
using AngleSharp.Dom;
|
||||
using AngleSharp.Html.Dom;
|
||||
using AngleSharp.Html.Parser;
|
||||
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.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml;
|
||||
using rss_generator.Class.Common;
|
||||
|
||||
namespace rss_generator.Class.Po85;
|
||||
|
||||
/// <summary>
|
||||
/// 85PO (https://www.85po.com/) の新着RSS (https://www.85po.com/ja/rss/) を取得し、
|
||||
/// WebImageViewer (https://udukipc-web.armonica-vps.work/) への再生リンク、ワンクリックフォルダ名コピー枠、
|
||||
/// 高解像度プレビュー画像、ダウンロード直リンク等を付加した拡張 RSS フィード (85po.xml) を生成・出力するクラスです。
|
||||
/// </summary>
|
||||
internal static class po85
|
||||
{
|
||||
#region □定数(Private)
|
||||
|
||||
/// <summary>
|
||||
/// プロジェクト固有規則に基づく出力先ドメインディレクトリ名です。
|
||||
/// </summary>
|
||||
private const string DomainDir = "85po.com";
|
||||
|
||||
/// <summary>
|
||||
/// 出力フィードのファイル名です。
|
||||
/// </summary>
|
||||
private const string FileName = "85po.xml";
|
||||
|
||||
/// <summary>
|
||||
/// 取得元の公式RSSフィードURLです。
|
||||
/// </summary>
|
||||
private const string TargetFeedUrl = "https://www.85po.com/ja/rss/";
|
||||
|
||||
/// <summary>
|
||||
/// 85PO のベースURLです。
|
||||
/// </summary>
|
||||
private const string BaseUrl = "https://www.85po.com";
|
||||
|
||||
/// <summary>
|
||||
/// WebImageViewer のベースURLです。
|
||||
/// </summary>
|
||||
private const string WebImageViewerBaseUrl = "https://udukipc-web.armonica-vps.work/?url=";
|
||||
|
||||
/// <summary>
|
||||
/// キャッシュ判定用の最新フォーマット識別子です。
|
||||
/// </summary>
|
||||
private const string CacheFormatTag = "85po-format-v1";
|
||||
|
||||
/// <summary>
|
||||
/// フィードで保持する最大アイテム数です。
|
||||
/// </summary>
|
||||
private const int MaxFeedItems = 100;
|
||||
|
||||
#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>
|
||||
public List<string> Categories { get; set; } = new();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 各動画の詳細情報を保持する内部クラスです。
|
||||
/// </summary>
|
||||
private sealed class VideoDetailInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 動画の元タイトルを取得または設定します。
|
||||
/// </summary>
|
||||
public string OriginalTitle { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Windows フォルダ名用に整形されたタイトルを取得または設定します。
|
||||
/// </summary>
|
||||
public string CleanTitle { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 動画ページのURLを取得または設定します。
|
||||
/// </summary>
|
||||
public string VideoUrl { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// サムネイル画像URLを取得または設定します。
|
||||
/// </summary>
|
||||
public string? ThumbnailUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 高解像度プレビュー画像URLを取得または設定します。
|
||||
/// </summary>
|
||||
public string? PreviewImageUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 動画の再生時間文字列を取得または設定します。
|
||||
/// </summary>
|
||||
public string? Duration { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 動画のタグ一覧を取得または設定します。
|
||||
/// </summary>
|
||||
public List<string> Tags { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// ダウンロード直リンクURLを取得または設定します。
|
||||
/// </summary>
|
||||
public string? DownloadUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ダウンロードリンクの表示ラベル(画質・サイズ等)を取得または設定します。
|
||||
/// </summary>
|
||||
public string? DownloadLabel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 動画の説明文を取得または設定します。
|
||||
/// </summary>
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region □メソッド(Public)
|
||||
|
||||
/// <summary>
|
||||
/// 85PO の新着RSSを取得し、WebImageViewer へのリンク等を追加した拡張 RSS フィードを非同期で生成・出力します。
|
||||
/// </summary>
|
||||
/// <param name="client">HTTP 通信に使用する HttpClient インスタンス</param>
|
||||
/// <returns>非同期タスク</returns>
|
||||
public static async Task CreateRSSAsync(HttpClient client)
|
||||
{
|
||||
var feed = new SyndicationFeed(
|
||||
"85PO - 新着ビデオ (WebImageViewer拡張版)",
|
||||
"85POの最新新着動画フィードです。WebImageViewerでの直接再生リンクおよびダウンロードリンクが含まれています。",
|
||||
new Uri("https://www.85po.com/ja/latest-updates/"));
|
||||
|
||||
try
|
||||
{
|
||||
// 1. 既存XMLフィードの読み込み(未更新記事の再利用および過去記事のマージ用)
|
||||
var existingEntries = LoadExistingEntries(FileName, DomainDir);
|
||||
LogManager.AddLog($"[情報] 【85po】 既存フィードキャッシュ件数: {existingEntries.Count} 件");
|
||||
|
||||
// 2. 85PO 公式RSSフィードの取得
|
||||
using var request = new HttpRequestMessage(HttpMethod.Get, TargetFeedUrl);
|
||||
request.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
|
||||
request.Headers.Add("Accept", "application/rss+xml,application/xml,text/xml;q=0.9,*/*;q=0.8");
|
||||
|
||||
using var response = await client.SendAsync(request);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
LogManager.AddLog($"[エラー] 【85po】 RSSフィードの取得に失敗しました。HTTPステータス: {(int)response.StatusCode}");
|
||||
return;
|
||||
}
|
||||
|
||||
var rssXml = await response.Content.ReadAsStringAsync();
|
||||
if (string.IsNullOrWhiteSpace(rssXml))
|
||||
{
|
||||
LogManager.AddLog("[エラー] 【85po】 RSSフィードの内容が空でした。");
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. XML の読み込みとパース
|
||||
using var stringReader = new StringReader(rssXml);
|
||||
using var xmlReader = XmlReader.Create(stringReader, new XmlReaderSettings { DtdProcessing = DtdProcessing.Ignore });
|
||||
var sourceFeed = SyndicationFeed.Load(xmlReader);
|
||||
if (sourceFeed == null || sourceFeed.Items == null)
|
||||
{
|
||||
LogManager.AddLog("[エラー] 【85po】 RSSフィードのXML解析に失敗しました。");
|
||||
return;
|
||||
}
|
||||
|
||||
var currentItems = new List<SyndicationItem>();
|
||||
var processedUrls = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
foreach (var srcItem in sourceFeed.Items)
|
||||
{
|
||||
var articleUrl = srcItem.Links.FirstOrDefault()?.Uri?.AbsoluteUri
|
||||
?? srcItem.Id
|
||||
?? string.Empty;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(articleUrl))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!processedUrls.Add(articleUrl))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// プロジェクト固有規則: GUIDのハッシュ化(CmnUtil.CreateGuid)
|
||||
var guid = CmnUtil.CreateGuid(articleUrl);
|
||||
var itemUri = new Uri(articleUrl);
|
||||
|
||||
// 日時を日本時間(JST = UTC+9)に正確に変換
|
||||
var pubDate = ConvertToJst(srcItem.PublishDate);
|
||||
|
||||
// 既存キャッシュの確認
|
||||
existingEntries.TryGetValue(articleUrl, out var prevEntry);
|
||||
if (prevEntry == null && !string.IsNullOrEmpty(guid))
|
||||
{
|
||||
existingEntries.TryGetValue(guid, out prevEntry);
|
||||
}
|
||||
|
||||
// 最新フォーマット(85po-format-v1)を持つ既存キャッシュはそのまま再利用して高速化&未読化防止
|
||||
if (prevEntry != null &&
|
||||
!string.IsNullOrEmpty(prevEntry.SummaryHtml) &&
|
||||
prevEntry.SummaryHtml.Contains(CacheFormatTag))
|
||||
{
|
||||
var cachedItem = new SyndicationItem(
|
||||
prevEntry.Title,
|
||||
(string?)null,
|
||||
itemUri,
|
||||
guid,
|
||||
prevEntry.LastUpdatedTime)
|
||||
{
|
||||
PublishDate = prevEntry.PublishDate,
|
||||
LastUpdatedTime = prevEntry.LastUpdatedTime,
|
||||
Summary = new TextSyndicationContent(prevEntry.SummaryHtml, TextSyndicationContentKind.Html)
|
||||
};
|
||||
|
||||
foreach (var cat in prevEntry.Categories)
|
||||
{
|
||||
cachedItem.Categories.Add(new SyndicationCategory(cat));
|
||||
}
|
||||
|
||||
currentItems.Add(cachedItem);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 新規記事またはフォーマット未更新の記事: 詳細情報取得
|
||||
var rawTitle = srcItem.Title?.Text?.Trim() ?? "タイトルなし";
|
||||
var rawDesc = srcItem.Summary?.Text ?? string.Empty;
|
||||
|
||||
var detailInfo = await FetchVideoDetailAsync(client, articleUrl, rawTitle, rawDesc);
|
||||
var summaryHtml = BuildSummaryHtml(detailInfo, pubDate);
|
||||
|
||||
var newItem = new SyndicationItem(
|
||||
detailInfo.CleanTitle,
|
||||
(string?)null,
|
||||
itemUri,
|
||||
guid,
|
||||
pubDate)
|
||||
{
|
||||
PublishDate = pubDate,
|
||||
LastUpdatedTime = pubDate,
|
||||
Summary = new TextSyndicationContent(summaryHtml, TextSyndicationContentKind.Html)
|
||||
};
|
||||
|
||||
foreach (var tag in detailInfo.Tags)
|
||||
{
|
||||
newItem.Categories.Add(new SyndicationCategory(tag));
|
||||
}
|
||||
|
||||
currentItems.Add(newItem);
|
||||
}
|
||||
|
||||
// 4. 過去記事の差分マージ(最大100件まで保持)
|
||||
foreach (var kvp in existingEntries)
|
||||
{
|
||||
var entry = kvp.Value;
|
||||
if (string.IsNullOrEmpty(kvp.Key) || processedUrls.Contains(kvp.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// URLとして有効なキーのみマージ対象とする
|
||||
if (!Uri.TryCreate(kvp.Key, UriKind.Absolute, out var pastUri))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!processedUrls.Add(kvp.Key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var pastGuid = CmnUtil.CreateGuid(kvp.Key);
|
||||
var pastItem = new SyndicationItem(
|
||||
entry.Title,
|
||||
(string?)null,
|
||||
pastUri,
|
||||
pastGuid,
|
||||
entry.LastUpdatedTime)
|
||||
{
|
||||
PublishDate = entry.PublishDate,
|
||||
LastUpdatedTime = entry.LastUpdatedTime,
|
||||
Summary = new TextSyndicationContent(entry.SummaryHtml, TextSyndicationContentKind.Html)
|
||||
};
|
||||
|
||||
foreach (var cat in entry.Categories)
|
||||
{
|
||||
pastItem.Categories.Add(new SyndicationCategory(cat));
|
||||
}
|
||||
|
||||
currentItems.Add(pastItem);
|
||||
}
|
||||
|
||||
// 5. 日時降順ソートおよび件数制限
|
||||
var finalItems = currentItems
|
||||
.OrderByDescending(x => x.PublishDate)
|
||||
.Take(MaxFeedItems)
|
||||
.ToList();
|
||||
|
||||
feed.Items = finalItems;
|
||||
LogManager.AddLog($"[情報] 【85po】 最終出力アイテム数: {finalItems.Count} 件");
|
||||
|
||||
// 6. XML ファイルへの出力(プロジェクト固有規則: addDir にドメインディレクトリを指定)
|
||||
await CmnUtil.ExportXMLFileAsync(
|
||||
FileName,
|
||||
feed,
|
||||
client,
|
||||
addDir: DomainDir,
|
||||
embedBase64: false,
|
||||
filter24Hours: false);
|
||||
|
||||
LogManager.AddLog($"[情報] 【85po】 RSS 生成完了: output/{DomainDir}/{FileName}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.AddLog($"[エラー] 【85po】 CreateRSSAsync 実行時例外: {ex.Message}");
|
||||
LogManager.AddLog($"{ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region □メソッド(Private)
|
||||
|
||||
/// <summary>
|
||||
/// 動画個別ページを取得し、詳細情報を解析・構築します。
|
||||
/// 取得失敗時はRSSフィード内の情報からフォールバックして安全に構築します。
|
||||
/// </summary>
|
||||
/// <param name="client">HttpClient インスタンス</param>
|
||||
/// <param name="videoUrl">動画ページのURL</param>
|
||||
/// <param name="feedTitle">RSSフィードから取得したタイトル</param>
|
||||
/// <param name="feedDesc">RSSフィードから取得した説明文HTML</param>
|
||||
/// <returns>動画詳細情報オブジェクト</returns>
|
||||
private static async Task<VideoDetailInfo> FetchVideoDetailAsync(
|
||||
HttpClient client,
|
||||
string videoUrl,
|
||||
string feedTitle,
|
||||
string feedDesc)
|
||||
{
|
||||
var cleanTitle = CleanFileNameTitle(feedTitle);
|
||||
var info = new VideoDetailInfo
|
||||
{
|
||||
OriginalTitle = feedTitle,
|
||||
CleanTitle = cleanTitle,
|
||||
VideoUrl = videoUrl
|
||||
};
|
||||
|
||||
// RSS の description からサムネイル画像および説明テキストを初期抽出
|
||||
ExtractFromFeedDescription(feedDesc, info);
|
||||
|
||||
try
|
||||
{
|
||||
using var request = new HttpRequestMessage(HttpMethod.Get, videoUrl);
|
||||
request.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36");
|
||||
request.Headers.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
|
||||
|
||||
using var response = await client.SendAsync(request);
|
||||
if (response.IsSuccessStatusCode)
|
||||
{
|
||||
var html = await response.Content.ReadAsStringAsync();
|
||||
var parser = new HtmlParser();
|
||||
using var document = await parser.ParseDocumentAsync(html);
|
||||
|
||||
// タイトル取得
|
||||
var h1Title = document.QuerySelector(".headline-video h1")?.TextContent?.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(h1Title))
|
||||
{
|
||||
info.OriginalTitle = h1Title;
|
||||
info.CleanTitle = CleanFileNameTitle(h1Title);
|
||||
}
|
||||
|
||||
// 再生時間取得
|
||||
var durationText = document.QuerySelector(".headline-item i.icon-playlist ~ span.text")?.TextContent?.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(durationText))
|
||||
{
|
||||
info.Duration = durationText;
|
||||
}
|
||||
|
||||
// 高画質プレビュー画像(og:image)
|
||||
var ogImage = document.QuerySelector("meta[property='og:image']")?.GetAttribute("content")?.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(ogImage))
|
||||
{
|
||||
info.PreviewImageUrl = ogImage;
|
||||
}
|
||||
|
||||
// 説明文
|
||||
var desc = document.QuerySelector("meta[name='description']")?.GetAttribute("content")?.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(desc) && string.IsNullOrWhiteSpace(info.Description))
|
||||
{
|
||||
info.Description = desc;
|
||||
}
|
||||
|
||||
// タグ・カテゴリ
|
||||
var tagElements = document.QuerySelectorAll("ul.tags-list a.tags-link");
|
||||
foreach (var tagEl in tagElements)
|
||||
{
|
||||
var tagText = tagEl.TextContent?.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(tagText) && !info.Tags.Contains(tagText))
|
||||
{
|
||||
info.Tags.Add(tagText);
|
||||
}
|
||||
}
|
||||
|
||||
// ダウンロード直リンク (MP4) の取得
|
||||
var downloadAnchor = document.QuerySelector("div.block-details a[href*='/get_file/']");
|
||||
if (downloadAnchor != null)
|
||||
{
|
||||
var rawDownloadHref = downloadAnchor.GetAttribute("href")?.Trim() ?? string.Empty;
|
||||
if (!string.IsNullOrWhiteSpace(rawDownloadHref))
|
||||
{
|
||||
info.DownloadUrl = rawDownloadHref.StartsWith("http", StringComparison.OrdinalIgnoreCase)
|
||||
? rawDownloadHref
|
||||
: $"{BaseUrl.TrimEnd('/')}/{rawDownloadHref.TrimStart('/')}";
|
||||
info.DownloadLabel = downloadAnchor.TextContent?.Trim() ?? "MP4 動画ダウンロード";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.AddLog($"[警告] 【85po】 詳細ページ取得スキップ ({videoUrl}): {ex.Message}");
|
||||
}
|
||||
|
||||
// 高解像度プレビュー画像が未設定で、サムネイルが取得できている場合はプレビュー画像パスを自動推定
|
||||
if (string.IsNullOrEmpty(info.PreviewImageUrl) && !string.IsNullOrEmpty(info.ThumbnailUrl))
|
||||
{
|
||||
// 例: https://www.85po.com/contents/videos_screenshots/37000/37405/320x180/1.jpg
|
||||
// → https://www.85po.com/contents/videos_screenshots/37000/37405/preview.jpg
|
||||
info.PreviewImageUrl = Regex.Replace(info.ThumbnailUrl, @"/\d+x\d+/\d+\.jpg$", "/preview.jpg");
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// RSSフィードの description HTML からサムネイル画像および説明テキストを抽出します。
|
||||
/// </summary>
|
||||
/// <param name="feedDesc">RSSフィードの説明文HTML</param>
|
||||
/// <param name="info">格納先オブジェクト</param>
|
||||
private static void ExtractFromFeedDescription(string feedDesc, VideoDetailInfo info)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(feedDesc))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
var parser = new HtmlParser();
|
||||
using var doc = parser.ParseDocument($"<html><body>{feedDesc}</body></html>");
|
||||
|
||||
var img = doc.QuerySelector("img");
|
||||
var src = img?.GetAttribute("src")?.Trim();
|
||||
if (!string.IsNullOrEmpty(src))
|
||||
{
|
||||
info.ThumbnailUrl = src;
|
||||
}
|
||||
|
||||
var text = doc.Body?.TextContent?.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
info.Description = text;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// 解析エラー時はフォールバックとして正規表現による抽出を試行
|
||||
var imgMatch = Regex.Match(feedDesc, @"<img\s+[^>]*src=[""']([^""']+)[""']", RegexOptions.IgnoreCase);
|
||||
if (imgMatch.Success)
|
||||
{
|
||||
info.ThumbnailUrl = imgMatch.Groups[1].Value.Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 記事の本文 HTML (Summary) を構築します。
|
||||
/// WebImageViewer へのリンク、フォルダ名ワンクリックコピー枠、ダウンロードボタン等を配置します。
|
||||
/// </summary>
|
||||
/// <param name="info">動画詳細情報</param>
|
||||
/// <param name="pubDate">日本時間の公開日時</param>
|
||||
/// <returns>本文 HTML 文字列</returns>
|
||||
private static string BuildSummaryHtml(VideoDetailInfo info, DateTimeOffset pubDate)
|
||||
{
|
||||
var sb = new StringBuilder();
|
||||
|
||||
// 1. フォーマット識別タグ(キャッシュ判定用)
|
||||
sb.AppendLine($"<!-- {CacheFormatTag} -->");
|
||||
|
||||
// 2. Windows フォルダ名用タイトル(クリックで全選択)枠 (AGENTS.md 規則 4.2)
|
||||
sb.AppendLine("<div style=\"margin-bottom: 16px; background-color: #f8f9fa; border: 1px solid #ced4da; border-radius: 6px; padding: 10px;\">");
|
||||
sb.AppendLine(" <div style=\"font-size: 11px; color: #6c757d; font-weight: bold; margin-bottom: 4px;\">📁 フォルダ名用タイトル(クリックで全選択)</div>");
|
||||
sb.AppendLine($" <input type=\"text\" readonly value=\"{WebUtility.HtmlEncode(info.CleanTitle)}\" onclick=\"this.select();\" style=\"width: 100%; padding: 6px 10px; font-size: 13px; font-family: Consolas, monospace; background-color: #ffffff; border: 1px solid #adb5bd; border-radius: 4px; box-sizing: border-box; cursor: pointer; color: #212529;\" />");
|
||||
sb.AppendLine("</div>");
|
||||
|
||||
// 3. WebImageViewer への再生リンク & 85PO公式ページリンク
|
||||
var viewerUrl = $"{WebImageViewerBaseUrl}{Uri.EscapeDataString(info.VideoUrl)}";
|
||||
sb.AppendLine("<div style=\"margin-bottom: 14px; padding: 12px 16px; background: rgba(218, 40, 88, 0.08); border-radius: 8px; border-left: 4px solid #da2858;\">");
|
||||
sb.AppendLine($" <p style=\"margin: 0 0 6px 0;\"><a href=\"{viewerUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" style=\"font-weight: bold; font-size: 1.15em; color: #da2858; text-decoration: none;\">▶ WebImageViewerで動画を再生する</a></p>");
|
||||
sb.AppendLine($" <p style=\"margin: 0; font-size: 0.9em; color: #64748b;\"><a href=\"{info.VideoUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" referrerpolicy=\"no-referrer\" style=\"color: #475569; text-decoration: underline;\">85PO公式ページで開く</a></p>");
|
||||
sb.AppendLine("</div>");
|
||||
|
||||
// 4. ダウンロードリンク直リンク配置 (AGENTS.md 規則 5)
|
||||
if (!string.IsNullOrEmpty(info.DownloadUrl))
|
||||
{
|
||||
var label = string.IsNullOrEmpty(info.DownloadLabel) ? "MP4 ダウンロード" : info.DownloadLabel;
|
||||
sb.AppendLine("<div style=\"margin-bottom: 14px;\">");
|
||||
sb.AppendLine(" <div style=\"font-size: 11px; color: #6c757d; font-weight: bold; margin-bottom: 6px;\">📥 ダウンロード</div>");
|
||||
sb.AppendLine(" <div style=\"display: flex; flex-wrap: wrap; gap: 8px;\">");
|
||||
sb.AppendLine($" <a href=\"{info.DownloadUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" referrerpolicy=\"no-referrer\" style=\"display: inline-flex; align-items: center; padding: 8px 14px; background-color: #da2858; color: #ffffff; text-decoration: none; border-radius: 4px; font-weight: bold; font-size: 13px;\">💾 {WebUtility.HtmlEncode(label)}</a>");
|
||||
sb.AppendLine(" </div>");
|
||||
sb.AppendLine("</div>");
|
||||
}
|
||||
|
||||
// 5. 日本時間表示 (AGENTS.md 規則 3.2)
|
||||
sb.AppendLine("<div style=\"margin-bottom: 12px;\">");
|
||||
sb.AppendLine($" <span style=\"font-size: 11px; color: #6c757d; font-weight: bold;\">📅 {pubDate:yyyy/MM/dd HH:mm:ss} (JST)</span>");
|
||||
if (!string.IsNullOrWhiteSpace(info.Duration))
|
||||
{
|
||||
sb.AppendLine($" <span style=\"font-size: 11px; color: #475569; font-weight: bold; margin-left: 12px;\">⏱ 再生時間: {WebUtility.HtmlEncode(info.Duration)}</span>");
|
||||
}
|
||||
sb.AppendLine("</div>");
|
||||
|
||||
// 6. カバー画像 / プレビュー画像表示 (AGENTS.md 規則 6)
|
||||
var displayImgUrl = !string.IsNullOrEmpty(info.PreviewImageUrl) ? info.PreviewImageUrl : info.ThumbnailUrl;
|
||||
if (!string.IsNullOrEmpty(displayImgUrl))
|
||||
{
|
||||
sb.AppendLine("<div style=\"margin-bottom: 14px; text-align: center;\">");
|
||||
sb.AppendLine($" <a href=\"{info.VideoUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" referrerpolicy=\"no-referrer\">");
|
||||
sb.AppendLine($" <img src=\"{displayImgUrl}\" referrerpolicy=\"no-referrer\" alt=\"{WebUtility.HtmlEncode(info.OriginalTitle)}\" style=\"max-width: 100%; height: auto; border-radius: 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.15);\" />");
|
||||
sb.AppendLine(" </a>");
|
||||
sb.AppendLine("</div>");
|
||||
}
|
||||
|
||||
// 7. 説明文およびタグ
|
||||
if (!string.IsNullOrWhiteSpace(info.Description))
|
||||
{
|
||||
sb.AppendLine("<div style=\"margin-bottom: 10px; font-size: 13px; color: #334155; line-height: 1.5;\">");
|
||||
sb.AppendLine($" <strong>説明:</strong> {WebUtility.HtmlEncode(info.Description)}");
|
||||
sb.AppendLine("</div>");
|
||||
}
|
||||
|
||||
if (info.Tags.Count > 0)
|
||||
{
|
||||
sb.AppendLine("<div style=\"margin-bottom: 8px; font-size: 12px; color: #64748b;\">");
|
||||
sb.AppendLine($" <strong>タグ:</strong> {WebUtility.HtmlEncode(string.Join(", ", info.Tags))}");
|
||||
sb.AppendLine("</div>");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// タイトル文字列から Windows フォルダ名に使用できない禁止文字を全角に置換します。
|
||||
/// </summary>
|
||||
/// <param name="rawTitle">元のタイトル文字列</param>
|
||||
/// <returns>整形後のタイトル文字列</returns>
|
||||
private static string CleanFileNameTitle(string rawTitle)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(rawTitle))
|
||||
{
|
||||
return "タイトルなし";
|
||||
}
|
||||
|
||||
var title = rawTitle.Trim();
|
||||
|
||||
// Windows 禁止文字 \ / : * ? " < > | を全角文字へ置換
|
||||
title = title
|
||||
.Replace('\\', '¥')
|
||||
.Replace('/', '/')
|
||||
.Replace(':', ':')
|
||||
.Replace('*', '*')
|
||||
.Replace('?', '?')
|
||||
.Replace('"', '”')
|
||||
.Replace('<', '<')
|
||||
.Replace('>', '>')
|
||||
.Replace('|', '|');
|
||||
|
||||
// 連続空白を1つに統合
|
||||
title = Regex.Replace(title, @"\s+", " ").Trim();
|
||||
|
||||
return title;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// DateTimeOffset を正確な日本時間 (JST = UTC+9) に変換します。
|
||||
/// </summary>
|
||||
/// <param name="dto">変換元の DateTimeOffset</param>
|
||||
/// <returns>日本時間 (UTC+9) の DateTimeOffset</returns>
|
||||
private static DateTimeOffset ConvertToJst(DateTimeOffset dto)
|
||||
{
|
||||
if (dto == default)
|
||||
{
|
||||
return DateTimeOffset.Now;
|
||||
}
|
||||
|
||||
return dto.ToOffset(TimeSpan.FromHours(9));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 既存の RSS フィードファイルから記事エントリを読み込みます。
|
||||
/// </summary>
|
||||
/// <param name="fileName">ファイル名</param>
|
||||
/// <param name="addDir">ドメインサブディレクトリ名</param>
|
||||
/// <returns>記事URLおよびGUIDをキーとする辞書</returns>
|
||||
private static Dictionary<string, ExistingFeedEntry> LoadExistingEntries(string fileName, string addDir = "")
|
||||
{
|
||||
var existingEntries = new Dictionary<string, ExistingFeedEntry>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
try
|
||||
{
|
||||
string xmlPath = CmnUtil.GetExportXmlPath(fileName, addDir);
|
||||
if (!File.Exists(xmlPath) && !string.IsNullOrEmpty(addDir))
|
||||
{
|
||||
xmlPath = CmnUtil.GetExportXmlPath(fileName);
|
||||
}
|
||||
|
||||
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 ?? string.Empty,
|
||||
SummaryHtml = item.Summary?.Text ?? string.Empty,
|
||||
PublishDate = item.PublishDate,
|
||||
LastUpdatedTime = item.LastUpdatedTime
|
||||
};
|
||||
|
||||
foreach (var cat in item.Categories)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(cat.Name))
|
||||
{
|
||||
entry.Categories.Add(cat.Name);
|
||||
}
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(linkUrl) && !existingEntries.ContainsKey(linkUrl))
|
||||
{
|
||||
existingEntries[linkUrl] = entry;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(guid) && !existingEntries.ContainsKey(guid))
|
||||
{
|
||||
existingEntries[guid] = entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LogManager.AddLog($"[警告] 【85po】 既存フィード読み込みスキップ: {ex.Message}");
|
||||
}
|
||||
|
||||
return existingEntries;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -16,7 +16,9 @@ using rss_generator.Class.Mangalear;
|
||||
using rss_generator.Class.MissAV;
|
||||
using rss_generator.Class.MissAV123;
|
||||
using rss_generator.Class.Momonga;
|
||||
using rss_generator.Class.OtomiGames;
|
||||
using rss_generator.Class.Pixiv;
|
||||
using rss_generator.Class.Po85;
|
||||
using rss_generator.Class.Ryuugames;
|
||||
using rss_generator.Class.Skebetter;
|
||||
using rss_generator.Class.SpankBang;
|
||||
@@ -99,18 +101,22 @@ while (true)
|
||||
var nonFlareActions = new List<(string Name, Func<HttpClient, Task> Action)>();
|
||||
|
||||
#if DEBUG
|
||||
nonFlareActions.Add(("85po", client => po85.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("YouTube", client => YouTubeFeedManager.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("ryuugames", client => ryuugames.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("japaneseavi", client => japaneseavi.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("jpfiles", client => jpfiles.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("otomigames", client => otomigames.CreateRSSAsync(client)));
|
||||
#else
|
||||
// ※ movie.eroterest.net は取得処理停止のため除外
|
||||
nonFlareActions.Add(("85po", client => po85.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("ryuugames", client => ryuugames.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("YouTube", client => YouTubeFeedManager.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("X (Twitter)", client => x_list.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("kimochiinfo", client => kimochiinfo.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("japaneseavi", client => japaneseavi.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("jpfiles", client => jpfiles.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("otomigames", client => otomigames.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("ci_en", client => ci_en.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("javtwi", client => javtwi.CreateRSSAsync(client)));
|
||||
nonFlareActions.Add(("mangalear", client => mangalear.CreateRSSAsync(client)));
|
||||
|
||||
Reference in new issue
Block a user