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

24 lines
717 B
Swift
Raw Normal View History

2021-06-12 04:19:42 +05:30
import Alamofire
import Foundation
import SwiftyJSON
2021-06-14 23:35:02 +05:30
final class SubscriptionVideosProvider: DataProvider {
2021-06-12 04:19:42 +05:30
@Published var videos = [Video]()
2021-06-20 01:40:14 +05:30
let profile = Profile()
2021-06-12 04:19:42 +05:30
func load() {
2021-06-20 01:40:14 +05:30
let headers = HTTPHeaders([HTTPHeader(name: "Cookie", value: "SID=\(profile.sid)")])
2021-06-12 04:19:42 +05:30
DataProvider.request("auth/feed", headers: headers).responseJSON { response in
switch response.result {
case let .success(value):
if let feedVideos = JSON(value).dictionaryValue["videos"] {
self.videos = feedVideos.arrayValue.map { Video($0) }
}
case let .failure(error):
print(error)
}
}
}
}