更新: Ryuugamesの外部ストレージ直接URL(Mediafire等)自動解決およびaタグ直リンク化
This commit is contained in:
1 parent
2eb067ff8f
commit
0e82c7a2b7
1 file changed
+87
-10
@@ -209,17 +209,26 @@ internal class ryuugames
|
|||||||
public string LinkKey { get; set; } = string.Empty;
|
public string LinkKey { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 直接開くことが可能なダウンロード処理ページの URL を取得します。
|
/// 解決された直接のストレージURL(Mediafire, MegaNZ, Buzzheavier等)を取得または設定します。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string DownloadUrl
|
public string DirectStorageUrl { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 最終的なリンク先URLを取得します。直接URLが解決されている場合は直接URL、それ以外はSafelink処理URLを返します。
|
||||||
|
/// </summary>
|
||||||
|
public string FinalUrl
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(this.PostId) || string.IsNullOrWhiteSpace(this.LinkKey))
|
if (!string.IsNullOrWhiteSpace(this.DirectStorageUrl))
|
||||||
{
|
{
|
||||||
return string.Empty;
|
return this.DirectStorageUrl;
|
||||||
}
|
}
|
||||||
return $"https://www.ryuugames.com/processing/?ryuu_sl_action=process&post_id={Uri.EscapeDataString(this.PostId)}&shortcode_id={Uri.EscapeDataString(this.ShortcodeId)}&link_key={Uri.EscapeDataString(this.LinkKey)}";
|
if (!string.IsNullOrWhiteSpace(this.PostId) && !string.IsNullOrWhiteSpace(this.LinkKey))
|
||||||
|
{
|
||||||
|
return $"https://www.ryuugames.com/processing/?ryuu_sl_action=process&post_id={Uri.EscapeDataString(this.PostId)}&shortcode_id={Uri.EscapeDataString(this.ShortcodeId)}&link_key={Uri.EscapeDataString(this.LinkKey)}";
|
||||||
|
}
|
||||||
|
return string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,10 +281,10 @@ internal class ryuugames
|
|||||||
|
|
||||||
LanguageType langType;
|
LanguageType langType;
|
||||||
|
|
||||||
// 最新フォーマット(ダウンロードセクション直下配置、aタグリンク、およびフォルダ名タイトル表示 v6)が含まれているキャッシュのみ再利用
|
// 最新フォーマット(ダウンロード直リンク解決、aタグリンク、およびフォルダ名タイトル表示 v7)が含まれているキャッシュのみ再利用
|
||||||
bool isLatestFormat = prevEntry != null &&
|
bool isLatestFormat = prevEntry != null &&
|
||||||
prevEntry.SummaryHtml.Contains("ryuu-dl-section") &&
|
prevEntry.SummaryHtml.Contains("ryuu-dl-section") &&
|
||||||
prevEntry.SummaryHtml.Contains("ryuu-format-v6");
|
prevEntry.SummaryHtml.Contains("ryuu-format-v7");
|
||||||
|
|
||||||
if (prevEntry != null && !string.IsNullOrEmpty(prevEntry.SummaryHtml) && isLatestFormat)
|
if (prevEntry != null && !string.IsNullOrEmpty(prevEntry.SummaryHtml) && isLatestFormat)
|
||||||
{
|
{
|
||||||
@@ -677,6 +686,24 @@ internal class ryuugames
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 主要アップローダー(Mediafire, MegaNZ, Buzzheavier, PixelDrain等)の直接ストレージURLを解決
|
||||||
|
int resolvedCount = 0;
|
||||||
|
foreach (var btn in info.DownloadButtons)
|
||||||
|
{
|
||||||
|
// 各記事最大4つの主要ボタンを直接URLへ解決
|
||||||
|
if (resolvedCount >= 4)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
string directUrl = await ResolveDirectStorageUrlAsync(client, btn.PostId, btn.ShortcodeId, btn.LinkKey);
|
||||||
|
if (!string.IsNullOrWhiteSpace(directUrl))
|
||||||
|
{
|
||||||
|
btn.DirectStorageUrl = directUrl;
|
||||||
|
resolvedCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// サンプル画像(スクリーンショット)
|
// サンプル画像(スクリーンショット)
|
||||||
@@ -707,6 +734,56 @@ internal class ryuugames
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ryuugames の Safelink 処理ページから Base64 データを取得・復号し、
|
||||||
|
/// 中間ページを経由しない直接の外部ストレージURL(Mediafire, MegaNZ等)を解決します。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="client">HttpClient インスタンス</param>
|
||||||
|
/// <param name="postId">投稿ID</param>
|
||||||
|
/// <param name="shortcodeId">ショートコードID</param>
|
||||||
|
/// <param name="linkKey">リンクキー</param>
|
||||||
|
/// <returns>解決された直接URL(取得失敗時は空文字)</returns>
|
||||||
|
private static async Task<string> ResolveDirectStorageUrlAsync(HttpClient client, string postId, string shortcodeId, string linkKey)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(postId) || string.IsNullOrWhiteSpace(linkKey))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
string processUrl = $"https://www.ryuugames.com/processing/?ryuu_sl_action=process&post_id={Uri.EscapeDataString(postId)}&shortcode_id={Uri.EscapeDataString(shortcodeId)}&link_key={Uri.EscapeDataString(linkKey)}";
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var doc = await CmnUtil.GetDocument(client, processUrl);
|
||||||
|
if (doc == null)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
var inputHost = doc.QuerySelector("input[name='host']");
|
||||||
|
string b64 = inputHost?.GetAttribute("value") ?? string.Empty;
|
||||||
|
if (!string.IsNullOrWhiteSpace(b64))
|
||||||
|
{
|
||||||
|
byte[] bytes = Convert.FromBase64String(b64);
|
||||||
|
string jsonStr = Encoding.UTF8.GetString(bytes);
|
||||||
|
|
||||||
|
// JSON内の "url" フィールドを抽出
|
||||||
|
var match = Regex.Match(jsonStr, @"""url""\s*:\s*""([^""]+)""", RegexOptions.IgnoreCase);
|
||||||
|
if (match.Success)
|
||||||
|
{
|
||||||
|
string decodedUrl = match.Groups[1].Value.Replace(@"\/", "/");
|
||||||
|
return decodedUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogManager.AddLog($"[情報] 【ryuugames】 直リンク解決スキップ ({linkKey}): {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 各種シグナル(記事タイトル、Language表記、カテゴリ、原題)に基づき、日本語版か海外向け翻訳版かを厳密に判定します。
|
/// 各種シグナル(記事タイトル、Language表記、カテゴリ、原題)に基づき、日本語版か海外向け翻訳版かを厳密に判定します。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -1011,7 +1088,7 @@ internal class ryuugames
|
|||||||
sb.Append("</div>");
|
sb.Append("</div>");
|
||||||
|
|
||||||
// 1.3. フォルダ名用タイトル (Folder Name) の明記(本文直下・テキストコピー用)
|
// 1.3. フォルダ名用タイトル (Folder Name) の明記(本文直下・テキストコピー用)
|
||||||
sb.Append("<div class=\"ryuu-folder-title ryuu-format-v6\" 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 class=\"ryuu-folder-title ryuu-format-v7\" 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: 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 style=\"font-size: 15px; font-weight: bold; color: #111827; user-select: all; -webkit-user-select: all;\">{WebUtility.HtmlEncode(folderTitle)}</div>");
|
||||||
sb.Append("</div>");
|
sb.Append("</div>");
|
||||||
@@ -1066,9 +1143,9 @@ internal class ryuugames
|
|||||||
|
|
||||||
foreach (var btn in info.DownloadButtons)
|
foreach (var btn in info.DownloadButtons)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrWhiteSpace(btn.DownloadUrl))
|
if (!string.IsNullOrWhiteSpace(btn.FinalUrl))
|
||||||
{
|
{
|
||||||
sb.Append($"<a href=\"{btn.DownloadUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" referrerpolicy=\"no-referrer\" style=\"display: inline-block; background-color: #1976d2; color: #ffffff; padding: 6px 14px; border-radius: 4px; text-decoration: none; font-weight: bold; font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,0.12);\">⬇️ {btn.ProviderName}</a>");
|
sb.Append($"<a href=\"{btn.FinalUrl}\" target=\"_blank\" rel=\"noopener noreferrer\" referrerpolicy=\"no-referrer\" style=\"display: inline-block; background-color: #1976d2; color: #ffffff; padding: 6px 14px; border-radius: 4px; text-decoration: none; font-weight: bold; font-size: 13px; box-shadow: 0 1px 3px rgba(0,0,0,0.12);\">⬇️ {btn.ProviderName}</a>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sb.Append("</div>");
|
sb.Append("</div>");
|
||||||
|
|||||||
Reference in new issue
Block a user