Playlists support

This commit is contained in:
Arkadiusz Fal
2021-06-26 11:39:35 +02:00
parent 594c77b7d4
commit b336d2c512
14 changed files with 189 additions and 85 deletions

25
Model/Playlist.swift Normal file
View File

@@ -0,0 +1,25 @@
import Foundation
import SwiftyJSON
final class Playlist: Identifiable, ObservableObject, Equatable, Hashable {
let id: String
var title: String
var description: String
var videos = [Video]()
init(_ json: JSON) {
id = json["playlistId"].stringValue
title = json["title"].stringValue
description = json["description"].stringValue
videos = json["videos"].arrayValue.map { Video($0) }
}
static func == (lhs: Playlist, rhs: Playlist) -> Bool {
lhs.id == rhs.id
}
func hash(into hasher: inout Hasher) {
hasher.combine(id)
}
}