thumb updates
This commit is contained in:
@@ -981,8 +981,10 @@ sys.stdout.buffer.write(response.content)
|
|||||||
item.title = title;
|
item.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(thumb) = parsed_thumb {
|
if item.thumb.is_empty() {
|
||||||
item.thumb = self.proxied_thumb(options, &thumb);
|
if let Some(thumb) = parsed_thumb {
|
||||||
|
item.thumb = self.proxied_thumb(options, &thumb);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(uploader) = parsed_uploader {
|
if let Some(uploader) = parsed_uploader {
|
||||||
@@ -1306,6 +1308,8 @@ impl PorndishThumbPolicy {
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::PorndishProvider;
|
use super::PorndishProvider;
|
||||||
|
use crate::util::requester::Requester;
|
||||||
|
use crate::videos::{ServerOptions, VideoItem};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn builds_archive_and_search_urls() {
|
fn builds_archive_and_search_urls() {
|
||||||
@@ -1419,4 +1423,59 @@ mod tests {
|
|||||||
"https://example.com/e/abc123"
|
"https://example.com/e/abc123"
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn preserves_list_thumb_when_detail_has_og_image() {
|
||||||
|
let provider = PorndishProvider::new();
|
||||||
|
let mut requester = Requester::new();
|
||||||
|
let options = ServerOptions {
|
||||||
|
featured: None,
|
||||||
|
category: None,
|
||||||
|
sites: None,
|
||||||
|
filter: None,
|
||||||
|
language: None,
|
||||||
|
public_url_base: None,
|
||||||
|
requester: None,
|
||||||
|
network: None,
|
||||||
|
stars: None,
|
||||||
|
categories: None,
|
||||||
|
duration: None,
|
||||||
|
sort: None,
|
||||||
|
sexuality: None,
|
||||||
|
};
|
||||||
|
let item = VideoItem::new(
|
||||||
|
"foo".to_string(),
|
||||||
|
"Example".to_string(),
|
||||||
|
"https://www.porndish.com/porn/foo/".to_string(),
|
||||||
|
"porndish".to_string(),
|
||||||
|
"https://www.porndish.com/wp-content/uploads/list-thumb.jpg".to_string(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
let html = r#"
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta property="og:image" content="https://www.porndish.com/wp-content/uploads/detail-thumb.jpg" />
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1 class="entry-title">Example</h1>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let enriched = provider
|
||||||
|
.apply_detail_video(
|
||||||
|
item,
|
||||||
|
html,
|
||||||
|
"https://www.porndish.com/porn/foo/",
|
||||||
|
&options,
|
||||||
|
&mut requester,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(
|
||||||
|
enriched.thumb,
|
||||||
|
"https://www.porndish.com/wp-content/uploads/list-thumb.jpg"
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1141,8 +1141,10 @@ impl ShooshtimeProvider {
|
|||||||
item = item.preview(preview.clone());
|
item = item.preview(preview.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Some(thumb) = preview_url {
|
if item.thumb.is_empty() {
|
||||||
item.thumb = thumb;
|
if let Some(thumb) = preview_url {
|
||||||
|
item.thumb = thumb;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if let Some(source) = embed_url {
|
if let Some(source) = embed_url {
|
||||||
item = item.embed(VideoEmbed {
|
item = item.embed(VideoEmbed {
|
||||||
@@ -1308,3 +1310,39 @@ impl Provider for ShooshtimeProvider {
|
|||||||
Some(self.build_channel(clientversion))
|
Some(self.build_channel(clientversion))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::ShooshtimeProvider;
|
||||||
|
use crate::videos::VideoItem;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn preserves_list_thumb_when_detail_has_preview_url() {
|
||||||
|
let provider = ShooshtimeProvider::new();
|
||||||
|
let item = VideoItem::new(
|
||||||
|
"123".to_string(),
|
||||||
|
"Example".to_string(),
|
||||||
|
"https://shooshtime.com/videos/example/123/".to_string(),
|
||||||
|
"shooshtime".to_string(),
|
||||||
|
"https://shooshtime.com/list-thumb.jpg".to_string(),
|
||||||
|
0,
|
||||||
|
);
|
||||||
|
let html = r#"
|
||||||
|
<script>
|
||||||
|
var flashvars = {
|
||||||
|
preview_url: 'https://shooshtime.com/detail-thumb.jpg'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let enriched = provider
|
||||||
|
.apply_detail_video(item, html, "https://shooshtime.com/videos/example/123/")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
assert_eq!(enriched.thumb, "https://shooshtime.com/list-thumb.jpg");
|
||||||
|
assert_eq!(
|
||||||
|
enriched.preview.as_deref(),
|
||||||
|
Some("https://shooshtime.com/detail-thumb.jpg")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user