This commit is contained in:
Simon
2025-11-29 14:20:36 +00:00
parent 0e02a1b821
commit d7e7f70bd2

View File

@@ -206,7 +206,6 @@ impl HqpornerProvider {
if let Some(cat) = self.categories.read().unwrap().iter().find(|c| c.title.to_ascii_lowercase() == search_string.to_ascii_lowercase()) { if let Some(cat) = self.categories.read().unwrap().iter().find(|c| c.title.to_ascii_lowercase() == search_string.to_ascii_lowercase()) {
video_url = format!("{}/category/{}/{}", self.url, cat.id, page); video_url = format!("{}/category/{}/{}", self.url, cat.id, page);
} }
println!("Searching URL: {}", video_url);
// 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(&video_url) { let old_items = match cache.get(&video_url) {
Some((time, items)) => { Some((time, items)) => {
@@ -310,7 +309,10 @@ impl HqpornerProvider {
.to_string(); .to_string();
let duration = parse_time_to_seconds(raw_duration.as_str()).unwrap_or(0) as u32; let duration = parse_time_to_seconds(raw_duration.as_str()).unwrap_or(0) as u32;
let (tags, formats) = self.extract_media(&video_url, &mut requester).await; let (tags, formats) = match self.extract_media(&video_url, &mut requester).await{
Ok((t, f)) => (t, f),
Err(_) => return Err(Error::from("Video media extraction failed")),
};
if formats.is_empty() { if formats.is_empty() {
return Err(Error::from("No formats found for video")); return Err(Error::from("No formats found for video"));
} }
@@ -331,12 +333,13 @@ impl HqpornerProvider {
&self, &self,
video_page_url: &str, video_page_url: &str,
requester: &mut Requester, requester: &mut Requester,
) -> (Vec<String>, Vec<VideoFormat>) { ) -> Result<(Vec<String>, Vec<VideoFormat>)> {
let mut formats = vec![]; let mut formats = vec![];
let mut tags = vec![]; let mut tags = vec![];
let text = requester.get(&video_page_url).await.unwrap(); let text = requester.get_raw_with_headers(&video_page_url, vec![("Referer".to_string(), "https://hqporner.com".to_string())])
.await.unwrap().text().await.unwrap();
if text.contains("Why do I see it?") { if text.contains("Why do I see it?") {
return (tags, formats); return Ok((tags, formats));
} }
let stars_elements = text.split("icon fa-star-o").collect::<Vec<&str>>()[1] let stars_elements = text.split("icon fa-star-o").collect::<Vec<&str>>()[1]
.split("</li>") .split("</li>")
@@ -392,6 +395,10 @@ impl HqpornerProvider {
.text() .text()
.await .await
.unwrap(); .unwrap();
match text2.split("<video ").collect::<Vec<&str>>().len() > 2 {
false => return Err(Error::from("No video element found")),
true => (),
}
let video_element = text2.split("<video ").collect::<Vec<&str>>()[2] let video_element = text2.split("<video ").collect::<Vec<&str>>()[2]
.split("</video>") .split("</video>")
.collect::<Vec<&str>>()[0]; .collect::<Vec<&str>>()[0];
@@ -416,7 +423,7 @@ impl HqpornerProvider {
.format_note(title.clone()), .format_note(title.clone()),
); );
} }
(tags, formats) Ok((tags, formats))
} }
} }