mirror of
https://github.com/yattee/yattee.git
synced 2025-01-08 22:07:10 +00:00
Add upstream fix for Invidious thumbnails
On John Ternus request (@llsc12)
This commit is contained in:
parent
312587ee05
commit
b9e7b287d8
@ -439,8 +439,23 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func extractThumbnails(from details: JSON) -> [Thumbnail] {
|
private func extractThumbnails(from details: JSON) -> [Thumbnail] {
|
||||||
details["videoThumbnails"].arrayValue.map { json in
|
details["videoThumbnails"].arrayValue.compactMap { json in
|
||||||
Thumbnail(url: json["url"].url!, quality: .init(rawValue: json["quality"].string!)!)
|
guard let url = json["url"].url,
|
||||||
|
var components = URLComponents(url: url, resolvingAgainstBaseURL: false),
|
||||||
|
let quality = json["quality"].string
|
||||||
|
else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// some of instances are not configured properly and return http thumbnails links
|
||||||
|
// http connections are not allowed in the app so we can safely convert it to https
|
||||||
|
components.scheme = "https"
|
||||||
|
|
||||||
|
guard let thumbnailUrl = components.url else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return Thumbnail(url: thumbnailUrl, quality: .init(rawValue: quality)!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user