mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Add option to disable proxying video streams for Invidious
This commit is contained in:
@@ -9,13 +9,15 @@ struct Instance: Defaults.Serializable, Hashable, Identifiable {
|
||||
let name: String
|
||||
let apiURL: String
|
||||
var frontendURL: String?
|
||||
var proxiesVideos: Bool
|
||||
|
||||
init(app: VideosApp, id: String? = nil, name: String, apiURL: String, frontendURL: String? = nil) {
|
||||
init(app: VideosApp, id: String? = nil, name: String, apiURL: String, frontendURL: String? = nil, proxiesVideos: Bool = false) {
|
||||
self.app = app
|
||||
self.id = id ?? UUID().uuidString
|
||||
self.name = name
|
||||
self.apiURL = apiURL
|
||||
self.frontendURL = frontendURL
|
||||
self.proxiesVideos = proxiesVideos
|
||||
}
|
||||
|
||||
var anonymous: VideosAPI {
|
||||
|
@@ -15,7 +15,8 @@ struct InstancesBridge: Defaults.Bridge {
|
||||
"id": value.id,
|
||||
"name": value.name,
|
||||
"apiURL": value.apiURL,
|
||||
"frontendURL": value.frontendURL ?? ""
|
||||
"frontendURL": value.frontendURL ?? "",
|
||||
"proxiesVideos": value.proxiesVideos ? "true" : "false"
|
||||
]
|
||||
}
|
||||
|
||||
@@ -30,8 +31,9 @@ struct InstancesBridge: Defaults.Bridge {
|
||||
}
|
||||
|
||||
let name = object["name"] ?? ""
|
||||
|
||||
let frontendURL: String? = object["frontendURL"]!.isEmpty ? nil : object["frontendURL"]
|
||||
return Instance(app: app, id: id, name: name, apiURL: apiURL, frontendURL: frontendURL)
|
||||
let proxiesVideos = object["proxiesVideos"] == "true"
|
||||
|
||||
return Instance(app: app, id: id, name: name, apiURL: apiURL, frontendURL: frontendURL, proxiesVideos: proxiesVideos)
|
||||
}
|
||||
}
|
||||
|
@@ -52,6 +52,17 @@ final class InstancesModel: ObservableObject {
|
||||
}
|
||||
}
|
||||
|
||||
static func setProxiesVideos(_ instance: Instance, _ proxiesVideos: Bool) {
|
||||
guard let index = Defaults[.instances].firstIndex(where: { $0.id == instance.id }) else {
|
||||
return
|
||||
}
|
||||
|
||||
var instance = Defaults[.instances][index]
|
||||
instance.proxiesVideos = proxiesVideos
|
||||
|
||||
Defaults[.instances][index] = instance
|
||||
}
|
||||
|
||||
static func remove(_ instance: Instance) {
|
||||
let accounts = Self.accounts(instance.id)
|
||||
if let index = Defaults[.instances].firstIndex(where: { $0.id == instance.id }) {
|
||||
|
@@ -58,4 +58,8 @@ enum VideosApp: String, CaseIterable {
|
||||
var supportsOpeningChannelsByName: Bool {
|
||||
self == .piped
|
||||
}
|
||||
|
||||
var allowsDisablingVidoesProxying: Bool {
|
||||
self == .invidious
|
||||
}
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ extension PlayerModel {
|
||||
streams.map { stream in
|
||||
stream.instance = instance
|
||||
|
||||
if instance.app == .invidious {
|
||||
if instance.app == .invidious, instance.proxiesVideos {
|
||||
if let audio = stream.audioAsset {
|
||||
stream.audioAsset = InvidiousAPI.proxiedAsset(instance: instance, asset: audio)
|
||||
}
|
||||
|
Reference in New Issue
Block a user