fix (#990)
This commit is contained in:
parent
a645444f25
commit
e28805a5cf
|
@ -12,8 +12,10 @@ import JellyfinAPI
|
||||||
|
|
||||||
extension JellyfinClient {
|
extension JellyfinClient {
|
||||||
|
|
||||||
func fullURL<T>(with request: Request<T>) -> URL {
|
func fullURL<T>(with request: Request<T>) -> URL? {
|
||||||
let fullPath = configuration.url.appendingPathComponent(request.url?.path ?? "")
|
|
||||||
|
guard let path = request.url?.path else { return configuration.url }
|
||||||
|
guard let fullPath = fullURL(with: path) else { return nil }
|
||||||
|
|
||||||
var components = URLComponents(string: fullPath.absoluteString)!
|
var components = URLComponents(string: fullPath.absoluteString)!
|
||||||
components.queryItems = request.query?.map { URLQueryItem(name: $0.0, value: $0.1) } ?? []
|
components.queryItems = request.query?.map { URLQueryItem(name: $0.0, value: $0.1) } ?? []
|
||||||
|
@ -21,7 +23,11 @@ extension JellyfinClient {
|
||||||
return components.url ?? fullPath
|
return components.url ?? fullPath
|
||||||
}
|
}
|
||||||
|
|
||||||
func fullURL(with path: String) -> URL {
|
/// Appends the path to the current configuration `URL`, assuming that the path begins with a leading `/`.
|
||||||
URL(string: configuration.url.absoluteString + path)!
|
/// Returns `nil` if the new `URL` is malformed.
|
||||||
|
func fullURL(with path: String) -> URL? {
|
||||||
|
guard let fullPath = URL(string: configuration.url.absoluteString.trimmingCharacters(in: ["/"]) + path)
|
||||||
|
else { return nil }
|
||||||
|
return fullPath
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ import Foundation
|
||||||
import JellyfinAPI
|
import JellyfinAPI
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
|
// TODO: strongly type errors
|
||||||
|
|
||||||
extension MediaSourceInfo {
|
extension MediaSourceInfo {
|
||||||
|
|
||||||
func videoPlayerViewModel(with item: BaseItemDto, playSessionID: String) throws -> VideoPlayerViewModel {
|
func videoPlayerViewModel(with item: BaseItemDto, playSessionID: String) throws -> VideoPlayerViewModel {
|
||||||
|
@ -21,8 +23,8 @@ extension MediaSourceInfo {
|
||||||
let streamType: StreamType
|
let streamType: StreamType
|
||||||
|
|
||||||
if let transcodingURL, !Defaults[.Experimental.forceDirectPlay] {
|
if let transcodingURL, !Defaults[.Experimental.forceDirectPlay] {
|
||||||
guard let fullTranscodeURL = URL(string: transcodingURL, relativeTo: userSession.server.currentURL)
|
guard let fullTranscodeURL = userSession.client.fullURL(with: transcodingURL)
|
||||||
else { throw JellyfinAPIError("Unable to construct transcoded url") }
|
else { throw JellyfinAPIError("Unable to make transcode URL") }
|
||||||
playbackURL = fullTranscodeURL
|
playbackURL = fullTranscodeURL
|
||||||
streamType = .transcode
|
streamType = .transcode
|
||||||
} else {
|
} else {
|
||||||
|
@ -39,7 +41,10 @@ extension MediaSourceInfo {
|
||||||
parameters: videoStreamParameters
|
parameters: videoStreamParameters
|
||||||
)
|
)
|
||||||
|
|
||||||
playbackURL = userSession.client.fullURL(with: videoStreamRequest)
|
guard let streamURL = userSession.client.fullURL(with: videoStreamRequest)
|
||||||
|
else { throw JellyfinAPIError("Unable to make stream URL") }
|
||||||
|
|
||||||
|
playbackURL = streamURL
|
||||||
streamType = .direct
|
streamType = .direct
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ extension MediaStream {
|
||||||
let client = Container.userSession().client
|
let client = Container.userSession().client
|
||||||
let deliveryPath = deliveryURL.removingFirst(if: client.configuration.url.absoluteString.last == "/")
|
let deliveryPath = deliveryURL.removingFirst(if: client.configuration.url.absoluteString.last == "/")
|
||||||
|
|
||||||
let fullURL = client.fullURL(with: deliveryPath)
|
guard let fullURL = client.fullURL(with: deliveryPath) else { return nil }
|
||||||
|
|
||||||
return .init(
|
return .init(
|
||||||
url: fullURL,
|
url: fullURL,
|
||||||
|
|
|
@ -57,7 +57,8 @@ class VideoPlayerViewModel: ViewModel {
|
||||||
parameters: parameters
|
parameters: parameters
|
||||||
)
|
)
|
||||||
|
|
||||||
let hlsStreamComponents = URLComponents(url: userSession.client.fullURL(with: request), resolvingAgainstBaseURL: false)!
|
// TODO: don't force unwrap
|
||||||
|
let hlsStreamComponents = URLComponents(url: userSession.client.fullURL(with: request)!, resolvingAgainstBaseURL: false)!
|
||||||
.addingQueryItem(key: "api_key", value: userSession.user.accessToken)
|
.addingQueryItem(key: "api_key", value: userSession.user.accessToken)
|
||||||
|
|
||||||
return hlsStreamComponents.url!
|
return hlsStreamComponents.url!
|
||||||
|
|
|
@ -2535,8 +2535,7 @@
|
||||||
E148128728C154BF003B8787 /* ItemFilter+ItemTrait.swift */,
|
E148128728C154BF003B8787 /* ItemFilter+ItemTrait.swift */,
|
||||||
E11B1B6B2718CD68006DA3E8 /* JellyfinAPIError.swift */,
|
E11B1B6B2718CD68006DA3E8 /* JellyfinAPIError.swift */,
|
||||||
E12A9EF729499E0100731C3A /* JellyfinClient.swift */,
|
E12A9EF729499E0100731C3A /* JellyfinClient.swift */,
|
||||||
E1D8428E2933F2D900D1041A /* MediaSourceInfo.swift */,
|
E1F5F9B12BA0200500BA5014 /* MediaSourceInfo */,
|
||||||
E18A8E7F28D6083700333B9A /* MediaSourceInfo+ItemVideoPlayerViewModel.swift */,
|
|
||||||
E122A9122788EAAD0060FA63 /* MediaStream.swift */,
|
E122A9122788EAAD0060FA63 /* MediaStream.swift */,
|
||||||
E1AD105E26D9ADDD003E4A08 /* NameGuidPair.swift */,
|
E1AD105E26D9ADDD003E4A08 /* NameGuidPair.swift */,
|
||||||
E148128428C15472003B8787 /* SortOrder.swift */,
|
E148128428C15472003B8787 /* SortOrder.swift */,
|
||||||
|
@ -2821,6 +2820,15 @@
|
||||||
path = PagingLibraryView;
|
path = PagingLibraryView;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
};
|
};
|
||||||
|
E1F5F9B12BA0200500BA5014 /* MediaSourceInfo */ = {
|
||||||
|
isa = PBXGroup;
|
||||||
|
children = (
|
||||||
|
E1D8428E2933F2D900D1041A /* MediaSourceInfo.swift */,
|
||||||
|
E18A8E7F28D6083700333B9A /* MediaSourceInfo+ItemVideoPlayerViewModel.swift */,
|
||||||
|
);
|
||||||
|
path = MediaSourceInfo;
|
||||||
|
sourceTree = "<group>";
|
||||||
|
};
|
||||||
E1FA891C289A302600176FEB /* CollectionItemView */ = {
|
E1FA891C289A302600176FEB /* CollectionItemView */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
|
Loading…
Reference in New Issue