bug hotfix
This commit is contained in:
@@ -106,7 +106,6 @@ impl SpankbangProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn query(&self, cache: VideoCache, page: u8, query: &str,) -> Result<Vec<VideoItem>> {
|
async fn query(&self, cache: VideoCache, page: u8, query: &str,) -> Result<Vec<VideoItem>> {
|
||||||
println!("query");
|
|
||||||
let url = format!("{}s/{}/{}/", self.url, query.replace(" ", "+"), page);
|
let url = format!("{}s/{}/{}/", self.url, query.replace(" ", "+"), page);
|
||||||
|
|
||||||
let old_items = match cache.get(&url) {
|
let old_items = match cache.get(&url) {
|
||||||
@@ -192,13 +191,16 @@ impl SpankbangProvider {
|
|||||||
.to_vec();
|
.to_vec();
|
||||||
for video_segment in &raw_videos {
|
for video_segment in &raw_videos {
|
||||||
let vid = video_segment.split("\n").collect::<Vec<&str>>();
|
let vid = video_segment.split("\n").collect::<Vec<&str>>();
|
||||||
//for (index,line) in vid.iter().enumerate(){
|
for (index,line) in vid.iter().enumerate(){
|
||||||
// println!("Line {}: {}\n\n", index, line);
|
println!("Line {}: {}\n\n", index, line);
|
||||||
//}
|
}
|
||||||
let mut title = vid[4].split("title=\"").collect::<Vec<&str>>()[1].split("\"").collect::<Vec<&str>>()[0].to_string();
|
let mut title = vid[4].split("title=\"").collect::<Vec<&str>>()[1].split("\"").collect::<Vec<&str>>()[0].to_string();
|
||||||
title = decode(title.as_bytes()).to_string().unwrap_or(title);
|
title = decode(title.as_bytes()).to_string().unwrap_or(title);
|
||||||
let thumb = vid[14].split("data-src=\"").collect::<Vec<&str>>()[1].split("\"").collect::<Vec<&str>>()[0].to_string();
|
let thumb = vid[14].split("data-src=\"").collect::<Vec<&str>>()[1].split("\"").collect::<Vec<&str>>()[0].to_string();
|
||||||
let preview = vid[16].split("data-preview=\"").collect::<Vec<&str>>()[1].split("\"").collect::<Vec<&str>>()[0].to_string();
|
let mut preview = "".to_string();
|
||||||
|
if vid[16].contains("data-preview=\""){
|
||||||
|
preview = vid[16].split("data-preview=\"").collect::<Vec<&str>>()[1].split("\"").collect::<Vec<&str>>()[0].to_string();
|
||||||
|
}
|
||||||
let duration_str = vid.iter().find(|s| s.contains("<span class=\"video-badge l\">")).unwrap().split("<span class=\"video-badge l\">").collect::<Vec<&str>>()[1].split("m<").collect::<Vec<&str>>()[0];
|
let duration_str = vid.iter().find(|s| s.contains("<span class=\"video-badge l\">")).unwrap().split("<span class=\"video-badge l\">").collect::<Vec<&str>>()[1].split("m<").collect::<Vec<&str>>()[0];
|
||||||
let duration: u32 = duration_str.parse::<u32>().unwrap_or(0) * 60;
|
let duration: u32 = duration_str.parse::<u32>().unwrap_or(0) * 60;
|
||||||
let view_and_rating_str: Vec<&str> = vid.iter().copied().filter(|s| s.contains("<span class=\"md:text-body-md\">")).collect();
|
let view_and_rating_str: Vec<&str> = vid.iter().copied().filter(|s| s.contains("<span class=\"md:text-body-md\">")).collect();
|
||||||
@@ -242,7 +244,7 @@ impl Provider for SpankbangProvider {
|
|||||||
cache: VideoCache,
|
cache: VideoCache,
|
||||||
pool: DbPool,
|
pool: DbPool,
|
||||||
_channel: String,
|
_channel: String,
|
||||||
sort: String,
|
mut sort: String,
|
||||||
query: Option<String>,
|
query: Option<String>,
|
||||||
page: String,
|
page: String,
|
||||||
per_page: String,
|
per_page: String,
|
||||||
@@ -251,6 +253,10 @@ impl Provider for SpankbangProvider {
|
|||||||
let _ = per_page;
|
let _ = per_page;
|
||||||
let _ = featured;
|
let _ = featured;
|
||||||
let _ = pool;
|
let _ = pool;
|
||||||
|
|
||||||
|
if sort == "date"{
|
||||||
|
sort = "trending_videos".to_string();
|
||||||
|
}
|
||||||
let videos: std::result::Result<Vec<VideoItem>, Error> = match query {
|
let videos: std::result::Result<Vec<VideoItem>, Error> = match query {
|
||||||
Some(q) => self.query(cache, page.parse::<u8>().unwrap_or(1), &q).await,
|
Some(q) => self.query(cache, page.parse::<u8>().unwrap_or(1), &q).await,
|
||||||
None => self.get(cache, page.parse::<u8>().unwrap_or(1), sort).await,
|
None => self.get(cache, page.parse::<u8>().unwrap_or(1), sort).await,
|
||||||
|
|||||||
Reference in New Issue
Block a user