2021-06-26 09:39:35 +00:00
|
|
|
import Foundation
|
|
|
|
import SwiftyJSON
|
|
|
|
|
2021-06-28 15:27:53 +00:00
|
|
|
struct Playlist: Identifiable, Equatable, Hashable {
|
2021-06-26 09:39:35 +00:00
|
|
|
let id: String
|
|
|
|
var title: String
|
2021-07-08 17:18:36 +00:00
|
|
|
var visibility: PlaylistVisibility
|
2021-06-26 09:39:35 +00:00
|
|
|
|
|
|
|
var videos = [Video]()
|
|
|
|
|
|
|
|
init(_ json: JSON) {
|
|
|
|
id = json["playlistId"].stringValue
|
|
|
|
title = json["title"].stringValue
|
2021-07-08 17:18:36 +00:00
|
|
|
visibility = json["isListed"].boolValue ? .public : .private
|
2021-06-26 09:39:35 +00:00
|
|
|
videos = json["videos"].arrayValue.map { Video($0) }
|
|
|
|
}
|
|
|
|
|
|
|
|
static func == (lhs: Playlist, rhs: Playlist) -> Bool {
|
2021-07-08 17:18:36 +00:00
|
|
|
lhs.id == rhs.id && lhs.title == rhs.title && lhs.visibility == rhs.visibility
|
2021-06-26 09:39:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func hash(into hasher: inout Hasher) {
|
|
|
|
hasher.combine(id)
|
|
|
|
}
|
|
|
|
}
|