paradise hill
This commit is contained in:
26
src/api.rs
26
src/api.rs
@@ -813,6 +813,29 @@ async fn status(req: HttpRequest) -> Result<impl web::Responder, web::Error> {
|
||||
cacheDuration: Some(1800),
|
||||
});
|
||||
|
||||
// paradisehill
|
||||
status.add_channel(Channel {
|
||||
id: "paradisehill".to_string(),
|
||||
name: "Paradisehill".to_string(),
|
||||
description: "Porn Movies on Paradise Hill".to_string(),
|
||||
premium: false,
|
||||
favicon: "https://en.paradisehill.cc/img/big-logo.svg".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(), //"Sort the videos by Date or Name.".to_string(),
|
||||
systemImage: "list.number".to_string(),
|
||||
colorName: "blue".to_string(),
|
||||
options: vec![
|
||||
],
|
||||
multiSelect: false,
|
||||
}],
|
||||
nsfw: true,
|
||||
cacheDuration: None,
|
||||
});
|
||||
|
||||
// youjizz
|
||||
status.add_channel(Channel {
|
||||
id: "youjizz".to_string(),
|
||||
@@ -1244,6 +1267,9 @@ pub fn get_provider(channel: &str) -> Option<AnyProvider> {
|
||||
"youjizz" => Some(AnyProvider::Youjizz(
|
||||
crate::providers::youjizz::YoujizzProvider::new(),
|
||||
)),
|
||||
"paradisehill" => Some(AnyProvider::Paradisehill(
|
||||
crate::providers::paradisehill::ParadisehillProvider::new(),
|
||||
)),
|
||||
_ => Some(AnyProvider::Perverzija(PerverzijaProvider::new())),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ pub mod porn00;
|
||||
// pub mod noodlemagazine;
|
||||
pub mod freshporno;
|
||||
pub mod youjizz;
|
||||
pub mod paradisehill;
|
||||
|
||||
|
||||
pub trait Provider {
|
||||
@@ -63,6 +64,7 @@ pub enum AnyProvider {
|
||||
// Noodlemagazine(crate::providers::noodlemagazine::NoodlemagazineProvider),
|
||||
Freshporno(crate::providers::freshporno::FreshpornoProvider),
|
||||
Youjizz(crate::providers::youjizz::YoujizzProvider),
|
||||
Paradisehill(crate::providers::paradisehill::ParadisehillProvider),
|
||||
}
|
||||
|
||||
impl Provider for AnyProvider {
|
||||
@@ -172,6 +174,10 @@ impl Provider for AnyProvider {
|
||||
AnyProvider::Youjizz(p) => {
|
||||
p.get_videos(cache, pool, sort, query, page, per_page, options,)
|
||||
.await
|
||||
},
|
||||
AnyProvider::Paradisehill(p) => {
|
||||
p.get_videos(cache, pool, sort, query, page, per_page, options,)
|
||||
.await
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
196
src/providers/paradisehill.rs
Normal file
196
src/providers/paradisehill.rs
Normal file
@@ -0,0 +1,196 @@
|
||||
use std::vec;
|
||||
use std::env;
|
||||
use error_chain::error_chain;
|
||||
use htmlentity::entity::{decode, ICodedDataTrait};
|
||||
use futures::future::join_all;
|
||||
use wreq::Client;
|
||||
use wreq::Proxy;
|
||||
use wreq_util::Emulation;
|
||||
use crate::db;
|
||||
use crate::providers::Provider;
|
||||
use crate::util::cache::VideoCache;
|
||||
use crate::util::flaresolverr::{FlareSolverrRequest, Flaresolverr};
|
||||
use crate::util::requester;
|
||||
use crate::videos::ServerOptions;
|
||||
use crate::videos::{VideoItem};
|
||||
use crate::DbPool;
|
||||
use crate::util::requester::Requester;
|
||||
|
||||
|
||||
error_chain! {
|
||||
foreign_links {
|
||||
Io(std::io::Error);
|
||||
HttpRequest(wreq::Error);
|
||||
JsonError(serde_json::Error);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct ParadisehillProvider {
|
||||
url: String,
|
||||
}
|
||||
impl ParadisehillProvider {
|
||||
pub fn new() -> Self {
|
||||
ParadisehillProvider {
|
||||
url: "https://en.paradisehill.cc".to_string()
|
||||
}
|
||||
}
|
||||
async fn get(&self, cache:VideoCache, page: u8, options: ServerOptions) -> Result<Vec<VideoItem>> {
|
||||
let mut requester = options.requester.clone().unwrap();
|
||||
|
||||
let url_str = format!("{}/all/?sort=created_at&page={}", self.url, page);
|
||||
|
||||
let old_items = match cache.get(&url_str) {
|
||||
Some((time, items)) => {
|
||||
if time.elapsed().unwrap_or_default().as_secs() < 60 * 60 {
|
||||
return Ok(items.clone());
|
||||
}
|
||||
else{
|
||||
items.clone()
|
||||
}
|
||||
}
|
||||
None => {
|
||||
vec![]
|
||||
}
|
||||
};
|
||||
|
||||
let text = requester.get(&url_str).await.unwrap();
|
||||
// Pass a reference to options if needed, or reconstruct as needed
|
||||
let video_items: Vec<VideoItem> = self.get_video_items_from_html(text.clone(), requester).await;
|
||||
if !video_items.is_empty() {
|
||||
cache.remove(&url_str);
|
||||
cache.insert(url_str.clone(), video_items.clone());
|
||||
} else{
|
||||
return Ok(old_items);
|
||||
}
|
||||
Ok(video_items)
|
||||
}
|
||||
|
||||
async fn query(&self, cache: VideoCache, page: u8, query: &str, options: ServerOptions) -> Result<Vec<VideoItem>> {
|
||||
// Extract needed fields from options at the start
|
||||
let mut requester = options.requester.clone().unwrap();
|
||||
let search_string = query.replace(" ", "+");
|
||||
let url_str = format!(
|
||||
"{}/search/?pattern={}&page={}",
|
||||
self.url, search_string, page
|
||||
);
|
||||
// Check our Video Cache. If the result is younger than 1 hour, we return it.
|
||||
let old_items = match cache.get(&url_str) {
|
||||
Some((time, items)) => {
|
||||
if time.elapsed().unwrap_or_default().as_secs() < 60 * 60 {
|
||||
return Ok(items.clone());
|
||||
}
|
||||
else{
|
||||
let _ = cache.check().await;
|
||||
return Ok(items.clone())
|
||||
}
|
||||
}
|
||||
None => {
|
||||
vec![]
|
||||
}
|
||||
};
|
||||
let text = requester.get(&url_str).await.unwrap();
|
||||
let video_items: Vec<VideoItem> = self.get_video_items_from_html(text.clone(), requester).await;
|
||||
if !video_items.is_empty() {
|
||||
cache.remove(&url_str);
|
||||
cache.insert(url_str.clone(), video_items.clone());
|
||||
} else{
|
||||
return Ok(old_items);
|
||||
}
|
||||
Ok(video_items)
|
||||
}
|
||||
|
||||
async fn get_video_items_from_html(&self, html: String, requester: Requester) -> Vec<VideoItem> {
|
||||
if html.is_empty() {
|
||||
println!("HTML is empty");
|
||||
return vec![];
|
||||
}
|
||||
let raw_videos = html
|
||||
.split("item list-film-item")
|
||||
.collect::<Vec<&str>>()[1..]
|
||||
.to_vec();
|
||||
let mut urls: Vec<String> = vec![];
|
||||
for video_segment in &raw_videos {
|
||||
// let vid = video_segment.split("\n").collect::<Vec<&str>>();
|
||||
// for (index, line) in vid.iter().enumerate() {
|
||||
// println!("Line {}: {}", index, line.to_string().trim());
|
||||
// }
|
||||
|
||||
let url_str = format!("{}{}",self.url, video_segment.split("<a href=\"").collect::<Vec<&str>>()[1]
|
||||
.split("\"")
|
||||
.collect::<Vec<&str>>()[0]
|
||||
.to_string());
|
||||
urls.push(url_str.clone());
|
||||
|
||||
}
|
||||
let futures = urls.into_iter().map(|el| self.get_video_item(el.clone(), requester.clone()));
|
||||
let results: Vec<Result<VideoItem>> = join_all(futures).await;
|
||||
let video_items: Vec<VideoItem> = results
|
||||
.into_iter()
|
||||
.filter_map(Result::ok)
|
||||
.collect();
|
||||
|
||||
return video_items;
|
||||
}
|
||||
|
||||
async fn get_video_item(&self, url_str: String, mut requester: Requester) -> Result<VideoItem> {
|
||||
let vid = requester.get(&url_str).await.unwrap();
|
||||
let mut title = vid.split("<meta property=\"og:title\" content=\"").collect::<Vec<&str>>()[1]
|
||||
.split("\"")
|
||||
.collect::<Vec<&str>>()[0].trim()
|
||||
.to_string();
|
||||
title = decode(title.as_bytes()).to_string().unwrap_or(title);
|
||||
let thumb = format!("{}{}",self.url, vid.split("<meta property=\"og:image\" content=\"").collect::<Vec<&str>>()[1]
|
||||
.split("\"")
|
||||
.collect::<Vec<&str>>()[0]
|
||||
.to_string());
|
||||
|
||||
|
||||
|
||||
let video_url = vid.split("var videoList = ").collect::<Vec<&str>>()[1]
|
||||
.split("\"src\":\"").collect::<Vec<&str>>()[1]
|
||||
.split("\"").collect::<Vec<&str>>()[0].replace("\\", "").to_string();
|
||||
let id = video_url.split("/").collect::<Vec<&str>>().last().unwrap().split("_").collect::<Vec<&str>>()[0]
|
||||
.to_string();
|
||||
let video_item = VideoItem::new(
|
||||
id,
|
||||
title,
|
||||
video_url.clone(),
|
||||
"paradisehill".to_string(),
|
||||
thumb,
|
||||
0,
|
||||
)
|
||||
.aspect_ratio(0.697674419 as f32)
|
||||
;
|
||||
|
||||
return Ok(video_item);
|
||||
}
|
||||
}
|
||||
|
||||
impl Provider for ParadisehillProvider {
|
||||
async fn get_videos(
|
||||
&self,
|
||||
cache: VideoCache,
|
||||
pool: DbPool,
|
||||
sort: String,
|
||||
query: Option<String>,
|
||||
page: String,
|
||||
per_page: String,
|
||||
options: ServerOptions,
|
||||
) -> Vec<VideoItem> {
|
||||
let _ = pool;
|
||||
let _ = sort;
|
||||
let _ = per_page;
|
||||
let videos: std::result::Result<Vec<VideoItem>, Error> = match query {
|
||||
Some(q) => self.query(cache, page.parse::<u8>().unwrap_or(1), &q, options).await,
|
||||
None => self.get(cache, page.parse::<u8>().unwrap_or(1), options).await,
|
||||
};
|
||||
match videos {
|
||||
Ok(v) => v,
|
||||
Err(e) => {
|
||||
println!("Error fetching videos: {}", e);
|
||||
vec![]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user