mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Subscriptions view
This commit is contained in:
@@ -2,8 +2,8 @@ import Foundation
|
||||
|
||||
class AppState: ObservableObject {
|
||||
@Published var showingChannel = false
|
||||
@Published var channelID: String?
|
||||
@Published var channel: String?
|
||||
@Published var channelID: String = ""
|
||||
@Published var channel: String = ""
|
||||
|
||||
func openChannel(from video: Video) {
|
||||
channel = video.author
|
||||
@@ -13,7 +13,7 @@ class AppState: ObservableObject {
|
||||
|
||||
func closeChannel() {
|
||||
showingChannel = false
|
||||
channel = nil
|
||||
channelID = nil
|
||||
channel = ""
|
||||
channelID = ""
|
||||
}
|
||||
}
|
||||
|
@@ -4,8 +4,8 @@ import Foundation
|
||||
class DataProvider: ObservableObject {
|
||||
static let instance = "https://invidious.home.arekf.net"
|
||||
|
||||
static func request(_ path: String) -> DataRequest {
|
||||
AF.request(apiURLString(path))
|
||||
static func request(_ path: String, headers: HTTPHeaders? = nil) -> DataRequest {
|
||||
AF.request(apiURLString(path), headers: headers)
|
||||
}
|
||||
|
||||
static func apiURLString(_ path: String) -> String {
|
||||
|
23
Model/SubscriptionVideosProvider.swift
Normal file
23
Model/SubscriptionVideosProvider.swift
Normal file
@@ -0,0 +1,23 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user