missav upgrade
This commit is contained in:
160
src/api.rs
160
src/api.rs
@@ -471,6 +471,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
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<impl web::Responder, web::Error> {
|
||||
nsfw: true,
|
||||
});
|
||||
|
||||
// ok.porn
|
||||
status.add_channel(Channel {
|
||||
id: "okporn".to_string(),
|
||||
name: "Ok.porn".to_string(),
|
||||
@@ -516,6 +518,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
nsfw: true,
|
||||
});
|
||||
|
||||
// pornhat
|
||||
status.add_channel(Channel {
|
||||
id: "pornhat".to_string(),
|
||||
name: "Pornhat".to_string(),
|
||||
@@ -549,6 +552,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
nsfw: true,
|
||||
});
|
||||
|
||||
//perfectgirls
|
||||
status.add_channel(Channel {
|
||||
id: "perfectgirls".to_string(),
|
||||
name: "Perfectgirls".to_string(),
|
||||
@@ -582,6 +586,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
nsfw: true,
|
||||
});
|
||||
|
||||
// okxxx
|
||||
status.add_channel(Channel {
|
||||
id: "okxxx".to_string(),
|
||||
name: "Ok.xxx".to_string(),
|
||||
@@ -615,6 +620,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
nsfw: true,
|
||||
});
|
||||
|
||||
// homoxxx
|
||||
status.add_channel(Channel {
|
||||
id: "homoxxx".to_string(),
|
||||
name: "Homo.xxx".to_string(),
|
||||
@@ -648,6 +654,7 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
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<impl web::Responder, web::Error> {
|
||||
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<impl web::Responder, web::Error> {
|
||||
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(),
|
||||
|
||||
@@ -33,9 +33,9 @@ impl MissavProvider {
|
||||
url: "https://missav.ws".to_string(),
|
||||
}
|
||||
}
|
||||
async fn get(&self, cache:VideoCache, pool:DbPool, page: u8) -> Result<Vec<VideoItem>> {
|
||||
async fn get(&self, cache:VideoCache, pool:DbPool, page: u8, sort: String, options: ServerOptions) -> Result<Vec<VideoItem>> {
|
||||
|
||||
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<Vec<VideoItem>> {
|
||||
async fn query(&self, cache: VideoCache, pool:DbPool, page: u8, query: &str, sort: String, options: ServerOptions) -> Result<Vec<VideoItem>> {
|
||||
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("<meta property=\"og:title\" content=\"").collect::<Vec<&str>>()[1]
|
||||
.split("\"")
|
||||
.collect::<Vec<&str>>()[0]
|
||||
.collect::<Vec<&str>>()[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("<meta property=\"og:image\" content=\"").collect::<Vec<&str>>()[1]
|
||||
.split("\"")
|
||||
.collect::<Vec<&str>>()[0]
|
||||
@@ -357,12 +359,10 @@ impl Provider for MissavProvider {
|
||||
per_page: String,
|
||||
options: ServerOptions,
|
||||
) -> Vec<VideoItem> {
|
||||
let _ = options;
|
||||
let _ = per_page;
|
||||
let _ = sort;
|
||||
let videos: std::result::Result<Vec<VideoItem>, Error> = match query {
|
||||
Some(q) => self.query(cache, pool, page.parse::<u8>().unwrap_or(1), &q).await,
|
||||
None => self.get(cache, pool, page.parse::<u8>().unwrap_or(1)).await,
|
||||
Some(q) => self.query(cache, pool, page.parse::<u8>().unwrap_or(1), &q, sort, options).await,
|
||||
None => self.get(cache, pool, page.parse::<u8>().unwrap_or(1), sort, options).await,
|
||||
};
|
||||
match videos {
|
||||
Ok(v) => v,
|
||||
|
||||
@@ -28,6 +28,8 @@ pub struct VideosRequest {
|
||||
pub featured: Option<String>, // "featured",
|
||||
pub category: Option<String>, // "pmv"
|
||||
pub sites: Option<String>, //
|
||||
pub filter: Option<String>, //
|
||||
pub language: Option<String>, //
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
|
||||
@@ -35,6 +37,8 @@ pub struct ServerOptions{
|
||||
pub featured: Option<String>, // "featured",
|
||||
pub category: Option<String>, // "pmv"
|
||||
pub sites: Option<String>, //
|
||||
pub filter: Option<String>,
|
||||
pub language: Option<String>, // "en"
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, Debug)]
|
||||
|
||||
Reference in New Issue
Block a user