no embed in video element

This commit is contained in:
Simon
2026-03-19 19:04:49 +00:00
parent 2b26019a66
commit 99e4a77507

View File

@@ -8,7 +8,7 @@ use crate::util::cache::VideoCache;
use crate::util::parse_abbreviated_number; use crate::util::parse_abbreviated_number;
use crate::util::requester::Requester; use crate::util::requester::Requester;
use crate::util::time::parse_time_to_seconds; use crate::util::time::parse_time_to_seconds;
use crate::videos::{ServerOptions, VideoEmbed, VideoFormat, VideoItem}; use crate::videos::{ServerOptions, VideoFormat, VideoItem};
use async_trait::async_trait; use async_trait::async_trait;
use chrono::{DateTime, Utc}; use chrono::{DateTime, Utc};
use error_chain::error_chain; use error_chain::error_chain;
@@ -959,16 +959,6 @@ impl VrpornProvider {
} }
} }
if let Some(embed_url) = json_ld.get("embedUrl").and_then(Value::as_str) {
item.embed = Some(VideoEmbed {
html: format!(
"<iframe src=\"{}\" frameborder=\"0\" allowfullscreen></iframe>",
self.normalize_url(embed_url)
),
source: self.normalize_url(embed_url),
});
}
if let Some(content_url) = json_ld.get("contentUrl").and_then(Value::as_str) { if let Some(content_url) = json_ld.get("contentUrl").and_then(Value::as_str) {
let mut format = VideoFormat::new( let mut format = VideoFormat::new(
content_url.to_string(), content_url.to_string(),
@@ -1220,4 +1210,40 @@ mod tests {
assert!(formats[0].url.contains("free_4k.mp4")); assert!(formats[0].url.contains("free_4k.mp4"));
assert!(formats[1].url.contains("free_6k.mp4")); assert!(formats[1].url.contains("free_6k.mp4"));
} }
#[test]
fn detail_parser_ignores_embed_url() {
let provider = provider();
let item = VideoItem::new(
"test".to_string(),
"Original".to_string(),
"https://vrporn.com/videos/test/".to_string(),
CHANNEL_ID.to_string(),
String::new(),
0,
);
let parsed = provider
.apply_detail_video(
item,
r#"
<html>
<head>
<script type="application/ld+json">
{
"@type": "VideoObject",
"name": "Updated Title",
"embedUrl": "https://vrporn.com/embed/test/",
"contentUrl": "https://cdns.vrporn.com/videos/test/free_4k.mp4?ttl=1&token=1"
}
</script>
</head>
<body></body>
</html>
"#,
)
.expect("detail HTML should parse");
assert_eq!(parsed.title, "Updated Title");
assert!(parsed.embed.is_none());
}
} }