diff --git a/src/providers/omgxxx.rs b/src/providers/omgxxx.rs index 85c8922..47b7c5f 100644 --- a/src/providers/omgxxx.rs +++ b/src/providers/omgxxx.rs @@ -11,7 +11,7 @@ use error_chain::error_chain; use htmlentity::entity::{ICodedDataTrait, decode}; use std::sync::{Arc, RwLock}; use std::vec; -use std::{env, thread}; +use std::{thread}; error_chain! { foreign_links { @@ -25,6 +25,7 @@ pub struct OmgxxxProvider { url: String, sites: Arc>>, networks: Arc>>, + stars: Arc>>, } impl OmgxxxProvider { pub fn new() -> Self { @@ -38,6 +39,10 @@ impl OmgxxxProvider { id: "all".to_string(), title: "All".to_string(), }])), + stars: Arc::new(RwLock::new(vec![FilterOption { + id: "all".to_string(), + title: "All".to_string(), + }])), }; // Kick off the background load but return immediately @@ -70,6 +75,44 @@ impl OmgxxxProvider { }); } + async fn load_stars(base_url: &str, networks: Arc>>) -> Result<()> { + let mut requester = util::requester::Requester::new(); + let mut page = 0; + loop { + page += 1; + let text = requester + .get(format!("{}/sites/{}/", &base_url, page).as_str()) + .await + .unwrap(); + if text.contains("404 Not Found") || text.is_empty() { + break; + } + let sites_div = text + .split("id=\"list_content_sources_sponsors_list_items\"").collect::>()[1] + .split("class=\"pagination\"").collect::>()[0]; + for sites_element in + sites_div.split("class=\"headline\"").collect::>()[1..].to_vec() + { + let site_url = sites_element.split("href=\"").collect::>()[1] + .split("\"") + .collect::>()[0]; + let site_id = site_url.split("/").collect::>()[4].to_string(); + let site_name = sites_element.split("

").collect::>()[1] + .split("<") + .collect::>()[0] + .to_string(); + Self::push_unique( + &networks, + FilterOption { + id: site_id, + title: site_name, + }, + ); + } + } + return Ok(()); + } + async fn load_sites(base_url: &str, networks: Arc>>) -> Result<()> { let mut requester = util::requester::Requester::new(); let mut page = 0; @@ -237,6 +280,12 @@ impl OmgxxxProvider { { sort_string = format!("networks/{}", options.network.as_ref().unwrap()); } + if options.sites.is_some() + && !options.sites.as_ref().unwrap().is_empty() + && options.sites.as_ref().unwrap() != "all" + { + sort_string = format!("sites/{}", 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)) => {