From 2bd132820beebd2e3c94ecf93c04a9f7b299cefb Mon Sep 17 00:00:00 2001 From: Simon Date: Sat, 25 Apr 2026 16:40:53 +0000 Subject: [PATCH] viralxxxporn fix --- src/providers/viralxxxporn.rs | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/providers/viralxxxporn.rs b/src/providers/viralxxxporn.rs index 88909b5..d71d863 100644 --- a/src/providers/viralxxxporn.rs +++ b/src/providers/viralxxxporn.rs @@ -5,7 +5,7 @@ use crate::status::*; use crate::util::cache::VideoCache; use crate::util::parse_abbreviated_number; use crate::util::time::parse_time_to_seconds; -use crate::videos::{ServerOptions, VideoFormat, VideoItem}; +use crate::videos::{ServerOptions, VideoItem}; use async_trait::async_trait; use error_chain::error_chain; use htmlentity::entity::{ICodedDataTrait, decode}; @@ -260,6 +260,14 @@ impl ViralxxxpornProvider { format!("{}/{}", self.url, url.trim_start_matches("./")) } + fn normalize_video_item_url(&self, url: &str) -> String { + let normalized = self.normalize_url(url); + if normalized.contains("/videos/") { + return normalized.replacen("/videos/", "/video/", 1); + } + normalized + } + fn extract_id_from_url(url: &str) -> String { let parts = url .trim_end_matches('/') @@ -353,7 +361,7 @@ impl ViralxxxpornProvider { let href = captures .name("href") - .map(|m| self.normalize_url(m.as_str())) + .map(|m| self.normalize_video_item_url(m.as_str())) .unwrap_or_default(); let body = captures .name("body") @@ -402,13 +410,7 @@ impl ViralxxxpornProvider { item = item.views(views); } if !preview.is_empty() { - let mut format = VideoFormat::new( - preview.clone(), - "preview".to_string(), - "video/mp4".to_string(), - ); - format.add_http_header("Referer".to_string(), item.url.clone()); - item = item.preview(preview).formats(vec![format]); + item = item.preview(preview); } items.push(item); } @@ -450,7 +452,7 @@ impl ViralxxxpornProvider { else { continue; }; - let video_url = self.normalize_url(&video_url_raw); + let video_url = self.normalize_video_item_url(&video_url_raw); let id = Self::extract_id_from_url(&video_url); if id.is_empty() { continue; @@ -506,13 +508,7 @@ impl ViralxxxpornProvider { item = item.views(views); } if !preview.is_empty() { - let mut format = VideoFormat::new( - preview.clone(), - "preview".to_string(), - "video/mp4".to_string(), - ); - format.add_http_header("Referer".to_string(), item.url.clone()); - item = item.preview(preview).formats(vec![format]); + item = item.preview(preview); } items.push(item); } @@ -616,11 +612,12 @@ mod tests { assert_eq!(items[0].title, "Sample & Title"); assert_eq!( items[0].url, - "https://viralxxxporn.com/videos/336186/sample-video/" + "https://viralxxxporn.com/video/336186/sample-video/" ); assert_eq!(items[0].thumb, "https://cdn.example/thumb.jpg"); assert_eq!(items[0].duration, 754); assert_eq!(items[0].views, Some(1_200_000)); + assert!(items[0].formats.is_none()); } #[test] @@ -645,6 +642,7 @@ mod tests { assert_eq!(items[0].thumb, "https://cdn.example.com/thumb.jpg"); assert_eq!(items[0].duration, 780); assert_eq!(items[0].views, Some(29_000)); + assert!(items[0].formats.is_none()); } #[test]