mirror of
https://github.com/yattee/yattee.git
synced 2026-07-20 14:22:02 +00:00
Fall back to lower-quality thumbnails when higher-res variants 404
YouTube's CDN advertises maxres/sddefault thumbnails for every video but only generates them for sufficiently high-res uploads, so older/low-res videos return 404 for those qualities. The view picked the best quality and showed a blank placeholder on failure with no fallback. VideoThumbnailView now accepts an ordered fallback chain and advances to the next candidate via NukeUI's onCompletion when a load fails, so a valid thumbnail is always shown. DeArrowVideoThumbnail feeds it DeArrow branding first, then the video's own thumbnails best-quality-first.
This commit is contained in:
@@ -91,6 +91,15 @@ struct Video: Identifiable, Codable, Sendable {
|
||||
thumbnails.sorted { $0.quality > $1.quality }.first
|
||||
}
|
||||
|
||||
/// Thumbnail URLs ordered best-quality-first.
|
||||
///
|
||||
/// Used as a fallback chain: backends (and YouTube's CDN) often advertise
|
||||
/// `maxres`/`sddefault` variants that don't actually exist for a given video
|
||||
/// and 404. Consumers try these in order and drop to the next when one fails.
|
||||
var thumbnailURLsByQuality: [URL] {
|
||||
thumbnails.sorted { $0.quality > $1.quality }.map(\.url)
|
||||
}
|
||||
|
||||
var formattedDuration: String {
|
||||
guard !isLive else { return "LIVE" }
|
||||
guard duration > 0 else { return "" }
|
||||
|
||||
Reference in New Issue
Block a user