Extended Piped support

This commit is contained in:
Arkadiusz Fal
2021-10-21 00:21:50 +02:00
parent 2d075e7b3a
commit c3326a56af
46 changed files with 706 additions and 458 deletions

View File

@@ -12,8 +12,8 @@ struct Video: Identifiable, Equatable, Hashable {
var length: TimeInterval
var published: String
var views: Int
var description: String
var genre: String
var description: String?
var genre: String?
// index used when in the Playlist
let indexID: String?
@@ -38,8 +38,8 @@ struct Video: Identifiable, Equatable, Hashable {
length: TimeInterval,
published: String,
views: Int,
description: String,
genre: String,
description: String? = nil,
genre: String? = nil,
channel: Channel,
thumbnails: [Thumbnail] = [],
indexID: String? = nil,
@@ -48,7 +48,8 @@ struct Video: Identifiable, Equatable, Hashable {
publishedAt: Date? = nil,
likes: Int? = nil,
dislikes: Int? = nil,
keywords: [String] = []
keywords: [String] = [],
streams: [Stream] = []
) {
self.id = id ?? UUID().uuidString
self.videoID = videoID
@@ -68,6 +69,7 @@ struct Video: Identifiable, Equatable, Hashable {
self.likes = likes
self.dislikes = dislikes
self.keywords = keywords
self.streams = streams
}
init(_ json: JSON) {
@@ -169,7 +171,11 @@ struct Video: Identifiable, Equatable, Hashable {
}
func thumbnailURL(quality: Thumbnail.Quality) -> URL? {
thumbnails.first { $0.quality == quality }?.url
if let url = thumbnails.first(where: { $0.quality == quality })?.url.absoluteString {
return URL(string: url.replacingOccurrences(of: "hqdefault", with: quality.filename))
}
return nil
}
private static func extractThumbnails(from details: JSON) -> [Thumbnail] {