archivebate: keep the proxied format when enrichment times out; skip dead search candidates

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MUYdCh2nCVsQYgJAT7gwSi
This commit is contained in:
Simon
2026-10-17 19:54:49 +00:00
parent edf6732f8e
commit a4364e5be3

View File

@@ -799,6 +799,22 @@ impl ArchivebateProvider {
.map(|value| value.to_string()) .map(|value| value.to_string())
} }
/// The proxied format needs no network, so an item always plays through
/// it even when the best-effort header enrichment below times out.
fn with_default_format(item: VideoItem, options: &ServerOptions) -> VideoItem {
let format_url = Self::proxied_video(options, &item.url);
if format_url.is_empty() || item.formats.is_some() {
return item;
}
let mut item = item;
item.formats = Some(vec![VideoFormat::new(
format_url,
"source".to_string(),
"mp4".to_string(),
)]);
item
}
async fn enrich_video(&self, item: VideoItem, options: &ServerOptions) -> VideoItem { async fn enrich_video(&self, item: VideoItem, options: &ServerOptions) -> VideoItem {
let page_url = item.url.clone(); let page_url = item.url.clone();
let format_url = Self::proxied_video(options, &page_url); let format_url = Self::proxied_video(options, &page_url);
@@ -1148,11 +1164,15 @@ impl ArchivebateProvider {
platform: candidate.platform.clone(), platform: candidate.platform.clone(),
gender: candidate.gender.clone(), gender: candidate.gender.clone(),
}; };
let items = self // A candidate whose profile page is gone (the search index lists
// deleted profiles) must not abort the whole search: try the next.
match self
.fetch_items_for_target(cache.clone(), &target, 1, per_page, &options) .fetch_items_for_target(cache.clone(), &target, 1, per_page, &options)
.await?; .await
if !items.is_empty() { {
return Ok(items); Ok(items) if !items.is_empty() => return Ok(items),
Ok(_) => {}
Err(_) => {}
} }
} }
@@ -1199,11 +1219,11 @@ impl Provider for ArchivebateProvider {
.await; .await;
match timeout_result { match timeout_result {
Ok(enriched) => enriched, Ok(enriched) => enriched,
Err(_) => video, Err(_) => Self::with_default_format(video, &options),
} }
} }
})) }))
.buffer_unordered(4) .buffered(4)
.collect::<Vec<_>>() .collect::<Vec<_>>()
.await .await
} }