mirror of
https://github.com/yattee/yattee.git
synced 2024-12-15 23:00:32 +05:30
24 lines
717 B
Swift
24 lines
717 B
Swift
import Alamofire
|
|
import Foundation
|
|
import SwiftyJSON
|
|
|
|
final class SubscriptionVideosProvider: DataProvider {
|
|
@Published var videos = [Video]()
|
|
|
|
let profile = Profile()
|
|
|
|
func load() {
|
|
let headers = HTTPHeaders([HTTPHeader(name: "Cookie", value: "SID=\(profile.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)
|
|
}
|
|
}
|
|
}
|
|
}
|