2021-06-28 15:02:13 +00:00
|
|
|
import AVFoundation
|
|
|
|
import Defaults
|
|
|
|
import Foundation
|
2021-08-25 22:12:59 +00:00
|
|
|
import SwiftyJSON
|
2021-06-28 15:02:13 +00:00
|
|
|
|
2021-08-31 21:17:50 +00:00
|
|
|
struct Channel: Identifiable, Hashable {
|
2021-06-28 15:02:13 +00:00
|
|
|
var id: String
|
|
|
|
var name: String
|
2021-10-21 23:29:10 +00:00
|
|
|
var thumbnailURL: URL?
|
2021-08-31 21:17:50 +00:00
|
|
|
var videos = [Video]()
|
|
|
|
|
|
|
|
private var subscriptionsCount: Int?
|
|
|
|
private var subscriptionsText: String?
|
2021-06-28 15:02:13 +00:00
|
|
|
|
2021-10-21 23:29:10 +00:00
|
|
|
init(
|
|
|
|
id: String,
|
|
|
|
name: String,
|
|
|
|
thumbnailURL: URL? = nil,
|
|
|
|
subscriptionsCount: Int? = nil,
|
|
|
|
subscriptionsText: String? = nil,
|
|
|
|
videos: [Video] = []
|
|
|
|
) {
|
2021-08-25 22:12:59 +00:00
|
|
|
self.id = id
|
|
|
|
self.name = name
|
2021-10-21 23:29:10 +00:00
|
|
|
self.thumbnailURL = thumbnailURL
|
2021-08-25 22:12:59 +00:00
|
|
|
self.subscriptionsCount = subscriptionsCount
|
2021-10-21 23:29:10 +00:00
|
|
|
self.subscriptionsText = subscriptionsText
|
2021-08-31 21:17:50 +00:00
|
|
|
self.videos = videos
|
|
|
|
}
|
|
|
|
|
2021-12-17 20:01:05 +00:00
|
|
|
var detailsLoaded: Bool {
|
|
|
|
!subscriptionsString.isNil
|
|
|
|
}
|
|
|
|
|
2021-08-31 21:17:50 +00:00
|
|
|
var subscriptionsString: String? {
|
2021-10-21 23:29:10 +00:00
|
|
|
if subscriptionsCount != nil, subscriptionsCount! > 0 {
|
2021-08-31 21:17:50 +00:00
|
|
|
return subscriptionsCount!.formattedAsAbbreviation()
|
|
|
|
}
|
|
|
|
|
|
|
|
return subscriptionsText
|
|
|
|
}
|
|
|
|
|
|
|
|
func hash(into hasher: inout Hasher) {
|
|
|
|
hasher.combine(id)
|
2021-06-28 15:02:13 +00:00
|
|
|
}
|
|
|
|
}
|