provider refactors and fixes
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
use crate::api::ClientVersion;
|
||||
use crate::util::parse_abbreviated_number;
|
||||
use crate::DbPool;
|
||||
use crate::providers::Provider;
|
||||
use crate::status::*;
|
||||
use crate::util::cache::VideoCache;
|
||||
use crate::util::time::parse_time_to_seconds;
|
||||
use crate::videos::{ServerOptions, VideoItem};
|
||||
@@ -35,6 +37,50 @@ impl PornhubProvider {
|
||||
}
|
||||
}
|
||||
|
||||
fn build_channel(&self, _clientversion: ClientVersion) -> Channel {
|
||||
Channel {
|
||||
id: "pornhub".to_string(),
|
||||
name: "Pornhub".to_string(),
|
||||
description: "Pornhub Free Videos".to_string(),
|
||||
premium: false,
|
||||
favicon: "https://www.google.com/s2/favicons?sz=64&domain=pornhub.com".to_string(),
|
||||
status: "active".to_string(),
|
||||
categories: vec![],
|
||||
options: vec![ChannelOption {
|
||||
id: "sort".to_string(),
|
||||
title: "Sort".to_string(),
|
||||
description: "Sort the Videos".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(),
|
||||
},
|
||||
FilterOption {
|
||||
id: "cm".to_string(),
|
||||
title: "Newest".to_string(),
|
||||
},
|
||||
],
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: Some(1800),
|
||||
}
|
||||
}
|
||||
|
||||
async fn get(
|
||||
&self,
|
||||
cache: VideoCache,
|
||||
@@ -216,10 +262,10 @@ impl PornhubProvider {
|
||||
.unwrap_or("");
|
||||
|
||||
let parts: Vec<&str> = href.split('/').collect();
|
||||
if parts.len() >= 3 {
|
||||
if let (Some(kind), Some(name)) = (parts.get(1), parts.get(2)) {
|
||||
(
|
||||
Some(format!("@{}:{}", parts[1], parts[2].replace('-', " "))),
|
||||
Some(parts[2].to_string()),
|
||||
Some(format!("@{}:{}", kind, name.replace('-', " "))),
|
||||
Some((*name).to_string()),
|
||||
)
|
||||
} else {
|
||||
(None, None)
|
||||
@@ -291,4 +337,8 @@ impl Provider for PornhubProvider {
|
||||
vec![]
|
||||
})
|
||||
}
|
||||
|
||||
fn get_channel(&self, clientversion: ClientVersion) -> Option<Channel> {
|
||||
Some(self.build_channel(clientversion))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user