diff --git a/WebImageViewer/Class/Renderers/HtmlRenderer.cs b/WebImageViewer/Class/Renderers/HtmlRenderer.cs
index 00cce5e..3173fa7 100644
--- a/WebImageViewer/Class/Renderers/HtmlRenderer.cs
+++ b/WebImageViewer/Class/Renderers/HtmlRenderer.cs
@@ -1797,6 +1797,35 @@ public static class HtmlRenderer
switch (normalizedSite)
{
+ case "inporn":
+ siteDisplayName = "InPorn";
+ badgeText = "INPORN VIDEO";
+ accentGradient = "linear-gradient(135deg, #e45257 0%, #f43f5e 100%)";
+ accentPrimary = "#e45257";
+ glowColor = "rgba(228, 82, 87, 0.3)";
+ defaultOrigUrl = $"https://inporn.com/video/{safeId}/";
+ playerUrl ??= $"https://inporn.com/embed/{safeId}/";
+ break;
+
+ case "bdsmx":
+ siteDisplayName = "BDSMx";
+ badgeText = "BDSMX TUBE";
+ accentGradient = "linear-gradient(135deg, #8b5cf6 0%, #6366f1 100%)";
+ accentPrimary = "#8b5cf6";
+ glowColor = "rgba(139, 92, 246, 0.3)";
+ defaultOrigUrl = $"https://bdsmx.tube/video/{safeId}/";
+ playerUrl ??= $"https://bdsmx.tube/embed/{safeId}/";
+ break;
+
+ case "galgaldoga":
+ siteDisplayName = "GalGalドーガ";
+ badgeText = "GALGAL DOGA";
+ accentGradient = "linear-gradient(135deg, #ec4899 0%, #f43f5e 50%, #fb7185 100%)";
+ accentPrimary = "#ec4899";
+ glowColor = "rgba(236, 72, 153, 0.3)";
+ defaultOrigUrl = $"https://galgaldoga.blogterest.net/page/{safeId}/";
+ break;
+
case "doga":
case "eroterest_doga":
siteDisplayName = "エロタレドーガ";
diff --git a/WebImageViewer/Class/Services/VideoUrlResolver.cs b/WebImageViewer/Class/Services/VideoUrlResolver.cs
new file mode 100644
index 0000000..c357519
--- /dev/null
+++ b/WebImageViewer/Class/Services/VideoUrlResolver.cs
@@ -0,0 +1,432 @@
+using System.Text.RegularExpressions;
+using HtmlAgilityPack;
+using Microsoft.Extensions.Logging;
+using WebImageViewer.Class.Common;
+
+namespace WebImageViewer.Class.Services;
+
+///
+/// 解決された動画情報モデル
+///
+public record ResolvedVideoResult
+{
+ public string Site { get; init; } = "video";
+ public string VideoId { get; init; } = "video";
+ public string? PlayerUrl { get; init; }
+ public string? StreamUrl { get; init; }
+ public string? OriginalUrl { get; init; }
+ public string? Title { get; init; }
+ public bool IsSuccess { get; init; }
+ public string? ErrorMessage { get; init; }
+}
+
+///
+/// 記事リンク(galgaldoga等)や各種動画サイトのURLから、実際の動画再生情報(embed/stream/ID等)を自動探索・解決するサービス
+///
+public class VideoUrlResolver
+{
+ private readonly HttpHelper _httpHelper;
+ private readonly ILogger _logger;
+
+ public VideoUrlResolver(HttpHelper httpHelper, ILogger logger)
+ {
+ _httpHelper = httpHelper;
+ _logger = logger;
+ }
+
+ ///
+ /// URLを解析し、実動画のプレイヤー情報を解決します。
+ ///
+ public async Task ResolveAsync(string targetUrl, string? customTitle = null, CancellationToken ct = default)
+ {
+ if (string.IsNullOrWhiteSpace(targetUrl))
+ {
+ return new ResolvedVideoResult { IsSuccess = false, ErrorMessage = "URLが指定されていません。" };
+ }
+
+ var trimmedUrl = targetUrl.Trim();
+
+ // 1. 直接指定されたURLが既に既知の動画サイトであるかチェック
+ var directResult = TryResolveDirectVideoHost(trimmedUrl, customTitle);
+ if (directResult != null)
+ {
+ return directResult;
+ }
+
+ // 2. 記事ページ(まとめブログ、galgaldoga、エロタレスト等)と判定し、HTMLを取得して内部の実動画リンクを探索
+ try
+ {
+ return await ResolveFromArticlePageAsync(trimmedUrl, customTitle, 1, ct);
+ }
+ catch (Exception ex)
+ {
+ _logger.LogWarning(ex, "記事ページからの動画解決中にエラーが発生しました: {Url}", trimmedUrl);
+ return new ResolvedVideoResult
+ {
+ IsSuccess = false,
+ OriginalUrl = trimmedUrl,
+ ErrorMessage = $"記事ページの動画解決に失敗しました: {ex.Message}"
+ };
+ }
+ }
+
+ ///
+ /// 直接動画ホストのURLから動画情報を判定します。
+ ///
+ public ResolvedVideoResult? TryResolveDirectVideoHost(string url, string? title = null)
+ {
+ // InPorn
+ if (url.Contains("inporn.com", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"/video/([0-9]+)");
+ var id = match.Success ? match.Groups[1].Value : "video";
+ return new ResolvedVideoResult
+ {
+ Site = "inporn",
+ VideoId = id,
+ PlayerUrl = $"https://inporn.com/embed/{id}/",
+ OriginalUrl = url,
+ Title = title ?? $"InPorn 動画 ({id})",
+ IsSuccess = true
+ };
+ }
+
+ // BDSMx Tube
+ if (url.Contains("bdsmx.tube", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"/video/([0-9]+)");
+ var id = match.Success ? match.Groups[1].Value : "video";
+ return new ResolvedVideoResult
+ {
+ Site = "bdsmx",
+ VideoId = id,
+ PlayerUrl = $"https://bdsmx.tube/embed/{id}/",
+ OriginalUrl = url,
+ Title = title ?? $"BDSMx 動画 ({id})",
+ IsSuccess = true
+ };
+ }
+
+ // Senzuri
+ if (url.Contains("senzuri.tube", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"/videos/([0-9]+)");
+ var id = match.Success ? match.Groups[1].Value : "video";
+ return new ResolvedVideoResult
+ {
+ Site = "senzuri",
+ VideoId = id,
+ PlayerUrl = $"https://senzuri.tube/embed/{id}/",
+ OriginalUrl = url,
+ Title = title ?? $"Senzuri 動画 ({id})",
+ IsSuccess = true
+ };
+ }
+
+ // TXXX
+ if (url.Contains("txxx.com", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"/videos/([0-9]+)");
+ var id = match.Success ? match.Groups[1].Value : "video";
+ return new ResolvedVideoResult
+ {
+ Site = "txxx",
+ VideoId = id,
+ PlayerUrl = $"https://www.txxx.com/embed/{id}/",
+ OriginalUrl = url,
+ Title = title ?? $"TXXX 動画 ({id})",
+ IsSuccess = true
+ };
+ }
+
+ // HClips
+ if (url.Contains("hclips.com", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"/videos/([0-9]+)");
+ var id = match.Success ? match.Groups[1].Value : "video";
+ return new ResolvedVideoResult
+ {
+ Site = "hclips",
+ VideoId = id,
+ PlayerUrl = $"https://www.hclips.com/embed/{id}/",
+ OriginalUrl = url,
+ Title = title ?? $"HClips 動画 ({id})",
+ IsSuccess = true
+ };
+ }
+
+ // HDZog
+ if (url.Contains("hdzog.com", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"/videos/([0-9]+)");
+ var id = match.Success ? match.Groups[1].Value : "video";
+ return new ResolvedVideoResult
+ {
+ Site = "hdzog",
+ VideoId = id,
+ PlayerUrl = $"https://www.hdzog.com/embed/{id}/",
+ OriginalUrl = url,
+ Title = title ?? $"HDZog 動画 ({id})",
+ IsSuccess = true
+ };
+ }
+
+ // Upornia
+ if (url.Contains("upornia.com", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"/videos/([0-9]+)");
+ var id = match.Success ? match.Groups[1].Value : "video";
+ return new ResolvedVideoResult
+ {
+ Site = "upornia",
+ VideoId = id,
+ PlayerUrl = $"https://upornia.com/embed/{id}/",
+ OriginalUrl = url,
+ Title = title ?? $"Upornia 動画 ({id})",
+ IsSuccess = true
+ };
+ }
+
+ // YouJizz
+ if (url.Contains("youjizz.com", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"/videos/([0-9]+)");
+ var id = match.Success ? match.Groups[1].Value : "video";
+ return new ResolvedVideoResult
+ {
+ Site = "youjizz",
+ VideoId = id,
+ PlayerUrl = $"https://www.youjizz.com/embed/{id}",
+ OriginalUrl = url,
+ Title = title ?? $"YouJizz 動画 ({id})",
+ IsSuccess = true
+ };
+ }
+
+ // エロタレドーガ
+ if (url.Contains("do-ga.eroterest.net", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"detail/([0-9]+)");
+ var id = match.Success ? match.Groups[1].Value : "doga";
+ return new ResolvedVideoResult
+ {
+ Site = "doga",
+ VideoId = id,
+ OriginalUrl = url,
+ Title = title ?? $"エロタレドーガ ({id})",
+ IsSuccess = true
+ };
+ }
+
+ // SpankBang
+ if (url.Contains("spankbang.com", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"(?:jp\.)?spankbang\.com/([a-zA-Z0-9]+)/video");
+ var id = match.Success ? match.Groups[1].Value : "video";
+ return new ResolvedVideoResult
+ {
+ Site = "spankbang",
+ VideoId = id,
+ PlayerUrl = $"https://spankbang.com/{id}/embed/",
+ OriginalUrl = url,
+ Title = title ?? $"SpankBang 動画 ({id})",
+ IsSuccess = true
+ };
+ }
+
+ // 123av
+ if (url.Contains("123av", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"video/([a-zA-Z0-9_-]+)");
+ var id = match.Success ? match.Groups[1].Value : "video";
+ return new ResolvedVideoResult
+ {
+ Site = "123av",
+ VideoId = id,
+ PlayerUrl = $"https://javplayer.cc/v/{id}",
+ OriginalUrl = url,
+ Title = title ?? $"123av 動画 ({id})",
+ IsSuccess = true
+ };
+ }
+
+ // MissAV
+ if (url.Contains("missav", StringComparison.OrdinalIgnoreCase))
+ {
+ var match = Regex.Match(url, @"/(?:ja/)?([a-zA-Z0-9_-]+)(?:$|\?)");
+ var id = match.Success ? match.Groups[1].Value : "video";
+ return new ResolvedVideoResult
+ {
+ Site = "missav",
+ VideoId = id,
+ OriginalUrl = url,
+ Title = title ?? $"missav 動画 ({id})",
+ IsSuccess = true
+ };
+ }
+
+ return null;
+ }
+
+ ///
+ /// 記事HTMLを取得し、「動画の再生はこちらから」等のリンク先実動画を特定します。
+ ///
+ private async Task ResolveFromArticlePageAsync(
+ string pageUrl,
+ string? customTitle,
+ int currentDepth,
+ CancellationToken ct)
+ {
+ if (currentDepth > 3)
+ {
+ return new ResolvedVideoResult
+ {
+ IsSuccess = false,
+ OriginalUrl = pageUrl,
+ ErrorMessage = "探索階層の深さ上限(3階層)に達しました。"
+ };
+ }
+
+ var html = await _httpHelper.GetHtmlAsync(pageUrl, ct);
+ if (string.IsNullOrWhiteSpace(html))
+ {
+ return new ResolvedVideoResult
+ {
+ IsSuccess = false,
+ OriginalUrl = pageUrl,
+ ErrorMessage = "記事HTMLを取得できませんでした。"
+ };
+ }
+
+ var doc = new HtmlDocument();
+ doc.LoadHtml(html);
+
+ // 記事タイトルの抽出(未指定の場合)
+ var pageTitle = customTitle;
+ if (string.IsNullOrWhiteSpace(pageTitle))
+ {
+ var titleNode = doc.DocumentNode.SelectSingleNode("//meta[@property='og:title']/@content")
+ ?? doc.DocumentNode.SelectSingleNode("//title")
+ ?? doc.DocumentNode.SelectSingleNode("//h1")
+ ?? doc.DocumentNode.SelectSingleNode("//div[contains(@class, 'itemTitle')]")
+ ?? doc.DocumentNode.SelectSingleNode("//div[contains(@class, 'entryTitle')]");
+ pageTitle = titleNode?.InnerText?.Trim() ?? titleNode?.GetAttributeValue("content", "")?.Trim();
+ if (!string.IsNullOrWhiteSpace(pageTitle))
+ {
+ // 「 - GalGalドーガ」等のサイト名サフィックスを除去
+ pageTitle = Regex.Replace(pageTitle, @"\s*[-|–]\s*(?:GalGalドーガ|動画エロタレスト|blogterest).*$", "", RegexOptions.IgnoreCase).Trim();
+ }
+ }
+
+ // 1. 【最重要】「動画の再生はこちらから」リンクを探索 (galgaldoga等)
+ string? candidateVideoUrl = null;
+
+ // A. テキストが「動画の再生はこちらから」を含む a タグ
+ var playTextLinks = doc.DocumentNode.SelectNodes("//a[contains(text(), '動画の再生はこちらから') or contains(text(), '動画の再生')]");
+ if (playTextLinks != null && playTextLinks.Count > 0)
+ {
+ candidateVideoUrl = playTextLinks[0].GetAttributeValue("href", "")?.Trim();
+ }
+
+ // B. .movie-frame 配下の a タグ
+ if (string.IsNullOrWhiteSpace(candidateVideoUrl))
+ {
+ var movieFrameLink = doc.DocumentNode.SelectSingleNode("//div[contains(@class, 'movie-frame')]//a[@href]");
+ candidateVideoUrl = movieFrameLink?.GetAttributeValue("href", "")?.Trim();
+ }
+
+ // C. エロタレスト記事の場合: .gotoBlog a
+ if (string.IsNullOrWhiteSpace(candidateVideoUrl))
+ {
+ var gotoBlog = doc.DocumentNode.SelectSingleNode("//div[contains(@class, 'gotoBlog')]//a[@href]");
+ if (gotoBlog != null)
+ {
+ var nextBlogUrl = gotoBlog.GetAttributeValue("href", "")?.Trim();
+ if (!string.IsNullOrWhiteSpace(nextBlogUrl))
+ {
+ // 中間まとめブログへ再帰探索
+ return await ResolveFromArticlePageAsync(nextBlogUrl, pageTitle, currentDepth + 1, ct);
+ }
+ }
+ }
+
+ // D. エロタレドーガの埋め込み・JSON-LD (contentUrl) がある場合
+ var jsonLdNodes = doc.DocumentNode.SelectNodes("//script[@type='application/ld+json']");
+ if (jsonLdNodes != null)
+ {
+ foreach (var node in jsonLdNodes)
+ {
+ var json = node.InnerText;
+ var match = Regex.Match(json, @"""contentUrl""\s*:\s*""(https?:[^""]+\.m3u8[^""]*)""");
+ if (match.Success)
+ {
+ var streamUrl = match.Groups[1].Value.Replace(@"\/", "/");
+ return new ResolvedVideoResult
+ {
+ Site = "doga",
+ VideoId = "doga",
+ StreamUrl = streamUrl,
+ OriginalUrl = pageUrl,
+ Title = pageTitle ?? "エロタレドーガ",
+ IsSuccess = true
+ };
+ }
+ }
+ }
+
+ // E. 本文内のすべての a タグから既知の動画ホスト(inporn, bdsmx, doga, senzuri, txxx, etc.)を探索
+ if (string.IsNullOrWhiteSpace(candidateVideoUrl))
+ {
+ var allLinks = doc.DocumentNode.SelectNodes("//a[@href]");
+ if (allLinks != null)
+ {
+ foreach (var a in allLinks)
+ {
+ var href = a.GetAttributeValue("href", "")?.Trim();
+ if (string.IsNullOrWhiteSpace(href)) continue;
+
+ if (href.Contains("inporn.com/video/", StringComparison.OrdinalIgnoreCase) ||
+ href.Contains("bdsmx.tube/video/", StringComparison.OrdinalIgnoreCase) ||
+ href.Contains("do-ga.eroterest.net/video/", StringComparison.OrdinalIgnoreCase) ||
+ href.Contains("senzuri.tube/videos/", StringComparison.OrdinalIgnoreCase) ||
+ href.Contains("txxx.com/videos/", StringComparison.OrdinalIgnoreCase) ||
+ href.Contains("hclips.com/videos/", StringComparison.OrdinalIgnoreCase) ||
+ href.Contains("hdzog.com/videos/", StringComparison.OrdinalIgnoreCase) ||
+ href.Contains("upornia.com/videos/", StringComparison.OrdinalIgnoreCase) ||
+ href.Contains("youjizz.com/videos/", StringComparison.OrdinalIgnoreCase) ||
+ href.Contains("video.laxd.com/a/content/", StringComparison.OrdinalIgnoreCase) ||
+ href.Contains("spankbang.com/", StringComparison.OrdinalIgnoreCase))
+ {
+ candidateVideoUrl = href;
+ break;
+ }
+ }
+ }
+ }
+
+ // 候補URLが見つかった場合
+ if (!string.IsNullOrWhiteSpace(candidateVideoUrl))
+ {
+ // URLが直接動画ホストであれば即座に解決結果を構築
+ var resolved = TryResolveDirectVideoHost(candidateVideoUrl, pageTitle);
+ if (resolved != null)
+ {
+ return resolved;
+ }
+
+ // まだ別のブログ等であれば再帰探索
+ return await ResolveFromArticlePageAsync(candidateVideoUrl, pageTitle, currentDepth + 1, ct);
+ }
+
+ // 見つからなかった場合は汎用結果として返す
+ return new ResolvedVideoResult
+ {
+ Site = "video",
+ VideoId = "video",
+ OriginalUrl = pageUrl,
+ Title = pageTitle ?? "動画プレイヤー",
+ IsSuccess = false,
+ ErrorMessage = "ページ内から実動画リンク(動画の再生はこちらから等)を検出できませんでした。"
+ };
+ }
+}
diff --git a/WebImageViewer/Program.cs b/WebImageViewer/Program.cs
index 5315010..b09460d 100644
--- a/WebImageViewer/Program.cs
+++ b/WebImageViewer/Program.cs
@@ -43,6 +43,9 @@ builder.Services.AddScoped();
// ギャラリー統括管理サービスの登録
builder.Services.AddScoped();
+// 動画URL・記事解決サービスの登録
+builder.Services.AddScoped();
+
// VPS / Caddy リバースプロキシ環境対応のフォワードヘッダー設定
builder.Services.Configure(options =>
{
@@ -111,7 +114,15 @@ app.MapGet("/view", async (string? url, string? site, string? id, string? catego
});
// 汎用動画プレイヤー画面
-app.MapGet("/video", (string? url, string? id, string? site, string? play, string? stream, string? title) =>
+app.MapGet("/video", async (
+ string? url,
+ string? id,
+ string? site,
+ string? play,
+ string? stream,
+ string? title,
+ VideoUrlResolver resolver,
+ CancellationToken ct) =>
{
var target = url ?? id;
if (string.IsNullOrWhiteSpace(target) && string.IsNullOrWhiteSpace(stream) && string.IsNullOrWhiteSpace(play))
@@ -119,6 +130,22 @@ app.MapGet("/video", (string? url, string? id, string? site, string? play, strin
return Results.Redirect("/");
}
+ // 1. target が URL かつ play/stream が渡されていない場合、記事URL(galgaldoga等)または未解決動画URLを自動探索
+ if (target != null && target.StartsWith("http", StringComparison.OrdinalIgnoreCase) && string.IsNullOrWhiteSpace(play) && string.IsNullOrWhiteSpace(stream))
+ {
+ // 直接の動画ホスト判定または記事ページからの実動画解決
+ var resolved = await resolver.ResolveAsync(target, title, ct);
+ if (resolved.IsSuccess)
+ {
+ site ??= resolved.Site;
+ id ??= resolved.VideoId;
+ play ??= resolved.PlayerUrl;
+ stream ??= resolved.StreamUrl;
+ title ??= resolved.Title;
+ target = resolved.OriginalUrl ?? target;
+ }
+ }
+
// 123av 判定
if (string.Equals(site, "123av", StringComparison.OrdinalIgnoreCase) || (target != null && target.Contains("123av", StringComparison.OrdinalIgnoreCase)))
{
@@ -152,6 +179,24 @@ app.MapGet("/video", (string? url, string? id, string? site, string? play, strin
return Results.Content(HtmlRenderer.RenderVideoPlayer("doga", vId, play, stream, orig, title ?? $"エロタレドーガ ({vId})"), "text/html; charset=utf-8");
}
+ // InPorn 判定
+ if (string.Equals(site, "inporn", StringComparison.OrdinalIgnoreCase) || (target != null && target.Contains("inporn.com", StringComparison.OrdinalIgnoreCase)))
+ {
+ var vId = id?.Trim() ?? (target != null ? System.Text.RegularExpressions.Regex.Match(target, @"/video/([0-9]+)").Groups[1].Value : "") ?? "video";
+ play ??= $"https://inporn.com/embed/{vId}/";
+ var orig = (target != null && target.StartsWith("http", StringComparison.OrdinalIgnoreCase)) ? target : $"https://inporn.com/video/{vId}/";
+ return Results.Content(HtmlRenderer.RenderVideoPlayer("inporn", vId, play, stream, orig, title ?? $"InPorn 動画 ({vId})"), "text/html; charset=utf-8");
+ }
+
+ // BDSMx 判定
+ if (string.Equals(site, "bdsmx", StringComparison.OrdinalIgnoreCase) || (target != null && target.Contains("bdsmx.tube", StringComparison.OrdinalIgnoreCase)))
+ {
+ var vId = id?.Trim() ?? (target != null ? System.Text.RegularExpressions.Regex.Match(target, @"/video/([0-9]+)").Groups[1].Value : "") ?? "video";
+ play ??= $"https://bdsmx.tube/embed/{vId}/";
+ var orig = (target != null && target.StartsWith("http", StringComparison.OrdinalIgnoreCase)) ? target : $"https://bdsmx.tube/video/{vId}/";
+ return Results.Content(HtmlRenderer.RenderVideoPlayer("bdsmx", vId, play, stream, orig, title ?? $"BDSMx 動画 ({vId})"), "text/html; charset=utf-8");
+ }
+
// target が URL で site 未指定の場合のドメイン自動判定
if (string.IsNullOrWhiteSpace(site) && target != null)
{