omgxxx fix

This commit is contained in:
Simon
2026-06-30 20:42:48 +00:00
parent 83e433d09b
commit 4dc1072d86

View File

@@ -1111,48 +1111,54 @@ impl OmgxxxProvider {
.unwrap_or_default()
.to_string();
let thumb = match video_segment
.split("img loading")
// Skip advertisement cards. They reuse class="item" but link to an
// external ad network instead of an omg.xxx video (and embed an
// <iframe> rather than a real <img> thumbnail), so they have no
// numeric video id under /videos/.
if !video_url.contains("/videos/")
|| id.is_empty()
|| !id.chars().all(|c| c.is_ascii_digit())
{
continue;
}
// Thumbnail: the site lazy-loads most cards, putting the real image
// in data-src with a 1x1 base64 placeholder in src. Eager (high
// priority) cards carry the real image directly in src. Prefer
// data-src, fall back to src, and reject "data:" placeholders.
let img_tag = video_segment
.split("<img")
.collect::<Vec<&str>>()
.get(1)
.copied()
.unwrap_or_default()
.contains("data-src=\"")
{
true => video_segment
.split("img loading")
.split('>')
.collect::<Vec<&str>>()
.get(0)
.copied()
.unwrap_or_default();
let extract_attr = |attr: &str| -> String {
img_tag
.split(attr)
.collect::<Vec<&str>>()
.get(1)
.copied()
.unwrap_or_default()
.split("data-src=\"")
.collect::<Vec<&str>>()
.get(1)
.copied()
.unwrap_or_default()
.split("\"")
.split('"')
.collect::<Vec<&str>>()
.get(0)
.copied()
.unwrap_or_default()
.to_string(),
false => video_segment
.split("img loading")
.collect::<Vec<&str>>()
.get(1)
.copied()
.unwrap_or_default()
.split("data-original=\"")
.collect::<Vec<&str>>()
.get(1)
.copied()
.unwrap_or_default()
.split("\"")
.collect::<Vec<&str>>()
.get(0)
.copied()
.unwrap_or_default()
.to_string(),
.to_string()
};
let data_src = extract_attr("data-src=\"");
let src = extract_attr(" src=\"");
let thumb = if !data_src.is_empty() && !data_src.starts_with("data:") {
data_src
} else if !src.is_empty() && !src.starts_with("data:") {
src
} else {
String::new()
};
let raw_duration = video_segment
.split("<span class=\"duration\">")
@@ -1515,6 +1521,69 @@ mod tests {
.any(|tag| tag.id == "mark-wood" && tag.title == "Mark Wood")
);
}
#[test]
fn skips_ads_and_extracts_thumbs_from_current_markup() {
// Mirrors the live omg.xxx markup as of mid-2026: <img> tags no longer
// carry a `loading` attribute, eager cards put the real image in `src`,
// lazy cards put a base64 placeholder in `src` with the real image in
// `data-src`, and advertisement cards reuse class="item" but link off-site.
let provider = test_provider();
let html = r##"
<div class="list-videos">
<div class="item">
<a href="https://www.omg.xxx/videos/93816267/eager-video/" title="Eager Video">
<img class="thumb thumb_img " fetchpriority="high" src="https://img.omg.xxx/93816000/93816267/medium@2x/1.jpg" alt="Eager Video" width="744" height="420"/>
<span class="duration"> 12:00 </span>
</a>
</div>
<div class="item">
<a href="https://a.aivanta76.com/native_txt?creative=native_txt" target="_blank" title="Create and Fuck your AI Cum Slut" class="">
<iframe src="https://engine.ultraomelette.com/banner"></iframe>
</a>
</div>
<div class="item">
<a href="https://www.omg.xxx/videos/93816269/lazy-video/" title="Lazy Video">
<img loading="lazy" class="thumb thumb_img lazyload" fetchpriority="high" src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" data-src="https://img.omg.xxx/93816000/93816269/medium@2x/1.jpg" alt="Lazy Video" width="744" height="420"/>
<span class="duration"> 08:30 </span>
</a>
</div>
</div>
"##
.to_string();
let items = provider.get_video_items_from_html(html);
// The advertisement card must be filtered out.
assert_eq!(items.len(), 2);
assert!(items.iter().all(|item| item.url.contains("/videos/")));
assert!(
!items
.iter()
.any(|item| item.title.contains("AI Cum Slut"))
);
// Thumbnails must be real CDN URLs, never empty or base64 placeholders.
for item in &items {
assert!(
item.thumb.starts_with("https://img.omg.xxx/"),
"unexpected thumb: {:?}",
item.thumb
);
assert!(!item.thumb.starts_with("data:"));
}
assert_eq!(items[0].id, "93816267");
assert_eq!(
items[0].thumb,
"https://img.omg.xxx/93816000/93816267/medium@2x/1.jpg"
);
assert_eq!(items[1].id, "93816269");
assert_eq!(
items[1].thumb,
"https://img.omg.xxx/93816000/93816269/medium@2x/1.jpg"
);
}
}
#[async_trait]