Load a single link from Open Link into its details screen

Open Link gets a Load action that resolves one link and shows its video
details page, playlist or channel screen instead of only playing or
downloading it. Play and Download stay as shortcuts for video links.
Timed links start at their timestamp from the details page, the Show
Details link action opens the details page, and a short extraction cache
avoids re-extracting the same link for details and playback.
This commit is contained in:
Arkadiusz Fal
2026-10-08 18:25:32 +02:00
parent b9e7d88a12
commit 03be964c66
8 changed files with 245 additions and 68 deletions

View File

@@ -676,9 +676,25 @@ actor ContentService: ContentServiceProtocol {
guard instance.type == .yatteeServer else {
throw APIError.notSupported
}
return try await yatteeServerAPI(for: instance).extractURL(url, instance: instance)
// Keyed by link only: callers pick the Yattee Server differently, and
// any server returns equivalent streams within the TTL.
let key = url.absoluteString
if let cached = recentExtractions[key], Date().timeIntervalSince(cached.date) < Self.extractionCacheTTL {
return cached.result
}
let result = try await yatteeServerAPI(for: instance).extractURL(url, instance: instance)
recentExtractions = recentExtractions.filter { Date().timeIntervalSince($0.value.date) < Self.extractionCacheTTL }
recentExtractions[key] = (result, Date())
return result
}
/// How long an extraction is reused. A link opened from Open Link is
/// extracted to show its details page, which re-extracts for full details,
/// and Play extracts again; all three share one Yattee Server request.
/// Short, so a retry after a failed stream soon fetches fresh URLs.
private static let extractionCacheTTL: TimeInterval = 60
private var recentExtractions: [String: (result: (video: Video, streams: [Stream], captions: [Caption]), date: Date)] = [:]
/// Extracts channel/user videos from any URL that yt-dlp supports.
/// Requires a Yattee Server instance.
///