diff --git a/src/api.rs b/src/api.rs index 9df19f5..631a0f1 100644 --- a/src/api.rs +++ b/src/api.rs @@ -471,6 +471,7 @@ async fn status(req: HttpRequest) -> Result { nsfw: true, }); + // Redtube status.add_channel(Channel { id: "redtube".to_string(), name: "Redtube".to_string(), @@ -483,6 +484,7 @@ async fn status(req: HttpRequest) -> Result { nsfw: true, }); + // ok.porn status.add_channel(Channel { id: "okporn".to_string(), name: "Ok.porn".to_string(), @@ -516,7 +518,8 @@ async fn status(req: HttpRequest) -> Result { nsfw: true, }); - status.add_channel(Channel { + // pornhat + status.add_channel(Channel { id: "pornhat".to_string(), name: "Pornhat".to_string(), description: "free HD porn videos".to_string(), @@ -549,7 +552,8 @@ async fn status(req: HttpRequest) -> Result { nsfw: true, }); - status.add_channel(Channel { + //perfectgirls + status.add_channel(Channel { id: "perfectgirls".to_string(), name: "Perfectgirls".to_string(), description: "Perfect Girls Tube".to_string(), @@ -582,6 +586,7 @@ async fn status(req: HttpRequest) -> Result { nsfw: true, }); + // okxxx status.add_channel(Channel { id: "okxxx".to_string(), name: "Ok.xxx".to_string(), @@ -615,7 +620,8 @@ async fn status(req: HttpRequest) -> Result { nsfw: true, }); - status.add_channel(Channel { + // homoxxx + status.add_channel(Channel { id: "homoxxx".to_string(), name: "Homo.xxx".to_string(), description: "Best Gay Porn".to_string(), @@ -648,6 +654,7 @@ async fn status(req: HttpRequest) -> Result { nsfw: true, }); + // hentaimoon status.add_channel(Channel { id: "hentaimoon".to_string(), name: "Hentai Moon".to_string(), @@ -681,6 +688,7 @@ async fn status(req: HttpRequest) -> Result { nsfw: true, }); + //missav status.add_channel(Channel { id: "missav".to_string(), name: "MissAV".to_string(), @@ -690,28 +698,124 @@ async fn status(req: HttpRequest) -> Result { status: "active".to_string(), categories: vec![], options: vec![ - // ChannelOption { - // id: "sort".to_string(), - // title: "Sort".to_string(), - // description: "Sort the Videos".to_string(), //"Sort the videos by Date or Name.".to_string(), - // systemImage: "list.number".to_string(), - // colorName: "blue".to_string(), - // options: vec![ - // FilterOption { - // id: "new".to_string(), - // title: "New".to_string(), - // }, - // FilterOption { - // id: "popular".to_string(), - // title: "Popular".to_string(), - // }, - // FilterOption { - // id: "top-rated".to_string(), - // title: "Top Rated".to_string(), - // }, - // ], - // multiSelect: false, - // } + ChannelOption { + id: "sort".to_string(), + title: "Sort".to_string(), + description: "Sort the Videos".to_string(), //"Sort the videos by Date or Name.".to_string(), + systemImage: "list.number".to_string(), + colorName: "blue".to_string(), + options: vec![ + FilterOption { + id: "released_at".to_string(), + title: "Release Date".to_string(), + }, + FilterOption { + id: "published_at".to_string(), + title: "Recent Update".to_string(), + }, + FilterOption { + id: "today_views".to_string(), + title: "Today Views".to_string(), + }, + FilterOption { + id: "weekly_views".to_string(), + title: "Weekly Views".to_string(), + }, + FilterOption { + id: "monthly_views".to_string(), + title: "Monthly Views".to_string(), + }, + FilterOption { + id: "views".to_string(), + title: "Total Views".to_string(), + }, + ], + multiSelect: false, + }, + ChannelOption { + id: "filter".to_string(), + title: "Filter".to_string(), + description: "Filter the Videos".to_string(), //"Sort the videos by Date or Name.".to_string(), + systemImage: "line.horizontal.3.decrease.circle".to_string(), + colorName: "green".to_string(), + options: vec![ + FilterOption { + id: "new".to_string(), + title: "Recent update".to_string(), + }, + FilterOption { + id: "release".to_string(), + title: "New Releases".to_string(), + }, + FilterOption { + id: "uncensored-leak".to_string(), + title: "Uncensored".to_string(), + }, + FilterOption { + id: "english-subtitle".to_string(), + title: "English subtitle".to_string(), + }, + ], + multiSelect: false, + }, + ChannelOption { + id: "language".to_string(), + title: "Language".to_string(), + description: "What Language to fetch".to_string(), //"Sort the videos by Date or Name.".to_string(), + systemImage: "flag.fill".to_string(), + colorName: "white".to_string(), + options: vec![ + FilterOption { + id: "en".to_string(), + title: "English".to_string(), + }, + FilterOption { + id: "cn".to_string(), + title: "简体中文".to_string(), + }, + FilterOption { + id: "ja".to_string(), + title: "日本語".to_string(), + }, + FilterOption { + id: "ko".to_string(), + title: "한국의".to_string(), + }, + FilterOption { + id: "ms".to_string(), + title: "Melayu".to_string(), + }, + FilterOption { + id: "th".to_string(), + title: "ไทย".to_string(), + }, + FilterOption { + id: "de".to_string(), + title: "Deutsch".to_string(), + }, + FilterOption { + id: "fr".to_string(), + title: "Français".to_string(), + }, + FilterOption { + id: "vi".to_string(), + title: "Tiếng Việt".to_string(), + }, + FilterOption { + id: "id".to_string(), + title: "Bahasa Indonesia".to_string(), + }, + FilterOption { + id: "fil".to_string(), + title: "Filipino".to_string(), + }, + FilterOption { + id: "pt".to_string(), + title: "Português".to_string(), + }, + ], + multiSelect: false, + } ], nsfw: true, }); @@ -780,7 +884,17 @@ async fn videos_post( .as_deref() .unwrap_or("") .to_string(); - let options = ServerOptions { featured: Some(featured), category: Some(category), sites: Some(sites) }; + let filter = video_request + .filter + .as_deref() + .unwrap_or("new") + .to_string(); + let language = video_request + .language + .as_deref() + .unwrap_or("en") + .to_string(); + let options = ServerOptions { featured: Some(featured), category: Some(category), sites: Some(sites), filter: Some(filter), language: Some(language) }; let video_items = provider .get_videos( cache.get_ref().clone(), diff --git a/src/providers/missav.rs b/src/providers/missav.rs index e5118bb..2872509 100644 --- a/src/providers/missav.rs +++ b/src/providers/missav.rs @@ -33,9 +33,9 @@ impl MissavProvider { url: "https://missav.ws".to_string(), } } - async fn get(&self, cache:VideoCache, pool:DbPool, page: u8) -> Result> { + async fn get(&self, cache:VideoCache, pool:DbPool, page: u8, sort: String, options: ServerOptions) -> Result> { - let url_str = format!("{}/en/new?page={}", self.url, page); + let url_str = format!("{}/{}/{}?page={}&sort={}", self.url, options.language.unwrap(), options.filter.unwrap(), page, sort); let old_items = match cache.get(&url_str) { Some((time, items)) => { @@ -103,11 +103,11 @@ impl MissavProvider { Ok(video_items) } } - async fn query(&self, cache: VideoCache, pool:DbPool, page: u8, query: &str) -> Result> { + async fn query(&self, cache: VideoCache, pool:DbPool, page: u8, query: &str, sort: String, options: ServerOptions) -> Result> { let search_string = query.replace(" ", "%20"); let url_str = format!( - "{}/en/search/{}?page={}", - self.url, search_string, page + "{}/{}/search/{}?page={}&sort={}", + self.url, options.language.unwrap(), search_string, page, sort ); // Check our Video Cache. If the result is younger than 1 hour, we return it. let old_items = match cache.get(&url_str) { @@ -245,10 +245,12 @@ impl MissavProvider { } let mut title = vid.split(">()[1] .split("\"") - .collect::>()[0] + .collect::>()[0].trim() .to_string(); title = decode(title.as_bytes()).to_string().unwrap_or(title); - + if url_str.contains("uncensored") { + title = format!("[Uncensored] {}", title); + } let thumb = vid.split(">()[1] .split("\"") .collect::>()[0] @@ -294,7 +296,7 @@ impl MissavProvider { tags.push(format!("@genre:{}", tag)); } } - } + } if vid.contains("Genre:"){ for tag_snippet in vid.split("Genre:").collect::>()[1] @@ -357,12 +359,10 @@ impl Provider for MissavProvider { per_page: String, options: ServerOptions, ) -> Vec { - let _ = options; let _ = per_page; - let _ = sort; let videos: std::result::Result, Error> = match query { - Some(q) => self.query(cache, pool, page.parse::().unwrap_or(1), &q).await, - None => self.get(cache, pool, page.parse::().unwrap_or(1)).await, + Some(q) => self.query(cache, pool, page.parse::().unwrap_or(1), &q, sort, options).await, + None => self.get(cache, pool, page.parse::().unwrap_or(1), sort, options).await, }; match videos { Ok(v) => v, diff --git a/src/videos.rs b/src/videos.rs index ca57249..688d0f2 100644 --- a/src/videos.rs +++ b/src/videos.rs @@ -28,6 +28,8 @@ pub struct VideosRequest { pub featured: Option, // "featured", pub category: Option, // "pmv" pub sites: Option, // + pub filter: Option, // + pub language: Option, // } #[derive(serde::Serialize, serde::Deserialize, Debug, Clone)] @@ -35,6 +37,8 @@ pub struct ServerOptions{ pub featured: Option, // "featured", pub category: Option, // "pmv" pub sites: Option, // + pub filter: Option, + pub language: Option, // "en" } #[derive(serde::Serialize, Debug)]