fixes and cleanup
This commit is contained in:
@@ -11,7 +11,7 @@ use crate::videos::{ServerOptions, VideoFormat, VideoItem};
|
||||
use async_trait::async_trait;
|
||||
use error_chain::error_chain;
|
||||
use futures::future::join_all;
|
||||
use htmlentity::entity::{decode, ICodedDataTrait};
|
||||
use htmlentity::entity::{ICodedDataTrait, decode};
|
||||
use std::sync::{Arc, RwLock};
|
||||
use std::{thread, vec};
|
||||
use titlecase::Titlecase;
|
||||
@@ -122,7 +122,8 @@ impl PimpbunnyProvider {
|
||||
file!(),
|
||||
line!(),
|
||||
module_path!(),
|
||||
).await;
|
||||
)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
@@ -138,7 +139,8 @@ impl PimpbunnyProvider {
|
||||
file!(),
|
||||
line!(),
|
||||
module_path!(),
|
||||
).await;
|
||||
)
|
||||
.await;
|
||||
}
|
||||
if let Err(e) = Self::load_categories(&url, Arc::clone(&categories)).await {
|
||||
eprintln!("load_categories failed: {e}");
|
||||
@@ -150,7 +152,8 @@ impl PimpbunnyProvider {
|
||||
file!(),
|
||||
line!(),
|
||||
module_path!(),
|
||||
).await;
|
||||
)
|
||||
.await;
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -183,7 +186,9 @@ impl PimpbunnyProvider {
|
||||
.unwrap_or("");
|
||||
|
||||
for el in block.split("<div class=\"col\">").skip(1) {
|
||||
if el.contains("pb-promoted-link") || !el.contains("href=\"https://pimpbunny.com/onlyfans-models/") {
|
||||
if el.contains("pb-promoted-link")
|
||||
|| !el.contains("href=\"https://pimpbunny.com/onlyfans-models/")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -309,7 +314,9 @@ impl PimpbunnyProvider {
|
||||
|
||||
let mut video_url = format!(
|
||||
"{}/search/{}/?mode=async&function=get_block&block_id=list_videos_videos_list_search_result&videos_per_page=32&from_videos={}",
|
||||
self.url, search_string.replace(" ","-"), page
|
||||
self.url,
|
||||
search_string.replace(" ", "-"),
|
||||
page
|
||||
);
|
||||
|
||||
let sort_string = match options.sort.as_deref().unwrap_or("") {
|
||||
@@ -423,11 +430,7 @@ impl PimpbunnyProvider {
|
||||
.collect()
|
||||
}
|
||||
|
||||
async fn get_video_item(
|
||||
&self,
|
||||
seg: String,
|
||||
mut requester: Requester,
|
||||
) -> Result<VideoItem> {
|
||||
async fn get_video_item(&self, seg: String, mut requester: Requester) -> Result<VideoItem> {
|
||||
let video_url = seg
|
||||
.split(" href=\"")
|
||||
.nth(1)
|
||||
@@ -443,7 +446,10 @@ impl PimpbunnyProvider {
|
||||
.ok_or_else(|| ErrorKind::Parse("video title".into()))?
|
||||
.trim()
|
||||
.to_string();
|
||||
title = decode(title.as_bytes()).to_string().unwrap_or(title).titlecase();
|
||||
title = decode(title.as_bytes())
|
||||
.to_string()
|
||||
.unwrap_or(title)
|
||||
.titlecase();
|
||||
|
||||
let id = video_url
|
||||
.split('/')
|
||||
@@ -483,18 +489,13 @@ impl PimpbunnyProvider {
|
||||
let (tags, formats, views, duration) =
|
||||
self.extract_media(&video_url, &mut requester).await?;
|
||||
|
||||
Ok(VideoItem::new(
|
||||
id,
|
||||
title,
|
||||
video_url,
|
||||
"pimpbunny".into(),
|
||||
thumb,
|
||||
duration,
|
||||
Ok(
|
||||
VideoItem::new(id, title, video_url, "pimpbunny".into(), thumb, duration)
|
||||
.formats(formats)
|
||||
.tags(tags)
|
||||
.preview(preview)
|
||||
.views(views),
|
||||
)
|
||||
.formats(formats)
|
||||
.tags(tags)
|
||||
.preview(preview)
|
||||
.views(views))
|
||||
}
|
||||
|
||||
async fn extract_media(
|
||||
@@ -532,7 +533,7 @@ impl PimpbunnyProvider {
|
||||
|
||||
let duration = json["duration"]
|
||||
.as_str()
|
||||
.map(|d| parse_time_to_seconds(&d.replace(['P','T','H','M','S'], "")).unwrap_or(0))
|
||||
.map(|d| parse_time_to_seconds(&d.replace(['P', 'T', 'H', 'M', 'S'], "")).unwrap_or(0))
|
||||
.unwrap_or(0) as u32;
|
||||
|
||||
Ok((
|
||||
|
||||
Reference in New Issue
Block a user