mirror of
https://github.com/yattee/yattee.git
synced 2024-12-23 05:53:41 +00:00
24 lines
744 B
Swift
24 lines
744 B
Swift
|
import Alamofire
|
||
|
import Foundation
|
||
|
import SwiftyJSON
|
||
|
|
||
|
class SubscriptionVideosProvider: DataProvider {
|
||
|
@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)
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|