filter/sort for pmvhaven

This commit is contained in:
Simon
2025-07-20 07:50:10 +00:00
parent 323fbfd5c9
commit 859ccd5efb
3 changed files with 9077 additions and 5 deletions

View File

@@ -166,8 +166,8 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
id: "category".to_string(), id: "category".to_string(),
title: "Category".to_string(), title: "Category".to_string(),
description: "Category of PMV Video get".to_string(), //"Sort the videos by Date or Name.".to_string(), description: "Category of PMV Video get".to_string(), //"Sort the videos by Date or Name.".to_string(),
systemImage: "list.number".to_string(), systemImage: "folder".to_string(),
colorName: "blue".to_string(), colorName: "yellow".to_string(),
options: vec![ options: vec![
FilterOption { FilterOption {
id: "all".to_string(), id: "all".to_string(),
@@ -199,6 +199,28 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
}, },
], ],
multiSelect: false, multiSelect: false,
},
ChannelOption {
id: "sort".to_string(),
title: "Filter".to_string(),
description: "Filter PMV Videos".to_string(),
systemImage: "list.number".to_string(),
colorName: "blue".to_string(),
options: vec![
FilterOption {
id: "Newest".to_string(),
title: "Newest".to_string(),
},
FilterOption {
id: "Top Rated".to_string(),
title: "Top Rated".to_string(),
},
FilterOption {
id: "Most Viewed".to_string(),
title: "Most Viewed".to_string(),
}
],
multiSelect: false,
}], }],
nsfw: true, nsfw: true,
}); });

View File

@@ -141,6 +141,10 @@ impl PmvhavenRequest {
self.hypno = false; self.hypno = false;
self self
} }
fn sort(&mut self, sort:String) -> Self {
self.activeView = sort;
self
}
} }
#[derive(serde::Serialize)] #[derive(serde::Serialize)]
@@ -250,10 +254,11 @@ impl PmvhavenProvider {
url: "https://pmvhaven.com".to_string(), url: "https://pmvhaven.com".to_string(),
} }
} }
async fn get(&self, cache: VideoCache, page: u8, category: String) -> Result<Vec<VideoItem>> { async fn get(&self, cache: VideoCache, page: u8, category: String, sort:String) -> Result<Vec<VideoItem>> {
let index = format!("pmvhaven:{}:{}", page, category); let index = format!("pmvhaven:{}:{}", page, category);
let url = format!("{}/api/getmorevideos", self.url); let url = format!("{}/api/getmorevideos", self.url);
let mut request = PmvhavenRequest::new(page as u32); let mut request = PmvhavenRequest::new(page as u32);
request = request.sort(sort);
println!("Category: {}", category); println!("Category: {}", category);
request = match category.as_str() { request = match category.as_str() {
"hypno" => { request.hypno(); request }, "hypno" => { request.hypno(); request },
@@ -432,13 +437,12 @@ impl Provider for PmvhavenProvider {
category: String, category: String,
) -> Vec<VideoItem> { ) -> Vec<VideoItem> {
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) => self.query(cache, page.parse::<u8>().unwrap_or(1), &q).await, Some(q) => self.query(cache, page.parse::<u8>().unwrap_or(1), &q).await,
None => { None => {
self.get(cache, page.parse::<u8>().unwrap_or(1), category) self.get(cache, page.parse::<u8>().unwrap_or(1), category, sort)
.await .await
} }
}; };

9046
ui.swift Normal file

File diff suppressed because it is too large Load Diff