2021-06-28 20:32:13 +05:30
|
|
|
import AVFoundation
|
|
|
|
import Defaults
|
|
|
|
import Foundation
|
2021-08-26 03:42:59 +05:30
|
|
|
import SwiftyJSON
|
2021-06-28 20:32:13 +05:30
|
|
|
|
2021-09-01 02:47:50 +05:30
|
|
|
struct Channel: Identifiable, Hashable {
|
2022-11-27 16:12:16 +05:30
|
|
|
enum ContentType: String, Identifiable {
|
|
|
|
case videos
|
|
|
|
case playlists
|
|
|
|
case livestreams
|
|
|
|
case shorts
|
|
|
|
case channels
|
|
|
|
|
|
|
|
var id: String {
|
|
|
|
rawValue
|
|
|
|
}
|
|
|
|
|
|
|
|
var contentItemType: ContentItem.ContentType {
|
|
|
|
switch self {
|
|
|
|
case .videos:
|
|
|
|
return .video
|
|
|
|
case .playlists:
|
|
|
|
return .playlist
|
|
|
|
case .livestreams:
|
|
|
|
return .video
|
|
|
|
case .shorts:
|
|
|
|
return .video
|
|
|
|
case .channels:
|
|
|
|
return .channel
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct Tab: Identifiable, Hashable {
|
|
|
|
var contentType: ContentType
|
|
|
|
var data: String
|
|
|
|
|
|
|
|
var id: String {
|
|
|
|
contentType.id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-06-28 20:32:13 +05:30
|
|
|
var id: String
|
|
|
|
var name: String
|
2022-11-27 16:12:16 +05:30
|
|
|
var bannerURL: URL?
|
2021-10-22 04:59:10 +05:30
|
|
|
var thumbnailURL: URL?
|
2022-11-27 16:12:16 +05:30
|
|
|
var description = ""
|
2021-09-01 02:47:50 +05:30
|
|
|
|
2022-11-27 16:12:16 +05:30
|
|
|
var subscriptionsCount: Int?
|
|
|
|
var subscriptionsText: String?
|
|
|
|
|
|
|
|
var totalViews: Int?
|
|
|
|
var verified: Bool? // swiftlint:disable discouraged_optional_boolean
|
|
|
|
|
|
|
|
var videos = [Video]()
|
|
|
|
var tabs = [Tab]()
|
2021-09-01 02:47:50 +05:30
|
|
|
|
2021-12-18 01:31:05 +05:30
|
|
|
var detailsLoaded: Bool {
|
|
|
|
!subscriptionsString.isNil
|
|
|
|
}
|
|
|
|
|
2021-09-01 02:47:50 +05:30
|
|
|
var subscriptionsString: String? {
|
2021-10-22 04:59:10 +05:30
|
|
|
if subscriptionsCount != nil, subscriptionsCount! > 0 {
|
2021-09-01 02:47:50 +05:30
|
|
|
return subscriptionsCount!.formattedAsAbbreviation()
|
|
|
|
}
|
|
|
|
|
|
|
|
return subscriptionsText
|
|
|
|
}
|
|
|
|
|
2022-11-27 16:12:16 +05:30
|
|
|
var totalViewsString: String? {
|
|
|
|
guard let totalViews, totalViews > 0 else { return nil }
|
|
|
|
|
|
|
|
return totalViews.formattedAsAbbreviation()
|
|
|
|
}
|
|
|
|
|
2021-09-01 02:47:50 +05:30
|
|
|
func hash(into hasher: inout Hasher) {
|
|
|
|
hasher.combine(id)
|
2021-06-28 20:32:13 +05:30
|
|
|
}
|
2022-11-27 16:12:16 +05:30
|
|
|
|
|
|
|
var contentItem: ContentItem {
|
|
|
|
ContentItem(channel: self)
|
|
|
|
}
|
2021-06-28 20:32:13 +05:30
|
|
|
}
|