pornhub update
This commit is contained in:
28
src/api.rs
28
src/api.rs
@@ -124,7 +124,33 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
|||||||
favicon: "https://www.google.com/s2/favicons?sz=64&domain=pornhub.com".to_string(),
|
favicon: "https://www.google.com/s2/favicons?sz=64&domain=pornhub.com".to_string(),
|
||||||
status: "active".to_string(),
|
status: "active".to_string(),
|
||||||
categories: vec![],
|
categories: vec![],
|
||||||
options: 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: "mr".to_string(),
|
||||||
|
title: "Most Recent".to_string(),
|
||||||
|
},
|
||||||
|
FilterOption {
|
||||||
|
id: "mv".to_string(),
|
||||||
|
title: "Most Viewed".to_string(),
|
||||||
|
},
|
||||||
|
FilterOption {
|
||||||
|
id: "tr".to_string(),
|
||||||
|
title: "Top Rated".to_string(),
|
||||||
|
},
|
||||||
|
FilterOption {
|
||||||
|
id: "lg".to_string(),
|
||||||
|
title: "Longest".to_string(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
multiSelect: false,
|
||||||
|
},],
|
||||||
nsfw: true,
|
nsfw: true,
|
||||||
});
|
});
|
||||||
// pmvhaven
|
// pmvhaven
|
||||||
|
|||||||
@@ -34,12 +34,10 @@ impl PornhubProvider {
|
|||||||
&self,
|
&self,
|
||||||
cache: VideoCache,
|
cache: VideoCache,
|
||||||
page: u8,
|
page: u8,
|
||||||
|
sort: &str,
|
||||||
) -> Result<Vec<VideoItem>> {
|
) -> Result<Vec<VideoItem>> {
|
||||||
let mut url = format!("{}/video?page={}", self.url, page);
|
let mut url = format!("{}/video?page={}", self.url, page);
|
||||||
if page == 1 {
|
url += format!("&o={}", sort).as_str();
|
||||||
url = format!("{}/video", self.url);
|
|
||||||
}
|
|
||||||
|
|
||||||
let old_items = match cache.get(&url) {
|
let old_items = match cache.get(&url) {
|
||||||
Some((time, items)) => {
|
Some((time, items)) => {
|
||||||
if time.elapsed().unwrap_or_default().as_secs() < 60 * 5 {
|
if time.elapsed().unwrap_or_default().as_secs() < 60 * 5 {
|
||||||
@@ -102,14 +100,11 @@ impl PornhubProvider {
|
|||||||
cache: VideoCache,
|
cache: VideoCache,
|
||||||
page: u8,
|
page: u8,
|
||||||
query: &str,
|
query: &str,
|
||||||
|
sort: &str,
|
||||||
) -> Result<Vec<VideoItem>> {
|
) -> Result<Vec<VideoItem>> {
|
||||||
let mut split_string = "<ul id=\"video";
|
let mut split_string = "<ul id=\"video";
|
||||||
let search_string = query.to_lowercase().trim().replace(" ", "+");
|
let search_string = query.to_lowercase().trim().replace(" ", "+");
|
||||||
let mut url = format!("{}/video/search?search={}&page={}", self.url, search_string, page);
|
let mut url = format!("{}/video/search?search={}&page={}", self.url, search_string, page);
|
||||||
if page == 1 {
|
|
||||||
url = format!("{}/video/search?search={}", self.url, search_string);
|
|
||||||
}
|
|
||||||
|
|
||||||
if query.starts_with("@"){
|
if query.starts_with("@"){
|
||||||
let url_parts = query[1..].split(":").collect::<Vec<&str>>();
|
let url_parts = query[1..].split(":").collect::<Vec<&str>>();
|
||||||
url = [self.url.to_string(), url_parts[0].to_string(), url_parts[1].replace("-", " ").to_string(), "videos?page=".to_string()].join("/");
|
url = [self.url.to_string(), url_parts[0].to_string(), url_parts[1].replace("-", " ").to_string(), "videos?page=".to_string()].join("/");
|
||||||
@@ -120,9 +115,10 @@ impl PornhubProvider {
|
|||||||
if query.contains("@channels"){
|
if query.contains("@channels"){
|
||||||
split_string = "dropdownHottestVideos";
|
split_string = "dropdownHottestVideos";
|
||||||
}
|
}
|
||||||
println!("Query URL: {}", url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
url += format!("&o={}", sort).as_str();
|
||||||
|
|
||||||
// Check our Video Cache. If the result is younger than 1 hour, we return it.
|
// Check our Video Cache. If the result is younger than 1 hour, we return it.
|
||||||
let old_items = match cache.get(&url) {
|
let old_items = match cache.get(&url) {
|
||||||
Some((time, items)) => {
|
Some((time, items)) => {
|
||||||
@@ -293,16 +289,15 @@ impl Provider for PornhubProvider {
|
|||||||
) -> Vec<VideoItem> {
|
) -> Vec<VideoItem> {
|
||||||
let _ = category;
|
let _ = category;
|
||||||
let _ = per_page;
|
let _ = per_page;
|
||||||
let _ = sort;
|
|
||||||
let _ = featured; // Ignored in this implementation
|
let _ = featured; // Ignored in this implementation
|
||||||
let _ = pool; // Ignored in this implementation
|
let _ = pool; // Ignored in this implementation
|
||||||
let videos: std::result::Result<Vec<VideoItem>, Error> = match query {
|
let videos: std::result::Result<Vec<VideoItem>, Error> = match query {
|
||||||
Some(q) => {
|
Some(q) => {
|
||||||
self.query(cache, page.parse::<u8>().unwrap_or(1), &q)
|
self.query(cache, page.parse::<u8>().unwrap_or(1), &q, &sort)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
self.get(cache, page.parse::<u8>().unwrap_or(1))
|
self.get(cache, page.parse::<u8>().unwrap_or(1), &sort)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user