Implement SponsorBlock API

This commit is contained in:
Arkadiusz Fal
2021-06-18 00:43:29 +02:00
parent 9d7abda63f
commit d551dee426
9 changed files with 190 additions and 29 deletions

View File

@@ -12,29 +12,11 @@ final class Video: Identifiable, ObservableObject {
var published: String
var views: Int
var channelID: String
var description: String
var genre: String
var streams = [Stream]()
init(
id: String,
title: String,
thumbnailURL: URL?,
author: String,
length: TimeInterval,
published: String,
views: Int,
channelID: String
) {
self.id = id
self.title = title
self.thumbnailURL = thumbnailURL
self.author = author
self.length = length
self.published = published
self.views = views
self.channelID = channelID
}
init(_ json: JSON) {
id = json["videoId"].stringValue
title = json["title"].stringValue
@@ -43,6 +25,9 @@ final class Video: Identifiable, ObservableObject {
published = json["publishedText"].stringValue
views = json["viewCount"].intValue
channelID = json["authorId"].stringValue
description = json["description"].stringValue
genre = json["genre"].stringValue
thumbnailURL = extractThumbnailURL(from: json)
streams = extractFormatStreams(from: json["formatStreams"].arrayValue)