This commit is contained in:
Simon
2026-02-23 17:34:33 +00:00
parent 61840b7ec5
commit 718e7c3f78
2 changed files with 35 additions and 49 deletions

View File

@@ -42,7 +42,7 @@ pub mod hypnotube;
pub mod freepornvideosxxx;
pub mod hentaihaven;
pub mod chaturbate;
// pub mod tube8;
pub mod tube8;
// convenient alias
pub type DynProvider = Arc<dyn Provider>;
@@ -64,7 +64,7 @@ pub static ALL_PROVIDERS: Lazy<HashMap<&'static str, DynProvider>> = Lazy::new(|
m.insert("freepornvideosxxx", Arc::new(freepornvideosxxx::FreepornvideosxxxProvider::new()) as DynProvider);
m.insert("hentaihaven", Arc::new(hentaihaven::HentaihavenProvider::new()) as DynProvider);
m.insert("chaturbate", Arc::new(chaturbate::ChaturbateProvider::new()) as DynProvider);
// m.insert("tube8", Arc::new(tube8::Tube8Provider::new()) as DynProvider);
m.insert("tube8", Arc::new(tube8::Tube8Provider::new()) as DynProvider);
// add more here as you migrate them
m
});

View File

@@ -89,15 +89,15 @@ impl Tube8Provider {
title: "Rating".into(),
},
FilterOption {
id: "mostviewed.html".into(),
id: "mostviewed".into(),
title: "Most Viewed".into(),
},
FilterOption {
id: "longest.html".into(),
id: "longest".into(),
title: "Duration".into(),
},
FilterOption {
id: "newest.html".into(),
id: "newest".into(),
title: "Newest".into(),
},
],
@@ -135,10 +135,10 @@ impl Tube8Provider {
options: ServerOptions,
) -> Result<Vec<VideoItem>> {
let mut sort_string: String = match sort {
"mostviewed.html" => "mostviewed.html/".to_string(),
"longest.html" => "longest.html/".to_string(),
"newest.html" => "newest.html/".to_string(),
_ => "".to_string(),
"mostviewed" => "most-viewed/page/".to_string(),
"longest" => "longest/page/".to_string(),
"newest" => "newest/page/".to_string(),
_ => "top/page/".to_string(),
};
if options.sites.is_some()
&& !options.sites.as_ref().unwrap().is_empty()
@@ -175,7 +175,7 @@ impl Tube8Provider {
vec![]
}
};
println!("Video URL {:?}", video_url);
let mut requester = options.requester.clone().unwrap();
let text = requester.get(&video_url, None).await.unwrap();
let video_items: Vec<VideoItem> = self.get_video_items_from_html(text.clone());
@@ -283,7 +283,7 @@ impl Tube8Provider {
let raw_videos = html.split("id=\"pagination\"").collect::<Vec<&str>>()[0]
.split("-thumbs")
.collect::<Vec<&str>>()[1]
.split("video-box ")
.split("\"video-box ")
.collect::<Vec<&str>>()[1..]
.to_vec();
for video_segment in &raw_videos {
@@ -291,6 +291,9 @@ impl Tube8Provider {
// for (index, line) in vid.iter().enumerate() {
// println!("Line {}: {}", index, line);
// }
if video_segment.contains("adsbytrafficjunky"){
continue;
}
let video_url: String = format!("{}{}", self.url, video_segment.split("<a href=\"").collect::<Vec<&str>>()[1]
.split("\"")
.collect::<Vec<&str>>()[0]
@@ -342,67 +345,50 @@ impl Tube8Provider {
.as_str(),
)
.unwrap_or(0) as u32;
let site_name = title
.split("]")
.collect::<Vec<&str>>()
.first()
.unwrap_or(&"")
.trim_start_matches("[");
let site_id = self
.get_site_id_from_name(site_name)
.unwrap_or("".to_string());
let mut tags = match video_segment.contains("class=\"models\">") {
let mut tags = match video_segment.contains("info-views-container block") {
true => video_segment
.split("class=\"models\">")
.split("info-views-container block")
.collect::<Vec<&str>>()[1]
.split("</div>")
.split("view-rating-container")
.collect::<Vec<&str>>()[0]
.split("href=\"")
.split("<a ")
.collect::<Vec<&str>>()[1..]
.into_iter()
.map(|s| {
let mut target = &self.stars;
if s.contains("author-title-text "){
target = &self.sites
}
let id = s.split("href=\"")
.collect::<Vec<&str>>()[1]
.split("\"")
.collect::<Vec<&str>>()[0];
let title = s.split(">")
.collect::<Vec<&str>>()[1]
.split("</a")
.collect::<Vec<&str>>()[0];
Self::push_unique(
&self.stars,
target,
FilterOption {
id: s.split("/").collect::<Vec<&str>>()[4].to_string(),
title: s.split(">").collect::<Vec<&str>>()[1]
.split("<")
.collect::<Vec<&str>>()[0]
.trim()
.to_string(),
id: id.to_string(),
title: title.to_string(),
},
);
s.split(">").collect::<Vec<&str>>()[1]
.split("<")
.collect::<Vec<&str>>()[0]
.trim()
.to_string()
title.to_string()
})
.collect::<Vec<String>>()
.to_vec(),
false => vec![],
};
if !site_id.is_empty() {
Self::push_unique(
&self.sites,
FilterOption {
id: site_id,
title: site_name.to_string(),
},
);
tags.push(site_name.to_string());
}
let video_item = VideoItem::new(
id,
title,
video_url.to_string(),
"omgxxx".to_string(),
"tube8".to_string(),
thumb,
duration,
)
.views(views)
.preview(preview)
.tags(tags);
items.push(video_item);
}