supjav and shooshtime fixes
This commit is contained in:
@@ -13,7 +13,6 @@ use crate::videos::{ServerOptions, VideoFormat, VideoItem};
|
||||
use async_trait::async_trait;
|
||||
use chrono::NaiveDate;
|
||||
use error_chain::error_chain;
|
||||
use futures::stream::{self, StreamExt};
|
||||
use htmlentity::entity::{ICodedDataTrait, decode};
|
||||
use regex::Regex;
|
||||
use scraper::{ElementRef, Html, Selector};
|
||||
@@ -644,7 +643,7 @@ impl ShooshtimeProvider {
|
||||
target.push_str(&quality.replace(' ', "%20"));
|
||||
}
|
||||
|
||||
build_proxy_url(options, "shooshtime", &target)
|
||||
build_proxy_url(options, "shooshtime-media", &target)
|
||||
}
|
||||
|
||||
fn search_sort_param(sort: &str) -> Option<&'static str> {
|
||||
@@ -1157,7 +1156,11 @@ impl ShooshtimeProvider {
|
||||
}
|
||||
let proxied_url = self.proxied_video(options, page_url, None);
|
||||
if !proxied_url.is_empty() {
|
||||
item.url = proxied_url;
|
||||
item.url = page_url.to_string();
|
||||
formats.push(
|
||||
VideoFormat::new(proxied_url, "Best".to_string(), "mp4".to_string())
|
||||
.format_id("best".to_string()),
|
||||
);
|
||||
}
|
||||
if !formats.is_empty() {
|
||||
item = item.formats(formats);
|
||||
@@ -1194,40 +1197,6 @@ impl ShooshtimeProvider {
|
||||
Ok(item)
|
||||
}
|
||||
|
||||
async fn enrich_video(&self, item: VideoItem, options: &ServerOptions) -> VideoItem {
|
||||
let page_url = item.url.clone();
|
||||
let original_item = item.clone();
|
||||
|
||||
let mut requester = match options.requester.clone() {
|
||||
Some(requester) => requester,
|
||||
None => Requester::new(),
|
||||
};
|
||||
|
||||
let html = match requester.get(&page_url, None).await {
|
||||
Ok(html) => html,
|
||||
Err(error) => {
|
||||
report_provider_error_background(
|
||||
"shooshtime",
|
||||
"enrich_video.request",
|
||||
&format!("url={}; error={error}", page_url),
|
||||
);
|
||||
return item;
|
||||
}
|
||||
};
|
||||
|
||||
match self.apply_detail_video(item, &html, &page_url, options) {
|
||||
Ok(item) => item,
|
||||
Err(error) => {
|
||||
report_provider_error_background(
|
||||
"shooshtime",
|
||||
"enrich_video.parse",
|
||||
&format!("url={}; error={error}", page_url),
|
||||
);
|
||||
original_item
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn fetch_items_for_url(
|
||||
&self,
|
||||
cache: VideoCache,
|
||||
@@ -1256,23 +1225,12 @@ impl ShooshtimeProvider {
|
||||
}
|
||||
};
|
||||
|
||||
let list_videos = self.parse_list_videos(&html)?;
|
||||
if list_videos.is_empty() {
|
||||
let items = self.parse_list_videos(&html)?;
|
||||
if items.is_empty() {
|
||||
return Ok(vec![]);
|
||||
}
|
||||
|
||||
let items = stream::iter(list_videos.into_iter().map(|video| {
|
||||
let provider = self.clone();
|
||||
let options = options.clone();
|
||||
async move { provider.enrich_video(video, &options).await }
|
||||
}))
|
||||
.buffer_unordered(6)
|
||||
.collect::<Vec<_>>()
|
||||
.await;
|
||||
|
||||
if !items.is_empty() {
|
||||
cache.insert(url, items.clone());
|
||||
}
|
||||
cache.insert(url, items.clone());
|
||||
|
||||
Ok(items)
|
||||
}
|
||||
@@ -1422,7 +1380,7 @@ mod tests {
|
||||
|
||||
assert_eq!(
|
||||
provider.proxied_video(&options, "https://shooshtime.com/videos/example/123/", None,),
|
||||
"https://example.com/proxy/shooshtime/shooshtime.com/videos/example/123/"
|
||||
"https://example.com/proxy/shooshtime-media/shooshtime.com/videos/example/123/"
|
||||
);
|
||||
assert_eq!(
|
||||
provider.proxied_video(
|
||||
@@ -1430,7 +1388,7 @@ mod tests {
|
||||
"https://shooshtime.com/videos/example/123/",
|
||||
Some("720p"),
|
||||
),
|
||||
"https://example.com/proxy/shooshtime/shooshtime.com/videos/example/123/__quality__/720p"
|
||||
"https://example.com/proxy/shooshtime-media/shooshtime.com/videos/example/123/__quality__/720p"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user