diff --git a/src/api.rs b/src/api.rs index fdaa56c..5436111 100644 --- a/src/api.rs +++ b/src/api.rs @@ -20,7 +20,7 @@ use crate::util::requester::Requester; use crate::{DbPool, db, status::*, videos::*}; use cute::c; use std::sync::Arc; -use crate::providers::{Provider, DynProvider, ALL_PROVIDERS}; +use crate::providers::{DynProvider, ALL_PROVIDERS}; #[derive(Debug, Clone)] pub struct ClientVersion { @@ -1138,10 +1138,6 @@ async fn status(req: HttpRequest) -> Result { } for provider in ALL_PROVIDERS.values() { - println!( - "Loaded provider (dyn): {:?}", - std::any::type_name::<&dyn Provider>() - ); status.add_channel(provider.get_channel(clientversion.clone())); } status.iconUrl = format!("http://{}/favicon.ico", host).to_string(); @@ -1214,6 +1210,11 @@ async fn videos_post( .as_deref() .unwrap_or("en") .to_string(); + let network = video_request + .networks + .as_deref() + .unwrap_or("") + .to_string(); let options = ServerOptions { featured: Some(featured), category: Some(category), @@ -1221,6 +1222,7 @@ async fn videos_post( filter: Some(filter), language: Some(language), requester: Some(requester), + network: Some(network), }; let video_items = provider .get_videos( diff --git a/src/providers/omgxxx.rs b/src/providers/omgxxx.rs index c9e03b3..d062dc3 100644 --- a/src/providers/omgxxx.rs +++ b/src/providers/omgxxx.rs @@ -28,7 +28,6 @@ pub struct OmgxxxProvider { } impl OmgxxxProvider { pub fn new() -> Self { - println!("new"); let provider = OmgxxxProvider { url: "https://www.omg.xxx".to_string(), sites: Arc::new(RwLock::new(vec![])), @@ -41,7 +40,6 @@ impl OmgxxxProvider { } fn spawn_initial_load(&self) { - println!("spawn_initial_load"); let url = self.url.clone(); // let sites = Arc::clone(&self.sites); let networks = Arc::clone(&self.networks); @@ -85,7 +83,6 @@ impl OmgxxxProvider { // } async fn load_networks(base_url: &str, networks: Arc>>) -> Result<()> { - println!("load_networks"); let mut requester = util::requester::Requester::new(); let text = requester.get(&base_url).await.unwrap(); let networks_div = text.split("class=\"sites__list\"").collect::>()[1] @@ -199,11 +196,14 @@ impl OmgxxxProvider { sort: &str, options: ServerOptions, ) -> Result> { - let sort_string = match sort { - "top-rated" => "top-rated", - "most-popular" => "most-popular", - _ => "latest-updates", + let mut sort_string:String = match sort { + "top-rated" => "top-rated".to_string(), + "most-popular" => "most-popular".to_string(), + _ => "latest-updates".to_string(), }; + if options.network.is_some() && !options.network.as_ref().unwrap().is_empty(){ + sort_string = format!("networks/{}",options.network.as_ref().unwrap()); + } let video_url = format!("{}/{}/{}/", self.url, sort_string, page); let old_items = match cache.get(&video_url) { Some((time, items)) => { @@ -219,6 +219,7 @@ impl OmgxxxProvider { } }; + let mut requester = options.requester.clone().unwrap(); let text = requester.get(&video_url).await.unwrap(); let video_items: Vec = self.get_video_items_from_html(text.clone()); @@ -427,10 +428,6 @@ impl Provider for OmgxxxProvider { } } fn get_channel(&self, clientversion: ClientVersion) -> crate::status::Channel { - println!( - "Getting channel for omgxxx with client version: {:?}", - clientversion - ); self.build_channel(clientversion) } } diff --git a/src/videos.rs b/src/videos.rs index ea6ad0d..ab057bb 100644 --- a/src/videos.rs +++ b/src/videos.rs @@ -30,6 +30,7 @@ pub struct VideosRequest { pub sites: Option, // pub filter: Option, // pub language: Option, // + pub networks: Option, // } #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] @@ -40,6 +41,7 @@ pub struct ServerOptions { pub filter: Option, pub language: Option, // "en" pub requester: Option, + pub network: Option, // } #[derive(serde::Serialize, Debug)]