vidara proxy for sxyprn

This commit is contained in:
Simon
2026-05-05 08:58:26 +00:00
committed by ForgeCode
parent 60d29ca905
commit 8ae0fcb544
8 changed files with 212 additions and 178 deletions

View File

@@ -8,6 +8,7 @@ use crate::util::discord::send_discord_error_report;
use crate::util::requester::Requester;
use crate::util::time::parse_time_to_seconds;
use crate::videos::ServerOptions;
use crate::videos::VideoFormat;
use crate::videos::VideoItem;
use async_trait::async_trait;
use error_chain::error_chain;
@@ -353,6 +354,7 @@ impl SxyprnProvider {
.replace('\n', "")
.replace(" + ", " ")
.replace(" ", " ")
.replace("\\", "")
.trim()
.to_string();
@@ -360,6 +362,29 @@ impl SxyprnProvider {
title = title[4..].to_string();
}
// Extract tags from title (words starting with #)
let mut tags = Vec::new();
let words: Vec<&str> = title.split_whitespace().collect();
let mut cleaned_words = Vec::new();
for word in words {
let raw_tag = word
.trim_end_matches(|c: char| !c.is_alphanumeric() && c != '_' && c != '-')
.to_string();
if raw_tag.starts_with('#') && raw_tag.len() > 1 {
let tag = raw_tag[1..].to_string();
if !tags.contains(&tag) {
tags.push(tag);
}
} else {
cleaned_words.push(word.to_string());
}
}
// Reconstruct title without tags
title = cleaned_words.join(" ");
// id (DON'T index [6])
let id = video_url
.split('/')
@@ -416,8 +441,15 @@ impl SxyprnProvider {
let duration = parse_time_to_seconds(&raw_duration).unwrap_or(0) as u32;
// stream urls (your filter condition looks suspicious; leaving as-is)
let stream_urls = video_segment
// stream urls - collect both lulustream and vidara.so URLs
let mut stream_urls = vec![format!(
"{}/proxy/sxyprn/post/{}",
options.public_url_base.as_deref().unwrap_or(""),
id
)];
// Also collect and transform vidara.so URLs to proxy format
let vidara_urls: Vec<String> = video_segment
.split("extlink_icon extlink")
.filter_map(|part| {
part.split("href='")
@@ -425,27 +457,52 @@ impl SxyprnProvider {
.and_then(|s| s.split('\'').next())
.map(|u| u.to_string())
})
.filter(|url| url.starts_with("https://lulustream."))
.collect::<Vec<String>>();
.filter(|url| url.contains("vidara.so/v/"))
.filter_map(|url| {
url.split("/v/").last().map(|video_id| {
format!(
"{}/proxy/vidara/e/{}",
options.public_url_base.as_deref().unwrap_or(""),
video_id
)
})
})
.collect();
let video_item_url = stream_urls.first().cloned().unwrap_or_else(|| {
crate::providers::build_proxy_url(options, "sxyprn", &format!("post/{}", id))
});
stream_urls.extend(vidara_urls);
let formats: Vec<VideoFormat> = stream_urls
.into_iter()
.map(|url| {
VideoFormat::new(url.clone(), "auto".to_string(), "mp4".to_string())
.format_note(
url.split("/")
.nth(4)
.or_else(|| Some(&url))
.unwrap_or_default()
.to_string(),
)
})
.collect::<Vec<VideoFormat>>();
let mut video_item = VideoItem::new(
id,
id.clone(),
title,
video_item_url,
format!("{}/post/{}", self.url, id.clone()),
"sxyprn".to_string(),
thumb,
duration,
)
.views(views.parse::<u32>().unwrap_or(0));
.views(views.parse::<u32>().unwrap_or(0))
.formats(formats);
if let Some(p) = preview {
video_item = video_item.preview(p);
// Add tags if any were found
if !tags.is_empty() {
video_item.tags = Some(tags);
}
if preview.is_some() {
video_item.preview = preview;
}
items.push(video_item);
}