fix(downloader): terabox proxy as primary link + accept threads.net URLs
Deploy Scraper / build-and-deploy (push) Canceled after 0s

- Terabox: return the working cookie-authenticated proxy URL as the
  FIRST media entry; keep the raw dlink second with an honest note
  (it 403s without cookies).
- Threads: accept threads.net URLs in the snapsave/IG validator so
  /download/threads no longer rejects them.
This commit is contained in:
asepharyana
2026-09-07 13:40:32 +07:00
parent 8b9bdeb56a
commit 7d68ff5620
+17 -18
View File
@@ -872,6 +872,7 @@ pub(crate) async fn fetch_snapsave(url: &str) -> Result<DownloadResult, Scraping
.unwrap() .unwrap()
.is_match(url); .is_match(url);
let valid_ig = url.contains("instagram.com") let valid_ig = url.contains("instagram.com")
|| url.contains("threads.net")
|| regex::Regex::new(r"https?://(www\.)?instagram\.com/[^\s]+") || regex::Regex::new(r"https?://(www\.)?instagram\.com/[^\s]+")
.unwrap() .unwrap()
.is_match(url); .is_match(url);
@@ -3478,20 +3479,9 @@ pub async fn fetch_terabox(url: &str) -> Result<DownloadResult, ScrapingError> {
if let Some(download_url) = data.get("download_link").and_then(|v| v.as_str()) { if let Some(download_url) = data.get("download_link").and_then(|v| v.as_str()) {
let size_bytes = data.get("file_size").and_then(|v| v.as_u64()).unwrap_or(0); let size_bytes = data.get("file_size").and_then(|v| v.as_u64()).unwrap_or(0);
result.media.push(MediaItem { // PRIMARY = the cookie-authenticated public proxy. The raw terabox
url: download_url.to_string(), // dlink is only a secondary entry — it 403s without cookies, so it
quality: None, // must NOT be the first link users see.
file_type: Some(MediaType::File),
extension: None,
thumbnail: None,
file_size: Some(format_filesize(size_bytes)),
size_bytes: Some(size_bytes),
frame_width: None,
frame_height: None,
note: None,
});
// A second entry pointing to the cookie-authenticated proxy — this one
// is what actually downloads when the user clicks it.
result.media.push(MediaItem { result.media.push(MediaItem {
url: proxy_dl.clone(), url: proxy_dl.clone(),
quality: None, quality: None,
@@ -3502,10 +3492,19 @@ pub async fn fetch_terabox(url: &str) -> Result<DownloadResult, ScrapingError> {
size_bytes: Some(size_bytes), size_bytes: Some(size_bytes),
frame_width: None, frame_width: None,
frame_height: None, frame_height: None,
note: Some( note: Some("Direct download via cookie-authenticated proxy (works).".into()),
"Direct download via cookie-authenticated proxy (works without TeraBox cookies)" });
.into(), result.media.push(MediaItem {
), url: download_url.to_string(),
quality: None,
file_type: Some(MediaType::File),
extension: None,
thumbnail: None,
file_size: Some(format_filesize(size_bytes)),
size_bytes: Some(size_bytes),
frame_width: None,
frame_height: None,
note: Some("Raw CDN link (may require a TeraBox session cookie).".into()),
}); });
// Directory: add child file links // Directory: add child file links