diff --git a/src/providers/mod.rs b/src/providers/mod.rs index 2018b28..72a812a 100644 --- a/src/providers/mod.rs +++ b/src/providers/mod.rs @@ -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; @@ -64,7 +64,7 @@ pub static ALL_PROVIDERS: Lazy> = 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 }); diff --git a/archive/tube8.rs b/src/providers/tube8.rs similarity index 88% rename from archive/tube8.rs rename to src/providers/tube8.rs index 3c49de9..604160c 100644 --- a/archive/tube8.rs +++ b/src/providers/tube8.rs @@ -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> { 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 = self.get_video_items_from_html(text.clone()); @@ -283,7 +283,7 @@ impl Tube8Provider { let raw_videos = html.split("id=\"pagination\"").collect::>()[0] .split("-thumbs") .collect::>()[1] - .split("video-box ") + .split("\"video-box ") .collect::>()[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(">()[1] .split("\"") .collect::>()[0] @@ -342,67 +345,50 @@ impl Tube8Provider { .as_str(), ) .unwrap_or(0) as u32; - let site_name = title - .split("]") - .collect::>() - .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::>()[1] - .split("") + .split("view-rating-container") .collect::>()[0] - .split("href=\"") + .split(">()[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::>()[1] + .split("\"") + .collect::>()[0]; + let title = s.split(">") + .collect::>()[1] + .split(">()[0]; Self::push_unique( - &self.stars, + target, FilterOption { - id: s.split("/").collect::>()[4].to_string(), - title: s.split(">").collect::>()[1] - .split("<") - .collect::>()[0] - .trim() - .to_string(), + id: id.to_string(), + title: title.to_string(), }, ); - s.split(">").collect::>()[1] - .split("<") - .collect::>()[0] - .trim() - .to_string() + title.to_string() }) .collect::>() .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); }