1
0
mirror of https://github.com/yattee/yattee.git synced 2025-01-07 18:10:33 +05:30
yattee/Model/Playlist.swift

29 lines
724 B
Swift
Raw Normal View History

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