thumb updates

This commit is contained in:
Simon
2026-03-17 09:44:38 +00:00
parent 7680a93fab
commit 3c3af70ed6
2 changed files with 101 additions and 4 deletions

View File

@@ -981,8 +981,10 @@ sys.stdout.buffer.write(response.content)
item.title = title;
}
if let Some(thumb) = parsed_thumb {
item.thumb = self.proxied_thumb(options, &thumb);
if item.thumb.is_empty() {
if let Some(thumb) = parsed_thumb {
item.thumb = self.proxied_thumb(options, &thumb);
}
}
if let Some(uploader) = parsed_uploader {
@@ -1306,6 +1308,8 @@ impl PorndishThumbPolicy {
#[cfg(test)]
mod tests {
use super::PorndishProvider;
use crate::util::requester::Requester;
use crate::videos::{ServerOptions, VideoItem};
#[test]
fn builds_archive_and_search_urls() {
@@ -1419,4 +1423,59 @@ mod tests {
"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"
);
}
}

View File

@@ -1141,8 +1141,10 @@ impl ShooshtimeProvider {
item = item.preview(preview.clone());
}
}
if let Some(thumb) = preview_url {
item.thumb = thumb;
if item.thumb.is_empty() {
if let Some(thumb) = preview_url {
item.thumb = thumb;
}
}
if let Some(source) = embed_url {
item = item.embed(VideoEmbed {
@@ -1308,3 +1310,39 @@ impl Provider for ShooshtimeProvider {
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")
);
}
}