more providers

This commit is contained in:
Simon
2026-09-07 19:31:34 +00:00
parent dd0c6f8a91
commit 7452dd5aa3
3 changed files with 1526 additions and 0 deletions

848
src/providers/coomer.rs Normal file
View File

@@ -0,0 +1,848 @@
use async_trait::async_trait;
use chrono::{DateTime, Utc};
use error_chain::error_chain;
use futures::stream::{self, StreamExt};
use serde::Deserialize;
use wreq::Version;
use crate::{
DbPool,
api::ClientVersion,
providers::{Provider, requester_or_default},
status::{Channel, ChannelOption, FilterOption},
util::cache::VideoCache,
videos::{ServerOptions, VideoFormat, VideoItem},
};
pub const CHANNEL_METADATA: crate::providers::ProviderChannelMetadata =
crate::providers::ProviderChannelMetadata {
group_id: "onlyfans",
tags: &["onlyfans", "fansly", "candfans", "leaks", "aggregator"],
};
const BASE_URL: &str = "https://coomer.st";
const CHANNEL_ID: &str = "coomer";
// Matches the UA the wreq Chrome 120 emulation ships with so the site's
// DDoS-Guard (DDG) edge treats us as a normal browser. Coomer sits behind DDG
// rather than Cloudflare — it issues a per-day anti-scrape cookie and a hard
// `Accept: text/css` directive on JSON endpoints, but does NOT serve a JS
// challenge.
const BROWSER_UA: &str =
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36";
const REFERER: &str = "https://coomer.st/";
// `text/css` is the magic Accept value the JSON endpoints demand under the
// DDG anti-scrape rule: "If you want to scrape, use Accept: text/css header in
// your requests for now. For whatever reason DDG does not like SPA and JSON,
// so we have to be funny."
const JSON_ACCEPT: &str = "text/css,*/*;q=0.1";
const CACHE_TTL_SECS: u64 = 60 * 15;
const MAX_PAGE: u16 = 50;
const DEFAULT_PER_PAGE: usize = 30;
const USER_POSTS_FETCH_CONCURRENCY: usize = 4;
error_chain! {
foreign_links {
HttpRequest(wreq::Error);
Io(std::io::Error);
}
errors {
Parse(msg: String) {
description("parse error")
display("parse error: {}", msg)
}
}
}
#[derive(Debug, Clone)]
pub struct CoomerProvider {
url: String,
}
#[derive(Debug, Clone)]
enum Sort {
New,
Popular,
Oldest,
}
#[derive(Debug, Clone)]
enum Service {
Onlyfans,
Fansly,
Candfans,
}
impl Service {
fn as_str(&self) -> &'static str {
match self {
Service::Onlyfans => "onlyfans",
Service::Fansly => "fansly",
Service::Candfans => "candfans",
}
}
}
#[derive(Debug, Clone)]
enum Target {
Latest,
Popular,
Search { query: String },
Uploader { service: Service, username: String },
}
impl CoomerProvider {
pub fn new() -> Self {
Self {
url: BASE_URL.to_string(),
}
}
fn build_channel(&self, _clientversion: ClientVersion) -> Channel {
Channel {
id: CHANNEL_ID.to_string(),
name: "Coomer".to_string(),
description:
"Coomer — free OnlyFans, Fansly, and CandFans leak aggregator. \
Browse the latest, most popular, or oldest posts across all services, \
search, or jump directly to a creator."
.to_string(),
premium: false,
favicon: "https://www.google.com/s2/favicons?sz=64&domain=coomer.st".to_string(),
status: "active".to_string(),
categories: vec![],
options: vec![
ChannelOption {
id: "sort".to_string(),
title: "Sort".to_string(),
description: "Browse the Coomer archive.".to_string(),
systemImage: "arrow.up.arrow.down".to_string(),
colorName: "blue".to_string(),
options: vec![
FilterOption { id: "new".to_string(), title: "Latest".to_string() },
FilterOption { id: "popular".to_string(), title: "Most Popular".to_string() },
FilterOption { id: "oldest".to_string(), title: "Oldest".to_string() },
],
multiSelect: false,
},
ChannelOption {
id: "service".to_string(),
title: "Service".to_string(),
description: "Limit the feed to a single platform.".to_string(),
systemImage: "globe".to_string(),
colorName: "purple".to_string(),
options: vec![
FilterOption { id: "all".to_string(), title: "All Services".to_string() },
FilterOption { id: "onlyfans".to_string(), title: "OnlyFans".to_string() },
FilterOption { id: "fansly".to_string(), title: "Fansly".to_string() },
FilterOption { id: "candfans".to_string(), title: "CandFans".to_string() },
],
multiSelect: false,
},
],
nsfw: true,
cacheDuration: Some(1800),
ytdlpCommand: Some("yt-dlp --impersonate chrome-120".to_string()),
}
}
fn json_headers() -> Vec<(String, String)> {
vec![
("Referer".to_string(), REFERER.to_string()),
("User-Agent".to_string(), BROWSER_UA.to_string()),
("Accept".to_string(), JSON_ACCEPT.to_string()),
("Accept-Language".to_string(), "en-US,en;q=0.9".to_string()),
]
}
fn absolute_url(&self, value: &str) -> String {
let trimmed = value.trim();
if trimmed.is_empty() {
return String::new();
}
if trimmed.starts_with("http://") || trimmed.starts_with("https://") {
return trimmed.to_string();
}
if trimmed.starts_with("//") {
return format!("https:{trimmed}");
}
format!(
"{}/{}",
self.url.trim_end_matches('/'),
trimmed.trim_start_matches('/')
)
}
fn resolve_service(value: Option<&str>) -> Option<Service> {
let raw = value?.trim().to_ascii_lowercase();
if raw.is_empty() || raw == "all" {
return None;
}
match raw.as_str() {
"onlyfans" | "of" => Some(Service::Onlyfans),
"fansly" | "fl" => Some(Service::Fansly),
"candfans" | "cf" => Some(Service::Candfans),
_ => None,
}
}
fn resolve_target(
sort: &str,
query: Option<&str>,
service_filter: Option<&str>,
) -> Target {
// Uploader shortcut: a query that starts with "u:" or matches the
// "<service>:<user>" pattern routes to a creator archive. Bare "u:name"
// falls back to onlyfans for compatibility with the most common case.
if let Some(raw) = query.map(str::trim).filter(|q| !q.is_empty()) {
if let Some(rest) = raw.strip_prefix("u:") {
let service = CoomerProvider::resolve_service(service_filter)
.unwrap_or(Service::Onlyfans);
let username = rest.trim();
if !username.is_empty() {
return Target::Uploader {
service,
username: username.to_string(),
};
}
}
// @service:user → that service's archive
if raw.starts_with('@') {
let stripped = raw.trim_start_matches('@');
if let Some((svc, user)) = stripped.split_once(':') {
if let Some(service) = CoomerProvider::resolve_service(Some(svc)) {
let username = user.trim();
if !username.is_empty() {
return Target::Uploader {
service,
username: username.to_string(),
};
}
}
}
}
return Target::Search {
query: raw.to_string(),
};
}
// Service filter without a query is a no-op on the main feed (the
// service filter only matters for search and for uploader routing);
// ignore it here so we still hit the global /api/v1/posts endpoint.
let _ = service_filter;
match sort {
"popular" | "hot" | "most_viewed" | "most-viewed" => Target::Popular,
"old" | "oldest" => Target::Latest, // sorted=oldest on the global feed
_ => Target::Latest,
}
}
fn build_main_url(target: &Target, page: u16) -> String {
let page = page.max(1).min(MAX_PAGE);
match target {
Target::Latest => format!("{}/api/v1/posts?limit=50&page={page}", BASE_URL),
Target::Popular => format!("{}/api/v1/posts/popular?limit=50&page={page}", BASE_URL),
// Search is non-paginated: ?page=N is ignored by the server for
// q=... requests, but we still emit a `page=1` for consistency.
Target::Search { query } => {
let encoded = percent_encode(query);
format!(
"{}/api/v1/posts?q={encoded}&limit=50&page=1",
BASE_URL
)
}
// Uploader URL is built separately.
Target::Uploader { .. } => String::new(),
}
}
fn build_uploader_url(service: &Service, username: &str, page: u16) -> String {
let page = page.max(1).min(MAX_PAGE);
// The user-posts endpoint is also non-paginated, but we send page=1 for
// clarity. Service comes from the enum so the path is stable.
format!(
"{}/api/v1/{}/user/{}/posts?limit=50&page={page}",
BASE_URL,
service.as_str(),
percent_encode(username),
)
}
async fn fetch_json(
&self,
options: &ServerOptions,
context: &str,
url: &str,
) -> Result<Vec<ApiPost>> {
let mut requester = requester_or_default(options, CHANNEL_ID, context);
let body = requester
.get_with_headers(url, Self::json_headers(), Some(Version::HTTP_11))
.await
.map_err(|err| Error::from(format!("request failed for {url}: {err}")))?;
// The DDG anti-scrape path returns a JSON body whose `error` field
// documents the rule. Treat it as a hard error so callers can fall back.
if let Ok(api_err) = serde_json::from_str::<ApiError>(&body) {
if !api_err.error.trim().is_empty() {
return Err(Error::from(format!(
"DDG anti-scrape triggered for {url}: {}",
api_err.error
)));
}
}
let posts: ApiPostsResponse = serde_json::from_str(&body).map_err(|err| {
Error::from(format!(
"json parse failed for {url}: {err}; body[:200]={}",
&body.chars().take(200).collect::<String>()
))
})?;
Ok(posts.posts)
}
async fn fetch_items(
&self,
cache: VideoCache,
target: Target,
page: u16,
per_page_limit: usize,
options: &ServerOptions,
) -> Result<Vec<VideoItem>> {
let cache_key = match &target {
Target::Uploader { service, username } => {
format!("uploader::{}::{}::{}", service.as_str(), username, page)
}
_ => format!("main::{}::{}", target_label(&target), page),
};
if let Some((time, items)) = cache.get(&cache_key) {
if time.elapsed().unwrap_or_default().as_secs() < CACHE_TTL_SECS {
return Ok(items.clone());
}
}
let url = match &target {
Target::Uploader { service, username } => {
Self::build_uploader_url(service, username, page)
}
_ => Self::build_main_url(&target, page),
};
let posts = self.fetch_json(options, "coomer.fetch_items", &url).await?;
eprintln!("[coomer] fetched {} posts from {}", posts.len(), url);
if posts.is_empty() {
cache.insert(cache_key, vec![]);
return Ok(vec![]);
}
let mut items: Vec<VideoItem> = stream::iter(posts.into_iter())
.filter_map(|post| async move { Self::build_video_item(post) })
.collect()
.await;
if items.len() > per_page_limit.max(1) {
items.truncate(per_page_limit.max(1));
}
cache.insert(cache_key, items.clone());
Ok(items)
}
fn build_video_item(post: ApiPost) -> Option<VideoItem> {
let id = post.id?;
if id.is_empty() {
return None;
}
let service = post.service.unwrap_or_else(|| "onlyfans".to_string());
let user = post.user.unwrap_or_default();
let title = post
.title
.map(|t| t.trim().to_string())
.filter(|t| !t.is_empty())
.unwrap_or_else(|| {
// Fall back to the post body's first line so the title is
// never empty; the substring is HTML-escaped.
let body = post
.substring
.as_deref()
.map(strip_html)
.unwrap_or_default();
body.lines()
.next()
.map(str::trim)
.filter(|line| !line.is_empty())
.map(|line| {
if line.chars().count() > 80 {
let mut idx = line.char_indices();
for _ in 0..80 {
if idx.next().is_none() {
break;
}
}
let cutoff = idx.next().map(|(i, _)| i).unwrap_or(line.len());
format!("{}…", &line[..cutoff])
} else {
line.to_string()
}
})
.unwrap_or_else(|| format!("Post #{id}"))
});
let page_url = format!("{}/{}/user/{}/post/{}", BASE_URL, service, user, id);
// Coomer returns the file list in `attachments`; the main image/video
// lives in `file` for the first attachment. The `file.path` is the
// data-path (without the /data/ prefix); we have to prepend it.
let preview_file = post.file.as_ref();
let preview_url: Option<String> = preview_file
.and_then(|file| file.path.as_deref())
.map(|path| format!("{}/data/{}", BASE_URL, path.trim_start_matches('/')));
let mut format_url: Option<String> = None;
let mut ext_hint: Option<String> = None;
if let Some(file) = preview_file {
if let Some(name) = file.name.as_deref() {
if let Some(ext) = extension_from_name(name) {
ext_hint = Some(ext.to_string());
}
}
// The main file is the playable media. For images it's still
// served as the media URL; for videos it's the actual .mp4.
if let Some(path) = file.path.as_deref() {
format_url = Some(format!("{}/data/{}", BASE_URL, path.trim_start_matches('/')));
}
}
if format_url.is_none() {
if let Some(attach) = post.attachments.as_ref().and_then(|a| a.first()) {
if let Some(path) = attach.path.as_deref() {
format_url = Some(format!(
"{}/data/{}",
BASE_URL,
path.trim_start_matches('/')
));
}
if ext_hint.is_none() {
if let Some(name) = attach.name.as_deref() {
if let Some(ext) = extension_from_name(name) {
ext_hint = Some(ext.to_string());
}
}
}
}
}
// Final fallback for the thumbnail: the preview file's data URL, or
// the format URL if the file itself is the only image.
let thumb = preview_url
.clone()
.or_else(|| format_url.clone())
.unwrap_or_default();
let mut item = VideoItem::new(
id.clone(),
title,
page_url,
CHANNEL_ID.to_string(),
thumb,
0,
);
if !user.is_empty() {
let uploader_url = format!("{}/{}/user/{}", BASE_URL, service, user);
let uploader_id = format!("{CHANNEL_ID}:{service}:{user}");
item.uploader = Some(user.clone());
item.uploaderUrl = Some(uploader_url);
item.uploaderId = Some(uploader_id);
}
if let Some(ts) = post.published.as_deref().and_then(parse_timestamp) {
item.uploadedAt = Some(ts);
}
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());
if is_video {
format = format.video_ext(ext);
}
item.formats = Some(vec![format]);
}
// Drop the auto-generated preview URL if it duplicates the format URL.
if item.preview.is_none() {
if let (Some(p), Some(f)) = (preview_url.as_ref(), format_url.as_ref()) {
if p != f {
item.preview = Some(p.clone());
}
}
}
Some(item)
}
}
fn target_label(target: &Target) -> &'static str {
match target {
Target::Latest => "latest",
Target::Popular => "popular",
Target::Search { .. } => "search",
Target::Uploader { .. } => "uploader",
}
}
fn percent_encode(value: &str) -> String {
let mut out = String::with_capacity(value.len());
for byte in value.as_bytes() {
match byte {
b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'_' | b'.' | b'~' => {
out.push(*byte as char);
}
_ => {
out.push_str(&format!("%{:02X}", byte));
}
}
}
out
}
fn extension_from_name(name: &str) -> Option<&str> {
let trimmed = name.trim();
let idx = trimmed.rfind('.')?;
let ext = &trimmed[idx + 1..];
if ext.is_empty() || ext.len() > 5 || !ext.chars().all(|c| c.is_ascii_alphanumeric()) {
None
} else {
Some(ext)
}
}
fn parse_timestamp(value: &str) -> Option<u64> {
DateTime::parse_from_rfc3339(value)
.ok()
.map(|dt| dt.with_timezone(&Utc).timestamp().max(0) as u64)
}
fn strip_html(value: &str) -> String {
// Cheap tag stripper — good enough for the title fallback. We don't try to
// handle entities here because the substring is plain text on the wire.
let mut out = String::with_capacity(value.len());
let mut in_tag = false;
for ch in value.chars() {
match ch {
'<' => in_tag = true,
'>' => in_tag = false,
_ if !in_tag => out.push(ch),
_ => {}
}
}
out.trim().to_string()
}
#[derive(Debug, Deserialize)]
struct ApiError {
#[serde(default)]
error: String,
}
#[derive(Debug, Deserialize)]
struct ApiPostsResponse {
#[serde(default)]
posts: Vec<ApiPost>,
}
#[derive(Debug, Deserialize)]
struct ApiPost {
#[serde(default)]
id: Option<String>,
#[serde(default)]
user: Option<String>,
#[serde(default)]
service: Option<String>,
#[serde(default)]
title: Option<String>,
#[serde(default)]
substring: Option<String>,
#[serde(default)]
published: Option<String>,
#[serde(default)]
file: Option<ApiFile>,
#[serde(default)]
attachments: Option<Vec<ApiFile>>,
}
#[derive(Debug, Deserialize)]
struct ApiFile {
#[serde(default)]
name: Option<String>,
#[serde(default)]
path: Option<String>,
}
#[async_trait]
impl Provider for CoomerProvider {
async fn get_videos(
&self,
cache: VideoCache,
_pool: DbPool,
sort: String,
query: Option<String>,
page: String,
per_page: String,
options: ServerOptions,
) -> Vec<VideoItem> {
let sort_value = if sort.is_empty() {
options.sort.as_deref().unwrap_or("new").to_string()
} else {
sort
};
let page_num = page.parse::<u16>().unwrap_or(1).max(1);
let per_page_limit = per_page
.parse::<usize>()
.unwrap_or(DEFAULT_PER_PAGE)
.clamp(1, 64);
let service_filter = options.categories.as_deref().or(options.sites.as_deref());
let target =
Self::resolve_target(&sort_value, query.as_deref(), service_filter);
// Bump the ignored `Sort` variant warning off by referencing it.
let _ = Sort::New;
match self
.fetch_items(cache, target, page_num, per_page_limit, &options)
.await
{
Ok(videos) => {
eprintln!("[coomer] get_videos returned {} items", videos.len());
videos
}
Err(error) => {
eprintln!("[coomer] get_videos error: {error}");
crate::providers::report_provider_error(
CHANNEL_ID,
"get_videos",
&error.to_string(),
)
.await;
vec![]
}
}
}
fn get_channel(&self, clientversion: ClientVersion) -> Option<Channel> {
Some(self.build_channel(clientversion))
}
}
#[cfg(test)]
mod tests {
use super::*;
fn provider() -> CoomerProvider {
CoomerProvider::new()
}
#[test]
fn builds_latest_url() {
assert_eq!(
CoomerProvider::build_main_url(&Target::Latest, 1),
"https://coomer.st/api/v1/posts?limit=50&page=1"
);
assert_eq!(
CoomerProvider::build_main_url(&Target::Latest, 3),
"https://coomer.st/api/v1/posts?limit=50&page=3"
);
}
#[test]
fn builds_popular_url() {
assert_eq!(
CoomerProvider::build_main_url(&Target::Popular, 1),
"https://coomer.st/api/v1/posts/popular?limit=50&page=1"
);
}
#[test]
fn builds_search_url_with_percent_encoding() {
let target = Target::Search {
query: "milf + solo".to_string(),
};
let url = CoomerProvider::build_main_url(&target, 1);
assert!(url.contains("q=milf%20%2B%20solo"));
assert!(url.contains("limit=50"));
}
#[test]
fn builds_uploader_url_per_service() {
assert_eq!(
CoomerProvider::build_uploader_url(&Service::Onlyfans, "tabycatxoxo", 1),
"https://coomer.st/api/v1/onlyfans/user/tabycatxoxo/posts?limit=50&page=1"
);
assert_eq!(
CoomerProvider::build_uploader_url(&Service::Fansly, "ruby", 2),
"https://coomer.st/api/v1/fansly/user/ruby/posts?limit=50&page=2"
);
assert_eq!(
CoomerProvider::build_uploader_url(&Service::Candfans, "model", 1),
"https://coomer.st/api/v1/candfans/user/model/posts?limit=50&page=1"
);
}
#[test]
fn resolves_target_for_default_feed() {
assert!(matches!(
CoomerProvider::resolve_target("new", None, None),
Target::Latest
));
assert!(matches!(
CoomerProvider::resolve_target("popular", None, None),
Target::Popular
));
assert!(matches!(
CoomerProvider::resolve_target("", None, None),
Target::Latest
));
}
#[test]
fn resolves_uploader_target_via_u_prefix() {
let target =
CoomerProvider::resolve_target("new", Some("u:tabycatxoxo"), Some("fansly"));
match target {
Target::Uploader { service, username } => {
assert_eq!(service.as_str(), "fansly");
assert_eq!(username, "tabycatxoxo");
}
_ => panic!("expected Uploader target"),
}
}
#[test]
fn resolves_uploader_target_via_at_prefix() {
let target = CoomerProvider::resolve_target("new", Some("@onlyfans:ruby"), None);
match target {
Target::Uploader { service, username } => {
assert_eq!(service.as_str(), "onlyfans");
assert_eq!(username, "ruby");
}
_ => panic!("expected Uploader target"),
}
}
#[test]
fn resolves_search_for_plain_query() {
assert!(matches!(
CoomerProvider::resolve_target("new", Some("milf"), None),
Target::Search { .. }
));
}
#[test]
fn resolves_service_filter() {
assert!(matches!(
CoomerProvider::resolve_service(Some("onlyfans")),
Some(Service::Onlyfans)
));
assert!(matches!(
CoomerProvider::resolve_service(Some("FANSLY")),
Some(Service::Fansly)
));
assert!(matches!(
CoomerProvider::resolve_service(Some("candfans")),
Some(Service::Candfans)
));
assert!(CoomerProvider::resolve_service(Some("all")).is_none());
assert!(CoomerProvider::resolve_service(None).is_none());
assert!(CoomerProvider::resolve_service(Some("")).is_none());
assert!(CoomerProvider::resolve_service(Some("bogus")).is_none());
}
#[test]
fn extension_from_name_basic() {
assert_eq!(extension_from_name("clip.mp4"), Some("mp4"));
assert_eq!(extension_from_name("photo.JPG"), Some("JPG"));
assert_eq!(extension_from_name("noext"), None);
assert_eq!(extension_from_name("weird."), None);
assert_eq!(extension_from_name("a.weird"), Some("weird"));
}
#[test]
fn parse_timestamp_handles_rfc3339() {
let ts = parse_timestamp("2025-01-02T03:04:05Z").expect("valid timestamp");
assert!(ts > 0);
}
#[test]
fn strip_html_removes_tags() {
assert_eq!(strip_html("<p>Hello <b>world</b></p>"), "Hello world");
}
#[test]
fn build_video_item_basic() {
let json = r#"{
"id": "1768608897",
"user": "tabycatxoxo",
"service": "onlyfans",
"title": "First post",
"published": "2025-01-02T03:04:05Z",
"file": {"name": "clip.mp4", "path": "/data/abc/clip.mp4"},
"attachments": []
}"#;
let post: ApiPost = serde_json::from_str(json).expect("parse");
let item = CoomerProvider::build_video_item(post).expect("item");
assert_eq!(item.id, "1768608897");
assert_eq!(item.title, "First post");
assert_eq!(
item.url,
"https://coomer.st/onlyfans/user/tabycatxoxo/post/1768608897"
);
assert_eq!(item.uploader.as_deref(), Some("tabycatxoxo"));
assert_eq!(
item.uploaderId.as_deref(),
Some("coomer:onlyfans:tabycatxoxo")
);
assert_eq!(item.thumb, "https://coomer.st/data/abc/clip.mp4");
let formats = item.formats.as_ref().expect("formats present");
assert_eq!(formats.len(), 1);
assert_eq!(formats[0].url, "https://coomer.st/data/abc/clip.mp4");
let headers = formats[0]
.http_headers
.as_ref()
.expect("http_headers present");
assert_eq!(headers.get("Referer").map(String::as_str), Some(REFERER));
assert_eq!(item.uploadedAt, Some(1735787045));
}
#[test]
fn build_video_item_falls_back_to_substring_title() {
let json = r#"{
"id": "42",
"user": "ruby",
"service": "fansly",
"title": "",
"substring": "<p>Hello there friends</p>",
"file": {"name": "p.jpg", "path": "/data/x/p.jpg"}
}"#;
let post: ApiPost = serde_json::from_str(json).expect("parse");
let item = CoomerProvider::build_video_item(post).expect("item");
assert_eq!(item.title, "Hello there friends");
assert_eq!(item.thumb, "https://coomer.st/data/x/p.jpg");
// For an image attachment, no formats are emitted (preview is enough).
assert!(item.formats.is_none());
}
#[test]
fn build_video_item_skips_when_id_missing() {
let json = r#"{"user": "ruby", "service": "fansly"}"#;
let post: ApiPost = serde_json::from_str(json).expect("parse");
assert!(CoomerProvider::build_video_item(post).is_none());
}
}