mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Channels search, add SDWebImage framework
This commit is contained in:
@@ -6,31 +6,30 @@ import SwiftyJSON
|
||||
struct Channel: Identifiable, Hashable {
|
||||
var id: String
|
||||
var name: String
|
||||
var thumbnailURL: URL?
|
||||
var videos = [Video]()
|
||||
|
||||
private var subscriptionsCount: Int?
|
||||
private var subscriptionsText: String?
|
||||
|
||||
init(json: JSON) {
|
||||
id = json["authorId"].stringValue
|
||||
name = json["author"].stringValue
|
||||
subscriptionsCount = json["subCount"].int
|
||||
subscriptionsText = json["subCountText"].string
|
||||
|
||||
if let channelVideos = json.dictionaryValue["latestVideos"] {
|
||||
videos = channelVideos.arrayValue.map(Video.init)
|
||||
}
|
||||
}
|
||||
|
||||
init(id: String, name: String, subscriptionsCount: Int? = nil, videos: [Video] = []) {
|
||||
init(
|
||||
id: String,
|
||||
name: String,
|
||||
thumbnailURL: URL? = nil,
|
||||
subscriptionsCount: Int? = nil,
|
||||
subscriptionsText: String? = nil,
|
||||
videos: [Video] = []
|
||||
) {
|
||||
self.id = id
|
||||
self.name = name
|
||||
self.thumbnailURL = thumbnailURL
|
||||
self.subscriptionsCount = subscriptionsCount
|
||||
self.subscriptionsText = subscriptionsText
|
||||
self.videos = videos
|
||||
}
|
||||
|
||||
var subscriptionsString: String? {
|
||||
if subscriptionsCount != nil {
|
||||
if subscriptionsCount != nil, subscriptionsCount! > 0 {
|
||||
return subscriptionsCount!.formattedAsAbbreviation()
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user