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
750 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]()
var sid: String = "RpoS7YPPK2-QS81jJF9z4KSQAjmzsOnMpn84c73-GQ8="
func load() {
let headers = HTTPHeaders([HTTPHeader(name: "Cookie", value: "SID=\(sid)")])
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)
}
}
}
}