mirror of
https://github.com/yattee/yattee.git
synced 2025-08-06 10:44:06 +00:00
Add tvOS streams selection
This commit is contained in:
@@ -20,13 +20,13 @@ struct Instance: Defaults.Serializable, Hashable, Identifiable {
|
||||
let sid: String
|
||||
let anonymous: Bool
|
||||
|
||||
init(id: String? = nil, instanceID: UUID, name: String? = nil, url: String, sid: String? = nil, anonymous: Bool = false) {
|
||||
init(id: String? = nil, instanceID: UUID? = nil, name: String? = nil, url: String? = nil, sid: String? = nil, anonymous: Bool = false) {
|
||||
self.anonymous = anonymous
|
||||
|
||||
self.id = id ?? (anonymous ? "anonymous-\(instanceID)" : UUID().uuidString)
|
||||
self.instanceID = instanceID
|
||||
self.id = id ?? (anonymous ? "anonymous-\(instanceID!)" : UUID().uuidString)
|
||||
self.instanceID = instanceID ?? UUID()
|
||||
self.name = name
|
||||
self.url = url
|
||||
self.url = url ?? ""
|
||||
self.sid = sid ?? ""
|
||||
}
|
||||
|
||||
|
@@ -15,6 +15,7 @@ final class InvidiousAPI: Service, ObservableObject {
|
||||
super.init()
|
||||
|
||||
guard !account.isNil else {
|
||||
self.account = .init(name: "Empty")
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -10,6 +10,10 @@ extension PlayerModel {
|
||||
!stream.isNil && stream != streamSelection
|
||||
}
|
||||
|
||||
var availableStreamsSorted: [Stream] {
|
||||
availableStreams.sorted(by: streamsSorter)
|
||||
}
|
||||
|
||||
func loadAvailableStreams(
|
||||
_ video: Video,
|
||||
completionHandler: @escaping ([Stream]) -> Void = { _ in }
|
||||
@@ -97,4 +101,8 @@ extension PlayerModel {
|
||||
func streamsWithAssetsFromInstance(instance: Instance, streams: [Stream]) -> [Stream] {
|
||||
streams.map { stream in stream.withAssetsFrom(instance) }
|
||||
}
|
||||
|
||||
func streamsSorter(_ lhs: Stream, _ rhs: Stream) -> Bool {
|
||||
lhs.kind == rhs.kind ? (lhs.resolution.height > rhs.resolution.height) : (lhs.kind < rhs.kind)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user