Files
hottub/src/proxies/rule34video.rs
Simon 4f83dae3fa rule34video: drop per-video enrichment; add on-demand page resolver proxy (off)
Listings no longer fetch every video page for formats/tags/artist, which
ran into the site's 429 limit. /proxy/rule34video/{id}/{slug} resolves the
page at play time and 302s to the signed mp4; the resolver lives in
util/rule34video_resolve.rs. Handing out proxy URLs is gated behind
USE_MEDIA_PROXY, currently false.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AEp724zDpCWNaSeCrMSvjx
2026-11-05 20:26:50 +00:00

29 lines
1.1 KiB
Rust

use ntex::http::Method;
use ntex::http::header::LOCATION;
use ntex::web::{self, HttpRequest};
use crate::util::requester::Requester;
use crate::util::rule34video_resolve::{page_url, resolve_media_url};
/// The channel lists `/proxy/rule34video/{id}/{slug}` instead of resolving every
/// video page while listing (which ran into the site's 429 limit): the page is
/// read when the video is played, and the player is sent to its signed mp4.
pub async fn redirect_to_media(
req: HttpRequest,
requester: web::types::State<Requester>,
) -> impl web::Responder {
let endpoint = req.match_info().query("endpoint").to_string();
let Some(page_url) = page_url(&endpoint) else {
return web::HttpResponse::BadRequest().finish();
};
if req.method() == Method::HEAD {
return web::HttpResponse::Ok().finish();
}
let mut requester = requester.get_ref().clone();
match resolve_media_url(&mut requester, &page_url, None).await {
Some(url) => web::HttpResponse::Found().header(LOCATION, url).finish(),
None => web::HttpResponse::BadGateway().finish(),
}
}