Add .player case to Page enum
This commit is contained in:
parent
6a7185f239
commit
6c246eadaa
2 changed files with 40 additions and 0 deletions
|
|
@ -685,6 +685,26 @@ public actor JellyfinClient {
|
|||
}
|
||||
}
|
||||
|
||||
public func pingPlaybackSession(playSessionId: String) async throws {
|
||||
guard token != nil else { throw JellyfinError.notAuthenticated }
|
||||
let response = try await client.pingPlaybackSession(
|
||||
Operations.PingPlaybackSession.Input(
|
||||
query: .init(playSessionId: playSessionId)
|
||||
))
|
||||
switch response {
|
||||
case .noContent:
|
||||
return
|
||||
case .unauthorized:
|
||||
throw JellyfinError.httpError(401)
|
||||
case .forbidden:
|
||||
throw JellyfinError.httpError(403)
|
||||
case .serviceUnavailable:
|
||||
throw JellyfinError.httpError(503)
|
||||
case .undocumented(let code, _):
|
||||
throw JellyfinError.httpError(code)
|
||||
}
|
||||
}
|
||||
|
||||
public func getLatestMedia(
|
||||
userId: String,
|
||||
parentId: String? = nil,
|
||||
|
|
@ -755,4 +775,22 @@ public actor JellyfinClient {
|
|||
if let tag { components.queryItems = [.init(name: "tag", value: tag)] }
|
||||
return components.url
|
||||
}
|
||||
|
||||
public func streamURL(
|
||||
itemId: String,
|
||||
mediaSourceId: String,
|
||||
playSessionId: String
|
||||
) -> URL? {
|
||||
guard var components = URLComponents(url: serverURL, resolvingAgainstBaseURL: false) else {
|
||||
return nil
|
||||
}
|
||||
components.path = "/Videos/\(itemId)/stream"
|
||||
components.queryItems = [
|
||||
.init(name: "static", value: "true"),
|
||||
.init(name: "mediaSourceId", value: mediaSourceId),
|
||||
.init(name: "playSessionId", value: playSessionId),
|
||||
.init(name: "api_key", value: token ?? ""),
|
||||
]
|
||||
return components.url
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,12 +23,14 @@ public enum Page: CustomStringConvertible {
|
|||
case item(item: BaseItemDto, type: DisplayType = .mixed)
|
||||
case items(title: String, items: [BaseItemDto], type: DisplayType = .mixed)
|
||||
case movieDetail(item: BaseItemDto)
|
||||
case player(PlayerState)
|
||||
|
||||
public var description: String {
|
||||
return switch self {
|
||||
case .item(let item, _): item.name ?? "Library"
|
||||
case .items(let title, _, _): title
|
||||
case .movieDetail(let item): item.name ?? "Luminate"
|
||||
case .player: "Now Playing"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue