bugfixes
This commit is contained in:
@@ -5,11 +5,9 @@ use crate::status::*;
|
||||
use crate::util::cache::VideoCache;
|
||||
use crate::util::requester::Requester;
|
||||
use crate::videos::VideoItem;
|
||||
use crate::videos::{self, ServerOptions};
|
||||
use crate::videos::ServerOptions;
|
||||
use error_chain::error_chain;
|
||||
use futures::future::join_all;
|
||||
use htmlentity::entity::{ICodedDataTrait, decode};
|
||||
use std::vec;
|
||||
use async_trait::async_trait;
|
||||
|
||||
error_chain! {
|
||||
@@ -214,77 +212,6 @@ impl ParadisehillProvider {
|
||||
items
|
||||
}
|
||||
|
||||
async fn get_video_item(&self, url_str: String, mut requester: Requester) -> Result<VideoItem> {
|
||||
let vid = match requester.get(&url_str, None).await {
|
||||
Ok(vid) => vid,
|
||||
Err(e) => {
|
||||
crate::providers::report_provider_error(
|
||||
"paradisehill",
|
||||
"get_video_item.request",
|
||||
&format!("url={url_str}; error={e}"),
|
||||
)
|
||||
.await;
|
||||
return Err(Error::from(e.to_string()));
|
||||
}
|
||||
};
|
||||
let mut title = vid
|
||||
.split("<meta property=\"og:title\" content=\"")
|
||||
.collect::<Vec<&str>>().get(1).copied().unwrap_or_default()
|
||||
.split("\"")
|
||||
.collect::<Vec<&str>>().get(0).copied().unwrap_or_default()
|
||||
.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>>().get(1).copied().unwrap_or_default()
|
||||
.split("\"")
|
||||
.collect::<Vec<&str>>().get(0).copied().unwrap_or_default()
|
||||
.to_string()
|
||||
);
|
||||
|
||||
let video_urls = vid.split("var videoList = ").collect::<Vec<&str>>().get(1).copied().unwrap_or_default()
|
||||
.split("\"src\":\"")
|
||||
.collect::<Vec<&str>>()[1..].to_vec();
|
||||
let mut formats = vec![];
|
||||
for url in video_urls {
|
||||
let video_url = url
|
||||
.split("\"")
|
||||
.collect::<Vec<&str>>().get(0).copied().unwrap_or_default()
|
||||
.replace("\\", "")
|
||||
.to_string();
|
||||
let format =
|
||||
videos::VideoFormat::new(video_url.clone(), "1080".to_string(), "mp4".to_string())
|
||||
// .protocol("https".to_string())
|
||||
.format_id(video_url.split("/").last().unwrap_or_default().to_string())
|
||||
.format_note(video_url.split("_").last().unwrap_or_default().replace(".mp4", ""))
|
||||
;
|
||||
formats.push(format);
|
||||
}
|
||||
|
||||
formats.reverse();
|
||||
let id = url_str
|
||||
.split("/")
|
||||
.collect::<Vec<&str>>().get(3).copied().unwrap_or_default()
|
||||
.split("_")
|
||||
.collect::<Vec<&str>>().get(0).copied().unwrap_or_default()
|
||||
.to_string();
|
||||
|
||||
let video_item = VideoItem::new(
|
||||
id,
|
||||
title,
|
||||
url_str.clone(),
|
||||
"paradisehill".to_string(),
|
||||
thumb,
|
||||
0,
|
||||
)
|
||||
.aspect_ratio(0.697674419 as f32)
|
||||
.formats(formats);
|
||||
|
||||
return Ok(video_item);
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
||||
Reference in New Issue
Block a user