Fix coomer: bogus video formats on image posts, and its CDN reachability in check.py
- coomer.rs: only emit a `formats` entry for actual video extensions. Image-only posts (very common - many creators post photos, not just videos) were getting a `formats[0]` pointing at a static jpg/png, which a player would try and fail to stream as video; the preview URL already covers showing the image. - coomer.rs tests: fix stale fixtures that baked a `/data/` prefix into `file.path`, which doesn't match the real API's path shape (the code prepends `/data/` itself) and was doubling it into `/data/data/...`. This was masking the formats bug above until the fixture was corrected. - check.py: coomer.st/data/... 302s to a load-balanced nN.coomer.st CDN node; every node tested (n1/n2/n3) is a hard connect-timeout from this sandbox's egress while coomer.st itself is a normal 200 - the same IP-reputation-style CDN block already documented for ripnsfw's doodstream/lulustream edges. Added `.coomer.st` to the CF-protected suffix allowlist, and made the url/thumb checks follow redirects before testing it (previously only the format-url check did). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QTqf6orbHZ9rFFpVpcgzcR
This commit is contained in:
@@ -462,18 +462,24 @@ impl CoomerProvider {
|
||||
if let Some(ref url) = format_url {
|
||||
let ext = ext_hint.unwrap_or_else(|| "mp4".to_string());
|
||||
let is_video = matches!(ext.as_str(), "mp4" | "webm" | "mov" | "mkv");
|
||||
let mut format = VideoFormat::new(url.clone(), "original".to_string(), ext.clone());
|
||||
// The /data/... path 302s to the n*.coomer.st CDN; that CDN will
|
||||
// serve the bytes without a Referer requirement, but the *initial*
|
||||
// redirect to the CDN does require a valid coomer.st session cookie
|
||||
// and Referer. Set the Referer so the 302 actually returns the
|
||||
// Location header.
|
||||
format = format.http_header("Referer".to_string(), REFERER.to_string());
|
||||
format = format.http_header("User-Agent".to_string(), BROWSER_UA.to_string());
|
||||
// An image-only post (very common - many creators post photos,
|
||||
// not just videos) has nothing playable; emitting a "format"
|
||||
// pointing at a static jpg/png just gives players a broken
|
||||
// pseudo-video to try to stream. The preview URL already covers
|
||||
// showing the image.
|
||||
if is_video {
|
||||
let mut format =
|
||||
VideoFormat::new(url.clone(), "original".to_string(), ext.clone());
|
||||
// The /data/... path 302s to the n*.coomer.st CDN; that CDN will
|
||||
// serve the bytes without a Referer requirement, but the *initial*
|
||||
// redirect to the CDN does require a valid coomer.st session cookie
|
||||
// and Referer. Set the Referer so the 302 actually returns the
|
||||
// Location header.
|
||||
format = format.http_header("Referer".to_string(), REFERER.to_string());
|
||||
format = format.http_header("User-Agent".to_string(), BROWSER_UA.to_string());
|
||||
format = format.video_ext(ext);
|
||||
item.formats = Some(vec![format]);
|
||||
}
|
||||
item.formats = Some(vec![format]);
|
||||
}
|
||||
|
||||
// Drop the auto-generated preview URL if it duplicates the format URL.
|
||||
@@ -793,7 +799,7 @@ mod tests {
|
||||
"service": "onlyfans",
|
||||
"title": "First post",
|
||||
"published": "2025-01-02T03:04:05Z",
|
||||
"file": {"name": "clip.mp4", "path": "/data/abc/clip.mp4"},
|
||||
"file": {"name": "clip.mp4", "path": "/abc/clip.mp4"},
|
||||
"attachments": []
|
||||
}"#;
|
||||
let post: ApiPost = serde_json::from_str(json).expect("parse");
|
||||
@@ -826,7 +832,7 @@ mod tests {
|
||||
"service": "fansly",
|
||||
"title": "",
|
||||
"substring": "<p>Hello there friends</p>",
|
||||
"file": {"name": "p.jpg", "path": "/data/x/p.jpg"}
|
||||
"file": {"name": "p.jpg", "path": "/x/p.jpg"}
|
||||
}"#;
|
||||
let post: ApiPost = serde_json::from_str(json).expect("parse");
|
||||
let item = CoomerProvider::build_video_item(post).expect("item");
|
||||
|
||||
Reference in New Issue
Block a user