1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-16 07:10:31 +05:30
yattee/Model/ChannelVideosProvider.swift

27 lines
717 B
Swift
Raw Normal View History

2021-06-12 02:41:59 +05:30
import Foundation
import SwiftyJSON
2021-06-14 23:35:02 +05:30
final class ChannelVideosProvider: DataProvider {
2021-06-12 02:41:59 +05:30
@Published var videos = [Video]()
var channelID: String? = ""
func load() {
2021-06-14 23:35:02 +05:30
guard channelID != nil else {
return
}
2021-06-12 02:41:59 +05:30
let searchPath = "channels/\(channelID!)"
DataProvider.request(searchPath).responseJSON { response in
switch response.result {
case let .success(value):
if let channelVideos = JSON(value).dictionaryValue["latestVideos"] {
self.videos = channelVideos.arrayValue.map { Video($0) }
}
case let .failure(error):
print(error)
}
}
}
}